SA-MP Forums Archive
Givecash command errors - 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 command errors (/showthread.php?tid=112231)



Givecash command errors - basker - 06.12.2009

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.


Re: Givecash command errors - Jeffry - 06.12.2009

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


Hope i helped



Re: Givecash command errors - DJDhan - 06.12.2009

I am seeing the new else combination first time O.O


Re: Givecash command errors - DeathOnaStick - 06.12.2009

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


Re: Givecash command errors - LarzI - 06.12.2009

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


Re: Givecash command errors - DeathOnaStick - 06.12.2009

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


Re: Givecash command errors - LarzI - 06.12.2009

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


Re: Givecash command errors - godknightx - 06.12.2009

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.