SA-MP Forums Archive
Help needed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help needed (/showthread.php?tid=643739)



Help needed - Uvais - 26.10.2017

Код:
CMD:deploy(playerid, params[])
{
 if(PlayerClass[playerid] = AIR_TROOPER)
 {
 ShowPlayerDialog(playerid, DIALOG_DEPLOY, DIALOG_STYLE_LIST, "AirTrooper Deploy Menu", " America\n Russia\n Arabia\n France\n Australia\n Africa", "Select", "Cancel");
 }
 else SendClientMessage(playerid, RED,"[ERROR]: {FFFFFF}You need to spawn with airtrooper class to use this command.");
 return 1;
}
This works for all classes even though i want it to work for only airtrooper class only.


Re: Help needed - FailerZ - 26.10.2017

first you should be getting syntax error for that
Код:
if(PlayerClass[playerid] = AIR_TROOPER)
Correct it to
Код:
if(PlayerClass[playerid] == AIR_TROOPER)
Second, When the player is selecting the class you should set the variable of PlayerClass for the player to AIR_TROOPER so double check it.
And also make sure if you have your class defines it doesn't have the same value


Re: Help needed - Uvais - 26.10.2017

Код:
if(GetPlayerScore(playerid) >= 500)
           				{
             				ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Air Trooper:", "{F81414}Abilities:\n{FFFFFF}Can teleport to an enemy base (/deploy), invisible on map\n\n{F81414}Weapons:\n\n{FFFFFF}Knife\n{FFFFFF}Sniper\n{FFFFFF}Silenced Pistol", "Play","");
       			     		PlayerClass[playerid] = AIR_TROOPER;
       			     		ChosenClass[playerid] = 6;
       			     		SetPlayerVirtualWorld(playerid, 0);
       			     		TogglePlayerControllable(playerid, 1);
       			     		ResetPlayerWeapons(playerid);
 							GivePlayerWeapon(playerid, 4, 1);//knife
	    			  		GivePlayerWeapon(playerid, 23, 200);//silenced pistol
	    			  		GivePlayerWeapon(playerid, 34, 200);//sniper
  				    		RemovePlayerMapIcon(playerid, 0);
Well i have this to double check, it set's when the player is selecting class, the class defines don't have the same values. Checked.. What's the possible error?


Re: Help needed - FailerZ - 26.10.2017

You have to do some debugging then,
As maybe there is some function changing that variable on spawn or something.

Try that to see:
Put this under OnPlayerSpawn or make a command for it so you can test it in the game anytime OR just put it in the same command on top
Код:
printf("My class: %i - Should be class: %i", PlayerClass[playerid], AIR_TROOPER);
Check what does it print in the server console


Re: Help needed - Uvais - 26.10.2017

Код:
My class: 0 - Should be class: 6



Re: Help needed - FailerZ - 26.10.2017

I just saw seems you have to variables for the same purpose, Why is that?

Код:
     		PlayerClass[playerid] = AIR_TROOPER;
       		ChosenClass[playerid] = 6;
About that seems the PlayerClass variable is getting reset to 0 somewhere
Maybe the right one is ChoosenClass[playerid]


Re: Help needed - Uvais - 26.10.2017

Okay got it, the id's are the classes. Not their names, thanks for the help.