Givecash bug
#1

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?
Reply
#2

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

Код:
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;
	}
Reply
#4

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

Isnt there too much of it?
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)