SA-MP Forums Archive
Givecash bug - 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: Givecash bug (/showthread.php?tid=132240)



Givecash bug - Puzi - 06.03.2010

Hello, I face a problem.
Any command I type that isnt in my script returns with USAGE: /givecash [playerid] message instead SERVER: Unknown Command message. Any ideas why does that happen?


Re: Givecash bug - Pawel2k9 - 06.03.2010

post the full code for
pawn Код:
public OnPlayerCommandText
here:


Re: Givecash bug - Puzi - 06.03.2010

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
Commands begin...

Код:
if(strcmp(cmd, "/givecash", true) == 0) {
	  new tmp[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
 		moneys = strval(tmp);

		printf("givecash_command: %d %d",giveplayerid,moneys);


		if (IsPlayerConnected(giveplayerid)) {
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			playermoney = GetPlayerMoney(playerid);
			if (moneys > 0 && playermoney >= moneys) {
				GivePlayerMoney(playerid, (0 - moneys));
				GivePlayerMoney(giveplayerid, moneys);
				format(stringa, sizeof(stringa), "You have sent %s (player: %d), $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_YELLOW, stringa);
				format(stringa, sizeof(stringa), "You have received $%d from %s (player: %d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, COLOR_YELLOW, stringa);
				printf("%s(playerid:%d) wysłał %d do %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
			}
			else {
				SendClientMessage(playerid, COLOR_YELLOW, "Incorrect amount.");
			}
		}
		else {
				format(stringa, sizeof(stringa), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_YELLOW, stringa);
			}
		return 1;
	}



Re: Givecash bug - Pawel2k9 - 06.03.2010

no i mean all of it from public to return 0; }


Re: Givecash bug - Puzi - 06.03.2010

Isnt there too much of it?


Re: Givecash bug - Correlli - 07.03.2010

Quote:
Originally Posted by Puzi
Hello, I face a problem.
Any command I type that isnt in my script returns with USAGE: /givecash [playerid] message instead SERVER: Unknown Command message. Any ideas why does that happen?
Make sure that you haven't messed any bracket at OnPlayerCommandText callback.