SA-MP Forums Archive
/pay Command - 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: /pay Command (/showthread.php?tid=95673)



/pay Command - indy-greg - 04.09.2009

I've been trying for about a week to get a working /pay command in dcmd (i use dcmd primarily) and strtok but nothing has worked fully or working at all.

I've used search a million times so please dont tell me to do that.

So if someone could help me out here with a /pay command (hopefully in dcmd) i will be eternally grateful.

Thanks.


Re: /pay Command - dougbrowne - 04.09.2009

pawn Код:
dcmd_pay(playerid, params[])
{
  new otherid, cash;
  if (sscanf(params, "dd", otherid, cash)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /pay [ID] [Cash]");
  else
  {
    if(GetPlayerMoney(playerid) > cash) SendClientMessage(playerid, COLOR_RED, "You don't have that much!");
    else if(!IsPlayerConnected(otherid)) SendClientMessage(playerid, COLOR_RED, "That PlayerID is not connected!");
    else if(otherid == playerid) SendClientMessage(playerid, COLOR_RED, "It is pointless to pay yourself..");
    else
    {
      GivePlayerMoney(playerid, -cash);
      GivePlayerMoney(otherid, cash);
    }
  }
  return 1;
}
Happy? Wrote it specially for you lol.


Re: /pay Command - indy-greg - 04.09.2009

I get a warning...
Quote:

C:\Users\Greg\Desktop\pawno\gregs.pwn(437) : warning 203: symbol is never used: "pMoney"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.




Re: /pay Command - coole210 - 04.09.2009

Hahaha > new otherid, cash, pMoney; < Get rid of , pMoney

(new otherid,cash


Re: /pay Command - dougbrowne - 04.09.2009

Haha my bad :P Put that there by mistake. Even so should still work fine with or without it.


Re: /pay Command - indy-greg - 04.09.2009

That got rid of the warning but the command doesnt work in the server

It just says 'you dont have that much' when i try to pay someone.


Re: /pay Command - indy-greg - 04.09.2009

Ok its works now. But i have to ask another favour.

How do i make it so it says 'You just got paid $<howevermuch> by <player>'

And 'You paid $<howevermuch> to <player>


Re: /pay Command - coole210 - 04.09.2009

....


Re: /pay Command - indy-greg - 04.09.2009

ok so now i have this;
pawn Код:
dcmd_pay(playerid, params[])
{
  new otherid,cash,string[128],namez[MAX_PLAYER_NAME];
  if (sscanf(params, "dd", otherid, cash)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /pay [ID] [Cash]");
  else
  {
    if(GetPlayerMoney(playerid) < cash) SendClientMessage(playerid, COLOR_RED, "You don't have that much!");
    else if(!IsPlayerConnected(otherid)) SendClientMessage(playerid, COLOR_RED, "That PlayerID is not connected!");
    else if(otherid == playerid) SendClientMessage(playerid, COLOR_RED, "It is pointless to pay yourself..");
    else
    {
      GivePlayerMoney(playerid, -cash);
            GetPlayerName(playerid,namez,sizeof(namez));
            format(string,sizeof(string),"You have gained $%d from %s",cash,namez);
            SendClientMessage(otherid,color,string);
    }
    {
      GivePlayerMoney(otherid, cash);
      GetPlayerName(playerid,namez,sizeof(namez));
            format(string,sizeof(string),"You have gained $%d from %s",cash,namez);
            SendClientMessage(otherid,color,string);
    }
  }
  return 1;
}
and i get these errors/warnings now..
Quote:

C:\Users\Greg\Desktop\pawno\gregs.pwn(437) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Greg\Desktop\pawno\gregs.pwn(449) : error 017: undefined symbol "color"
C:\Users\Greg\Desktop\pawno\gregs.pwn(455) : error 017: undefined symbol "color"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.




Re: /pay Command - coole210 - 04.09.2009

....