/pay methods
#1

Good day,

I'm trying to find out to be able to /pay with a wallet envelope or cash.
But now I'm stuck,

pawn Код:
dcmd_pay(playerid, params[]) {
    new playermoney = Money[playerid];
    new payment[128];
    if (PlayerInfo[playerid][pExp] == 0 && PlayerInfo[playerid][pLevel] == 0) return SendClientMessage(playerid, ORANZNA,".: You have to wait 1 more hour (payday) in order to be able to /pay :.");
  new amount,id = GetPlayerIDFromName(params);
  if(sscanf(params,"sud",payment,id,amount)) return SendClientMessage(playerid, COLOR_GREY, ".: Usage: /pay [wallet/envelope/cash] [playerid/PartOfName] [amount] :.");
  if(amount <= 0) return SendClientMessage(playerid, COLOR_ERROR, ".: Error: Invalid amount, you cannot pay less then 0 money. :.");
  if(playermoney < amount) return SendClientMessage(playerid, COLOR_ERROR, ".: Error: You don't have enough money to pay. :.");
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ERROR, ".: Error: Player is not connected :.");
    if(playerid == id) return SendClientMessage(playerid, COLOR_ERROR, ".: Error: You can't pay yourself :.");
    if(ProxDetectorS(5.0, playerid, id)) {
    if(payment == wallet) {
    GivePlayerMoney(playerid, (0 - amount);
    Money[playerid] -= amount;
    GivePlayerMoney(id, amount);
    Money[id] += amount;
    format(string, sizeof(string), ".: Info: You gave %d dollars to %s[%i] :.", amount, GetName(id),id);
    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), ".: Info: %s[%i] gave you %d dollars :.",GetName(playerid), playerid,amount);
    SendClientMessage(giveplayerid, COLOR_YELLOW, string);
    format(string,sizeof(string),"%s takes his wallet from his pockets, flips it open, takes some cash from it and hands it to %s.",GetName(playerid),GetName(id));
    ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    new UserPath[MAX_STRING];
    format(UserPath,sizeof(UserPath),"Users/%s.ini",GetName(playerid));
    dini_IntSet(UserPath,"Money",Money[playerid]);
    format(UserPath,sizeof(UserPath),"Users/%s.ini",GetName(id));
    dini_IntSet(UserPath,"Money",Money[id]);
    format(string,sizeof(string),"%s gave %d to %s with /pay command",GetName(playerid),moneys,GetName(id));
    MoneyLog(string); }
    else if(payment == envelope) {
    GivePlayerMoney(playerid, (0 - amount);
    Money[playerid] -= amount;
    GivePlayerMoney(id, amount);
    Money[id] += amount;
    format(string, sizeof(string), ".: Info: You gave %d dollars to %s[%i] :.", amount, GetName(id),id);
    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), ".: Info: %s[%i] gave you %d dollars :.",GetName(playerid), playerid,amount);
    SendClientMessage(giveplayerid, COLOR_YELLOW, string);
    format(string,sizeof(string),"%s slides his jacket a bit open, takes an envelope out of an inside pocket and hands it to %s.",GetName(playerid),GetName(id));
    ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    new UserPath[MAX_STRING];
    format(UserPath,sizeof(UserPath),"Users/%s.ini",GetName(playerid));
    dini_IntSet(UserPath,"Money",Money[playerid]);
    format(UserPath,sizeof(UserPath),"Users/%s.ini",GetName(id));
    dini_IntSet(UserPath,"Money",Money[id]);
    format(string,sizeof(string),"%s gave %d to %s with /pay command",GetName(playerid),moneys,GetName(id));
    MoneyLog(string); }
    else if(payment == cash) {
    GivePlayerMoney(playerid, (0 - amount);
    Money[playerid] -= amount;
    GivePlayerMoney(id, amount);
    Money[id] += amount;
    format(string, sizeof(string), ".: Info: You gave %d dollars to %s[%i] :.", amount, GetName(id),id);
    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), ".: Info: %s[%i] gave you %d dollars :.",GetName(playerid), playerid,amount);
    SendClientMessage(giveplayerid, COLOR_YELLOW, string);
    format(string,sizeof(string),"%s takes a roll of cash out from his pockets of his jeans and hands it to %s.",GetName(playerid),GetName(id));
    ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    new UserPath[MAX_STRING];
    format(UserPath,sizeof(UserPath),"Users/%s.ini",GetName(playerid));
    dini_IntSet(UserPath,"Money",Money[playerid]);
    format(UserPath,sizeof(UserPath),"Users/%s.ini",GetName(id));
    dini_IntSet(UserPath,"Money",Money[id]);
    format(string,sizeof(string),"%s gave %d to %s with /pay command",GetName(playerid),moneys,GetName(id));
    MoneyLog(string); }
    else return SendClientMessage(playerid, COLOR_ERROR, ".: Error: You have provided an invalid pay method. :."); }
    else return SendClientMessage(playerid, COLOR_ERROR, ".: Error: Your too far away from that player :."); }
Код:
C:\Users\Sander_2\Documents\server\gamemodes\burnbabyburn.pwn(28994) : error 017: undefined symbol "wallet"
C:\Users\Sander_2\Documents\server\gamemodes\burnbabyburn.pwn(29013) : error 017: undefined symbol "envelope"
C:\Users\Sander_2\Documents\server\gamemodes\burnbabyburn.pwn(29032) : error 017: undefined symbol "cash"
pawn Код:
if(payment == wallet)
pawn Код:
if(payment == envelope)
pawn Код:
if(payment == cash)
Reply
#2

You can't compare strings like that.
Use strcmp
Reply
#3

Quote:
Originally Posted by //exora
You can't compare strings like that.
Use strcmp
Can't it be done with DCMD, I'm not very familair with strcmp.
Reply
#4

pawn Код:
if(!strcmp(payment, "wallet", true)
if(!strcmp(payment, "envelope", true)
if(!strcmp(payment, "cash", true)
That's how it should be done .

~[HiC]TheKiller
Reply
#5

Quote:
Originally Posted by KnooL
Quote:
Originally Posted by //exora
You can't compare strings like that.
Use strcmp
Can't it be done with DCMD, I'm not very familair with strcmp.
It can be done with dcmd. just add strcmp below your DCMD command
Reply
#6

Quote:
Originally Posted by [HiC
TheKiller ]
pawn Код:
if(!strcmp(payment, "wallet", true)
if(!strcmp(payment, "envelope", true)
if(!strcmp(payment, "cash", true)
That's how it should be done .

~[HiC]TheKiller
Awesome!

Thank you for the reply
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)