how to pay other players
#1

how would i make a script so players could pay each other ingame. ive looked around but i cant seem to get on to work. :l
Reply
#2

Check the lvdm gamemode included with the windows server pack. Theres a /givecash command that does that job.
Reply
#3

pawn Код:
if(strcmp(cmd, "/givecash", true) == 0) {
      new string[256];
      new playermoney;
      new sendername[MAX_PLAYER_NAME];
      new giveplayer[MAX_PLAYER_NAME];
      new giveplayerid, moneys, idxx;
      new tmp[256];
        tmp = strtok(cmdtext, idxx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = ReturnUser(tmp);

        tmp = strtok(cmdtext, idxx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);

        //printf("givecash_command: %d %d",giveplayerid,moneys);


        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(%d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(%d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
Reply
#4

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Check the lvdm gamemode included with the windows server pack. Theres a /givecash command that does that job.
that one didnt work out so well lol. really bad glitch xD
Reply
#5

Quote:
Originally Posted by WarriorEd22
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/givecash", true) == 0) {
      new string[256];
      new playermoney;
      new sendername[MAX_PLAYER_NAME];
      new giveplayer[MAX_PLAYER_NAME];
      new giveplayerid, moneys, idxx;
      new tmp[256];
        tmp = strtok(cmdtext, idxx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = ReturnUser(tmp);

        tmp = strtok(cmdtext, idxx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);

        //printf("givecash_command: %d %d",giveplayerid,moneys);


        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(%d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(%d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
C:\Documents and Settings\Administrator\Desktop\gta sa server\gamemodes\DDPDRIFT.pwn(5193) : error 017: undefined symbol "cmd"
C:\Documents and Settings\Administrator\Desktop\gta sa server\gamemodes\DDPDRIFT.pwn(5206) : error 017: undefined symbol "ReturnUser"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#6

pawn Код:
new string[256];
    new playermoney;
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new giveplayerid, moneys, idx;

if(strcmp(cmd, "/givecash", true) == 0) {
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = strval(tmp);
       
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);
       
        //printf("givecash_command: %d %d",giveplayerid,moneys);

       
        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
Reply
#7

Quote:
Originally Posted by sjvt
Посмотреть сообщение
pawn Код:
new string[256];
    new playermoney;
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new giveplayerid, moneys, idx;

if(strcmp(cmd, "/givecash", true) == 0) {
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = strval(tmp);
       
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);
       
        //printf("givecash_command: %d %d",giveplayerid,moneys);

       
        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
if i try any commands in my GM it says "usage: /givecash playerid amount" lol and when i try that it says "invalid transaction amount"
Reply
#8

You use old methods for commands like strcmp?If not,this is my ZCMD givemoney command i use in my cnr gamemode.

pawn Код:
CMD:gm(playerid, params[])
{
    new Destinationid,Ammount,PlayerName[24],DestName[24],String[128];
    if(GetPVarInt(playerid,"GmTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 5 seconds before giving money again.");
    SetPVarInt(playerid,"GmTime",GetTickCount()+5000);
    if (sscanf(params, "ui", Destinationid, Ammount)) return SendClientMessage(playerid, -1, "Usage: /givemoney <playerid> <ammount>");
    if (!IsPlayerConnected(Destinationid)) return SendClientMessage(playerid, -1, "Player is not connected.");
    if (GetPlayerMoney(playerid) < Ammount) return SendClientMessage(playerid, -1, "Insufficent funds.");
    if(playerid == Destinationid) return SendClientMessage(playerid,red, "You can't send money to yourself.");
    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerName(Destinationid, DestName, 24);
    format(String, 128, "%s (%d) has sent you %d$", PlayerName, playerid, Ammount);
    SendClientMessage(Destinationid, -1, String);
    new gmsent[128];
    format(gmsent,sizeof(gmsent),"Sent %d$ to %s (%d)", Ammount,DestName,Destinationid);
    GameTextForPlayer(playerid,gmsent,3000,5);
    format(String, 128, "You've sent %d$ to %s (%d)", Ammount, DestName, Destinationid);
    SendClientMessage(playerid, -1, String);
    new gmrec[128];
    format(gmrec,sizeof(gmrec),"Received %d$ from %s (%d)", Ammount,PlayerName,Destinationid);
    GameTextForPlayer(Destinationid,gmrec,3000,5);
    GivePlayerMoney(Destinationid, Ammount);
    GivePlayerMoney(playerid, -Ammount);
    return 1;
}
Don't hesitate to ask if you've a problem with this.
Reply
#9

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
You use old methods for commands like strcmp?If not,this is my ZCMD givemoney command i use in my cnr gamemode.

pawn Код:
CMD:gm(playerid, params[])
{
    new Destinationid,Ammount,PlayerName[24],DestName[24],String[128];
    if(GetPVarInt(playerid,"GmTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 5 seconds before giving money again.");
    SetPVarInt(playerid,"GmTime",GetTickCount()+5000);
    if (sscanf(params, "ui", Destinationid, Ammount)) return SendClientMessage(playerid, -1, "Usage: /givemoney <playerid> <ammount>");
    if (!IsPlayerConnected(Destinationid)) return SendClientMessage(playerid, -1, "Player is not connected.");
    if (GetPlayerMoney(playerid) < Ammount) return SendClientMessage(playerid, -1, "Insufficent funds.");
    if(playerid == Destinationid) return SendClientMessage(playerid,red, "You can't send money to yourself.");
    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerName(Destinationid, DestName, 24);
    format(String, 128, "%s (%d) has sent you %d$", PlayerName, playerid, Ammount);
    SendClientMessage(Destinationid, -1, String);
    new gmsent[128];
    format(gmsent,sizeof(gmsent),"Sent %d$ to %s (%d)", Ammount,DestName,Destinationid);
    GameTextForPlayer(playerid,gmsent,3000,5);
    format(String, 128, "You've sent %d$ to %s (%d)", Ammount, DestName, Destinationid);
    SendClientMessage(playerid, -1, String);
    new gmrec[128];
    format(gmrec,sizeof(gmrec),"Received %d$ from %s (%d)", Ammount,PlayerName,Destinationid);
    GameTextForPlayer(Destinationid,gmrec,3000,5);
    GivePlayerMoney(Destinationid, Ammount);
    GivePlayerMoney(playerid, -Ammount);
    return 1;
}
Don't hesitate to ask if you've a problem with this.
Yeah im just using STRCMP, i dont really know ZCMD or DCMD. as my sig defines below im still learning xD
Reply
#10

yeah still cant seem to get it to work correctly
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)