SA-MP Forums Archive
Wiered Problem, Half of a command don't work. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Wiered Problem, Half of a command don't work. (/showthread.php?tid=124369)



Wiered Problem, Half of a command don't work. - silvan - 30.01.2010

I did a command which half of it the if's part work but the last piece don't

Код:
	if(strcmp(cmd, "/promote", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /promote [playerid]");
		  return 1;
		}
		giveplayerid = strval(tmp);
	  if(PlayerInfo[playerid][policerank] != 4)
	  {
			SendClientMessage(playerid,COLOR_BRIGHTRED,"Only the chief can use this command!");
			return 1;
		}
		if(PlayerInfo[giveplayerid][policerank] == 0)
		{
		  SendClientMessage(playerid,COLOR_BRIGHTRED,"This player is not in the police force!");
		  return 1;
		}
		if(PlayerInfo[giveplayerid][policerank] == 3)           // Till here is working...
		{
		  SendClientMessage(playerid,COLOR_BRIGHTRED,"You cannot promote from Captian to Chief!");
		  return 1;
		}
		format(string, sizeof(string),"(PD Radio) Congratulations to %s , got promoted from %s to %s",PlayerInfo[giveplayerid][name],PoliceRank[PlayerInfo[playerid][policerank]-1][0],PoliceRank[PlayerInfo[playerid][policerank]][0]);           // From here onwards don't work.
		PlayerInfo[giveplayerid][policerank] += 1;
		SavePlayer(giveplayerid);
		SendMessageToPolice(COLOR_LIGHTBLUE,string);
		return 1;
	}
In my opinion there is nothing wrong with this command... but somehow it don't wanna work.


Re: Wiered Problem, Half of a command don't work. - ray187 - 30.01.2010

What doesn`t work. Does the string appear somehow on the screen if those if statements are false or what happens after that?


Re: Wiered Problem, Half of a command don't work. - silvan - 30.01.2010

erm the string don't appear... tghou the function is correct because i use it in other commands and they work fine... and for example when the player don't type the " playerid" after the command like : /promote 15 it say USAGE: /promote [playerid]

those if's works fine but if the server skips those if's it say unknown command....

Only this code don't work...
Код:
		format(string, sizeof(string),"(PD Radio) Congratulations to %s , got promoted from %s to %s",PlayerInfo[giveplayerid][name],PoliceRank[PlayerInfo[playerid][policerank]-1][0],PoliceRank[PlayerInfo[playerid][policerank]][0]);           // From here onwards don't work.
		PlayerInfo[giveplayerid][policerank] += 1;
		SavePlayer(giveplayerid);
		SendMessageToPolice(COLOR_LIGHTBLUE,string);
		return 1;
from all that command.... ( the important piece )

when the server should work that code... instead it displays " SERVER: Unknown command . "


Re: Wiered Problem, Half of a command don't work. - ray187 - 30.01.2010

Does your SendMessageToPolice function work properly, do you use it somewhere else where so it`s confirmed that it works as it should?

Do you probably use your Global array "string" in that function as well so they interfere?


Re: Wiered Problem, Half of a command don't work. - silvan - 30.01.2010

it works absulutely fine... i use it in several other places and it works fine even pawno it gives no errors or warnings at all


Re: Wiered Problem, Half of a command don't work. - ray187 - 30.01.2010

I still think you use your global array "string" in SavePlayer() or SendMessageToPolice() and they interfere somehow, but thats just a fast guess.


Re: Wiered Problem, Half of a command don't work. - silvan - 30.01.2010

SavePlayer Works fine too i use it everywhere in my gm


Re: Wiered Problem, Half of a command don't work. - ray187 - 30.01.2010

Just try this out for the command, then we`ll know:

Код:
	if(strcmp(cmd, "/promote", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /promote [playerid]");
		  return 1;
		}
		giveplayerid = strval(tmp);
	  if(PlayerInfo[playerid][policerank] != 4)
	  {
			SendClientMessage(playerid,COLOR_BRIGHTRED,"Only the chief can use this command!");
			return 1;
		}
		if(PlayerInfo[giveplayerid][policerank] == 0)
		{
		  SendClientMessage(playerid,COLOR_BRIGHTRED,"This player is not in the police force!");
		  return 1;
		}
		if(PlayerInfo[giveplayerid][policerank] == 3)           // Till here is working...
		{
		  SendClientMessage(playerid,COLOR_BRIGHTRED,"You cannot promote from Captian to Chief!");
		  return 1;
		}
		new opstr[128];
		format(opstr, sizeof(opstr),"(PD Radio) Congratulations to %s , got promoted from %s to %s",PlayerInfo[giveplayerid][name],PoliceRank[PlayerInfo[playerid][policerank]-1][0],PoliceRank[PlayerInfo[playerid][policerank]][0]);           // From here onwards don't work.
		PlayerInfo[giveplayerid][policerank] += 1;
		SavePlayer(giveplayerid);
		SendMessageToPolice(COLOR_LIGHTBLUE,opstr);
		return 1;
	}



Re: Wiered Problem, Half of a command don't work. - ray187 - 30.01.2010

And if that doesn`t work try this one:

Код:
	if(strcmp(cmd, "/promote", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /promote [playerid]");
		  return 1;
		}
		giveplayerid = strval(tmp);
	  if(PlayerInfo[playerid][policerank] != 4)
	  {
			SendClientMessage(playerid,COLOR_BRIGHTRED,"Only the chief can use this command!");
			return 1;
		}
		if(PlayerInfo[giveplayerid][policerank] == 0)
		{
		  SendClientMessage(playerid,COLOR_BRIGHTRED,"This player is not in the police force!");
		  return 1;
		}
		if(PlayerInfo[giveplayerid][policerank] == 3)           // Till here is working...
		{
		  SendClientMessage(playerid,COLOR_BRIGHTRED,"You cannot promote from Captian to Chief!");
		  return 1;
		}
		PlayerInfo[giveplayerid][policerank]++;
		format(string, sizeof(string),"(PD Radio) Congratulations to %s , got promoted from %s to %s",PlayerInfo[giveplayerid][name],PoliceRank[PlayerInfo[playerid][policerank]-1][0],PoliceRank[PlayerInfo[playerid][policerank]][0]);           // From here onwards don't work.
		SavePlayer(giveplayerid);
		SendMessageToPolice(COLOR_LIGHTBLUE,string);
		return 1;
	}



Re: Wiered Problem, Half of a command don't work. - ray187 - 30.01.2010

great ultra tripple post...

One of those should bring some solution.