Help in /pay for RP server/gamemode
#1

how to create a command for /pay? pay like give some money to another player... you know what i mean..

can someone give me a sample script for it or any FS for that command?
Reply
#2

Here
pawn Код:
CMD:pay(playerid, params[])
{
    if(AdminDuty[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You can't use this command while on-duty as admin.");
        return 1;
    }

    new
        iTargetID, iCashAmount;

    if(sscanf(params, "ui", iTargetID, iCashAmount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/partofname] [amount]");

    if(iTargetID == playerid)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "You can't use this command on yourself!");
        return 1;
    }
    if(iCashAmount > 100 && PlayerInfo[playerid][pLevel] < 2)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "You must be level 2 to pay over $100");
        return 1;
    }
    if(iCashAmount < 1 || iCashAmount > 10000)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "Don't go below $1, or above $10,000 at once.");
        return 1;
    }
    if(IsPlayerConnected(iTargetID))
    {
        if(ProxDetectorS(5.0, playerid, iTargetID))
        {
            new
                szMessage[128], giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], playermoney = GetPlayerCash(playerid);

            giveplayer = GetPlayerNameEx(iTargetID);
            sendername = GetPlayerNameEx(playerid);
            if(iCashAmount > 0 && playermoney >= iCashAmount)
            {
                GivePlayerCash(playerid, (0 - iCashAmount));
                GivePlayerCash(iTargetID, iCashAmount);
                format(szMessage, sizeof(szMessage), "   You have sent %s(player: %d), $%d.", GetPlayerNameEx(iTargetID),iTargetID, iCashAmount);
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                SendClientMessage(playerid, COLOR_GRAD1, szMessage);
                format(szMessage, sizeof(szMessage), "   You have recieved $%d from %s(player: %d).", iCashAmount, GetPlayerNameEx(playerid), playerid);
                SendClientMessage(iTargetID, COLOR_GRAD1, szMessage);

                new ip[32], ipex[32];
                GetPlayerIp(playerid, ip, sizeof(ip));
                GetPlayerIp(iTargetID, ipex, sizeof(ipex));
                format(szMessage, sizeof(szMessage), "%s (IP:%s) has paid $%d to %s (IP:%s)", GetPlayerNameEx(playerid), ip, iCashAmount, GetPlayerNameEx(iTargetID), ipex);
                Log("logs/pay.log", szMessage);

                PayWarn[playerid][iTargetID] += iCashAmount;
                if(PayWarn[playerid][iTargetID] >= 10000 && PlayerInfo[playerid][pLevel] <= 3)
                {
                    format(szMessage, sizeof(szMessage), "%s (IP:%s) has paid %s (IP:%s) $%d in this session.", GetPlayerNameEx(playerid), ip, GetPlayerNameEx(iTargetID), ipex, PayWarn[playerid][iTargetID]);
                    ABroadCast(COLOR_YELLOW, szMessage, 1);
                }

                if(iCashAmount >= 100000)
                {
                    ABroadCast(COLOR_YELLOW,szMessage,1);
                }

                PlayerPlaySound(iTargetID, 1052, 0.0, 0.0, 0.0);
                format(szMessage, sizeof(szMessage), "* %s takes out some cash, and hands it to %s.", GetPlayerNameEx(playerid) ,GetPlayerNameEx(iTargetID));
                ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "That player isn't near you.");
        }
    }
    else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
Edit this, this is from my script

+rep if i help
Reply
#3

Thanks for the help! +rep
Reply
#4

But is there a simpler code for it? i'm not pretty good at scripting and i'm still learning.
Something that only uses a_players.inc if its possible?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)