/pay help!!!
#1

Can someone please give me a code script for /pay!!!!!!
Reply
#2

what this script have 2 do?
Reply
#3

Quote:
Originally Posted by [ISS]jumbo
Посмотреть сообщение
what this script have 2 do?
i want one player give money to the other, when someone type /pay [playerid] [amount] the money will go to the receiver.!! Any code script?
Reply
#4

pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

dcmd_pay(playerid, params[])
{
    new idx;
    tmp = strtok(params, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
    }else{
        new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[150], pid;
        pid = strval(tmp);
        if(!IsPlayerConnected(pid)){
            SendClientMessage(playerid, 0x801818AA, "Invalid player");
            return 1;
        }
        tmp = strrest(params, idx);
        if(!strlen(tmp)){
            SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
        }
        new amount = strval(tmp);
        if(GetPlayerMoney(playerid) < amount){
            SendClientMessage(playerid, 0x801818AA, "You don't have enough money");
        }else{
            GetPlayerName(playerid, pname1, sizeof(pname1));
            GetPlayerName(pid, pname2, sizeof(pname2));
            format(string, sizeof(string), "*%s gave %s %d$", pname1, pname2, amount);
            SendClientMessageToAll(0x801818AA, string);
            GivePlayerMoney(pid, amount);
            GivePlayerMoney(playerid, -amount);
        }
    }
    return 1;
}
stock strrest(const string[], index)
{
    new length = strlen(string),offset = index,result[256];
    while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
haven't tested it thought
Reply
#5

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

dcmd_pay(playerid, params[])
{
    new idx;
    tmp = strtok(params, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
    }else{
        new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[150], pid;
        pid = strval(tmp);
        if(!IsPlayerConnected(pid)){
            SendClientMessage(playerid, 0x801818AA, "Invalid player");
            return 1;
        }
        tmp = strrest(params, idx);
        if(!strlen(tmp)){
            SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
        }
        new amount = strval(tmp);
        if(GetPlayerMoney(playerid) < amount){
            SendClientMessage(playerid, 0x801818AA, "You don't have enough money");
        }else{
            GetPlayerName(playerid, pname1, sizeof(pname1));
            GetPlayerName(pid, pname2, sizeof(pname2));
            format(string, sizeof(string), "*%s gave %s %d$", pname1, pname2, amount);
            SendClientMessageToAll(0x801818AA, string);
            GivePlayerMoney(pid, amount);
            GivePlayerMoney(playerid, -amount);
        }
    }
    return 1;
}
stock strrest(const string[], index)
{
    new length = strlen(string),offset = index,result[256];
    while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
haven't tested it thought
i got this erros: what i did wrong?

: warning 219: local variable "string" shadows a variable at a preceding level
: warning 203: symbol is never used: "dcmd_pay"

?
Reply
#6

use the command in lvdm gm ...
Reply
#7

Quote:
Originally Posted by [ISS]jumbo
Посмотреть сообщение
use the command in lvdm gm ...
I didn't understand what you mean!
Reply
#8

go to gm directory find lvdm.pwn open search for this command is into..
Reply
#9

Also you forgot to add this line:
pawn Код:
dcmd(pay,3,cmdtext);
on the:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    // ADD the line here
}
Reply
#10

i get so many errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)