Jump to content
  • 0

vreau sa fac din comanda buton


mihai441

Question

am facut o poarta si vreau sa se deschida daca playerul apasa click , daca este  langa poarta  , daca se numeste ....  am facut ceva da nu merge



#include <a_samp>

#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_BLUE 0x2641FEAA
#define FILTERSCRIPT
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward GateClose();
new casa;
enum pInfo
{
pFishSkill,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnFilterScriptInit()
{
	casa = CreateObject(980, 1497.9704589844, -700.01293945313, 96.523391723633, 0, 0, 0);
    CreateObject(1239, 70.946022033691, -1523.2164306641, 4.0335631370544, 0, 0, 0);
    CreateObject(1872, 2484.0852050781, -1664.6156005859, 12.34375, 0, 0, 0);
    CreateObject(7505, 2470.2509765625, -1650.9846191406, 14.024735450745, 0, 0, 0);
    CreateObject(3749, 1497.7768554688, -698.67248535156, 99.608413696289, 0, 0, 0);
    CreateObject(3877, 1508.0806884766, -699.92834472656, 95.409622192383, 0, 0, 0);
    CreateObject(3877, 1487.1959228516, -700.11193847656, 95.415740966797, 0, 0, 0);
    CreateObject(3528, 1497.4173583984, -700.74462890625, 105.40616607666, 0, 0, 262);
	CreateObject(9833, 1481.1741943359, -685.87902832031, 107.33651733398, 0, 0, 0);
    CreateObject(9833, 1512.4923095703, -685.88250732422, 107.16002655029, 0, 0, 0);
     

}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
     if(newkeys == KEY_FIRE)
	 {
        if(PlayerToPoint(5,playerid,1497.7893,-700.6332,94.7500))
		 {
             if (PlayerInfo[playerid][pFishSkill] == 785)
			 {
                   MoveObject(casa, 1497.9704589844, -700.01293945313, 90.773391723633, 5.5);
                   SetTimer("GateClose", 2000, 0);
                   SendClientMessage(playerid, COLOR_BLUE,"Ai deschis poarta");
                   return 1;
             }
		  }
	}
	return 0;
}

public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

public GateClose()
{
    MoveObject (casa,1497.9704589844, -700.01293945313, 96.523391723633, 2.5);
    return 1;
}

nu apare eroare dar nu se deschide :( ma puteti ajuta?

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

Uita-te mai bine in filterscript, si observa ca pFishSkill, nu il folosesti nicaieri, doar il declari, de aici rezulta ca tot timpul, tabloul multidimensional pFishSkill, pt fiecare player o sa aiba valoarea 0 ... Daca, intr'adevar, vrei sa folosesti pFishSkill, atunci implementeaza acest FS in Gamemode.

Link to comment
Share on other sites

in loc de: if (PlayerInfo[playerid][pFishSkill] == 785) pui asa:

new str[MAX_PLAYER_NAME];
GetPlayerName(playerid,str,sizeof(str));
if(!strcmp(str,"KoBrA",false))
ia, foloseste FS asta ... e putin mai optimizat:
#include <a_samp>

#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_BLUE 0x2641FEAA

new casa;
forward GateClose();

public OnFilterScriptInit()
{
	casa = CreateObject(980, 1497.9704, -700.01293945313, 96.523391723633, 0, 0,   0);
    CreateObject(1239, 70.946022033691, -1523.2164306641, 4.0335631370544, 0, 0,   0);
    CreateObject(1872, 2484.0852050781, -1664.6156005859, 12.343752132345, 0, 0,   0);
    CreateObject(7505, 2470.2509765625, -1650.9846191406, 14.024735450745, 0, 0,   0);
    CreateObject(3749, 1497.7768554688, -698.67248535156, 99.608413696289, 0, 0,   0);
    CreateObject(3877, 1508.0806884766, -699.92834472656, 95.409622192383, 0, 0,   0);
    CreateObject(3877, 1487.1959228516, -700.11193847656, 95.415740966797, 0, 0,   0);
    CreateObject(3528, 1497.4173583984, -700.74462890625, 105.40616607666, 0, 0, 262);
	CreateObject(9833, 1481.1741943359, -685.87902832031, 107.33651733398, 0, 0,   0);
    CreateObject(9833, 1512.4923095703, -685.88250732422, 107.16002655029, 0, 0,   0);
    return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	static str[MAX_PLAYER_NAME];
	GetPlayerName(playerid,str,sizeof(str));
    if(newkeys & KEY_FIRE)
	{
       	if(IsPlayerInRangeOfPoint(playerid, 5.0, 1497.7893, -700.6332, 94.7500))
		{
        	if(!strcmp(str,"KoBrA",false))
			{
            	MoveObject(casa, 1497.9704589844, -700.01293945313, 90.773391723633, 5.5);
                SetTimer("GateClose", 2000, 0);
                SendClientMessage(playerid, COLOR_BLUE,"Ai deschis poarta.");
                return 1;
            }
		}
	}
	return 1;
}

public GateClose()
{
    MoveObject(casa, 1497.9704589844, -700.01293945313, 96.523391723633, 2.5);
    return 1;
}

pastebin: http://pastebin.com/NnQGqafe

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.