/pay Command
#1

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

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

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.

Reply
#4

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

(new otherid,cash
Reply
#5

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

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

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>
Reply
#8

....
Reply
#9

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.

Reply
#10

....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)