Givecash command errors
#1

hello i try to edit the Givecash command from Wiki But i get those errors

Код:
C:\Users\Steven\Desktop\Server\gamemodes\Streetlife.pwn(210) : error 017: undefined symbol "amount"
C:\Users\Steven\Desktop\Server\gamemodes\Streetlife.pwn(365) : error 025: function heading differs from prototype
C:\Users\Steven\Desktop\Server\gamemodes\Streetlife.pwn(370) : error 029: invalid expression, assumed zero
C:\Users\Steven\Desktop\Server\gamemodes\Streetlife.pwn(365) : warning 203: symbol is never used: "params"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
And my Script look likes this:


InTopOfScript:
Код:
forward Givecash(playerid,amount);
Under OnPlayerCommandsText
Код:
if(strcmp(cmdtext, "/GiveCash", true, 3))
	{
		Givecash(playerid,amount);
	}
InTheBottem
Код:
Givecash(playerid, params[])
{
	new
		giveplayerid,
		amount;
	else
	{
		GivePlayerMoney(giveplayerid, amount);
		GivePlayerMoney(playerid, 0 - amount);
		SendClientMessage(playerid, 0x00FF00AA, "Money sent");
		SendClientMessage(giveplayerid, 0x00FF00AA, "Money received");
	}
	return 1;
}
Thx to anyone who help me.
Reply
#2

Well, just put the complete script under
pawn Код:
public OnPlayerText(playerid, text[])
Thats how i did. (im using same) xD


Hope i helped
Reply
#3

I am seeing the new else combination first time O.O
Reply
#4

Use sscanf from Wiki
Works fine at my script.

Cheers.

PS: The Errors just say, that you never declared "amount" as variable. You can fix that with sscanf

#Edit#:
Quote:
Originally Posted by DJDhan
I am seeing the new else combination first time O.O
Huh... lol
Reply
#5

You only need to forward public functions, so delete the forward line :P
Reply
#6

Quote:
Originally Posted by lrZ^ aka LarzI
You only need to forward public functions, so delete the forward line :P
But "amount" will still be undefined. Watch first Error :P
Reply
#7

Omg, this code is a huge fail -.-
check out DCMD and Sscanf
Reply
#8

OnPlayerCommandText()
pawn Код:
OnPlayerCommandText(playerid, cmdtext)
{
  new cmd[64], idx;
  new tmp[128];
  cmd = strtok(cmdtext, idx); // This is the command (e.g /help)
  if(strcmp(cmd, "/givecash", true) == 0)
  {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
      return SendClientMessage(playerid, COLOR_RED, "Usage: /givecash [playerid] [amount]");
   
    new player = strval(tmp);
   
    if(!IsPlayerConnected(player))
      return SendClientMessage(playerid, COLOR_RED, "Wrong id, or not connected");
   
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
      return SendClientMessage(playerid, COLOR_RED, "Usage: /givecash [playerid] [amount]");
   
    new amount = strval(tmp);
   
    GivePlayerMoney(playerid, amount);
   
    return 1;
  }
}
But i hope you learn pawn, and not requesting every time when you dont know something.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)