Random Money Robbery System Help
#1

I'm trying to make a command (/takecaps) where it will send a dialog to the other party, asking if they wish to accept the robbery. When they do, it should take a random amount of money, based on how much money they have (scaps requires at least 1, mcaps requires at least 50, and lcaps requires at least 100). However, when testing with my friend, it seemed to work when my tester did it to me, but when I try to do it to him, it messes up. I'll post the code, hopefully one of you knows what's wrong and can help me out

pawn Код:
//The command itself

CMD:takecaps(playerid, params[])
{
    if(GetPVarInt(playerid, "LoggedIn") == 0) return SendClientMessage(playerid, COLOR_GREY, "ERROR: You are not logged in.");
    new string[128], id, Float:x, Float:y, Float:z;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Command Usage: /takecaps [playerid]");
    GetPlayerPos(playerid, x, y, z);
    if(id != INVALID_PLAYER_ID)
    {
        if(IsPlayerInRangeOfPoint(id, 5, x, y, z))
        {
            format(string, sizeof(string), "%s[%i] is requesting to steal some of your caps.  The amount is random, dependant on the amount of caps you are holding.\nThe player can only do this once, they can't do this multiple times.  If the opposite party did not roleplay the robbery, feel free to deny the request.", GetName(playerid), playerid);
            ShowPlayerDialog(id, 11, DIALOG_STYLE_MSGBOX, "Robbery Of Caps Request", string, "Accept", "Deny");
            format(string, sizeof(string), "You have sent the request to %s[%i].", GetName(id), id);
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
        else return SendClientMessage(playerid, COLOR_GREY, "You aren't near the player.");
    }
    else return SendClientMessage(playerid, COLOR_GREY, "That is not a valid playerid.");
    return 1;
}

// What the dialog does

case 11:
        {
            new string[128], bstring[128], bstring1[128], id, Scaps = randomEx(1, 49), Mcaps = 50 + random(49), Lcaps = 100 + random(200);
            if(!response)
            {
                format(string, sizeof(string), "%s has denied your robbery request.", GetName(playerid));
                SendClientMessage(id, COLOR_WHITE, string);
                format(string, sizeof(string), "You have denied %s's robbery request.", GetName(id));
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
            if(response)
            {
                if(GetPlayerMoney(
                if(GetPlayerMoney(playerid) >= 1)
                {
                    if(GetPlayerMoney(playerid) < Scaps)
                    {
                        Player[id][Money] += GivePlayerMoney(playerid, Player[playerid][Money]);
                        Player[playerid][Money] = 0;
                    }
                    else
                    {
                        Player[playerid][Money] -= Scaps;
                        Player[id][Money] += Scaps;
                    }
                    format(string, sizeof(string), "%s has just stole %i caps from you.", GetName(id), Scaps);
                    format(bstring, sizeof(bstring), "%s was robbed of %i caps from %s.", GetName(playerid), Scaps, GetName(id));
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    SetPlayerChatBubble(playerid, bstring, COLOR_LIGHTPURPLE, 10, 7000);
                    format(string, sizeof(string), "You have stole %i caps from %s.", Scaps, GetName(playerid));
                    format(bstring, sizeof(bstring), "%s has stole %i caps from %s.", GetName(id), Scaps, GetName(playerid));
                    format(bstring1, sizeof(bstring1), "> %s has stole %i caps from %s.", GetName(id), Scaps, GetName(playerid));
                    SendClientMessage(id, COLOR_WHITE, string);
                    SetPlayerChatBubble(id, bstring, COLOR_LIGHTPURPLE, 10, 7000);
                    SendClientMessage(id, COLOR_LIGHTPURPLE, bstring1);
                }
                if(GetPlayerMoney(playerid) >= 50)
                {
                    if(GetPlayerMoney(playerid) < Mcaps)
                    {
                        Player[id][Money] += GivePlayerMoney(playerid, Player[playerid][Money]);
                        Player[playerid][Money] = 0;
                    }
                    else
                    {
                        Player[playerid][Money] -= Mcaps;
                        Player[id][Money] += Mcaps;
                    }
                    format(string, sizeof(string), "%s has just stole %i caps from you.", GetName(id), Mcaps);
                    format(bstring, sizeof(bstring), "%s was robbed of %i caps from %s.", GetName(playerid), Mcaps, GetName(id));
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    SetPlayerChatBubble(playerid, bstring, COLOR_LIGHTPURPLE, 10, 7000);
                    format(string, sizeof(string), "You have stole %i caps from %s.", Mcaps, GetName(playerid));
                    format(bstring, sizeof(bstring), "%s has stole %i caps from %s.", GetName(id), Mcaps, GetName(playerid));
                    format(bstring1, sizeof(bstring1), "> %s has stole %i caps from %s.", GetName(id), Mcaps, GetName(playerid));
                    SendClientMessage(id, COLOR_WHITE, string);
                    SetPlayerChatBubble(id, bstring, COLOR_LIGHTPURPLE, 10, 7000);
                    SendClientMessage(id, COLOR_LIGHTPURPLE, bstring1);
                }
                if(GetPlayerMoney(playerid) >= 100)
                {
                    if(GetPlayerMoney(playerid) < Lcaps)
                    {
                        Player[id][Money] += GivePlayerMoney(playerid, Player[playerid][Money]);
                        Player[playerid][Money] = 0;
                    }
                    else
                    {
                        Player[playerid][Money] -= Lcaps;
                        Player[id][Money] += Lcaps;
                    }
                    format(string, sizeof(string), "%s has just stole %i caps from you.", GetName(id), Lcaps);
                    format(bstring, sizeof(bstring), "%s was robbed of %i caps from %s.", GetName(playerid), Lcaps, GetName(id));
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    SetPlayerChatBubble(playerid, bstring, COLOR_LIGHTPURPLE, 10, 7000);
                    format(string, sizeof(string), "You have stole %i caps from %s.", Lcaps, GetName(playerid));
                    format(bstring, sizeof(bstring), "%s has stole %i caps from %s.", GetName(id), Lcaps, GetName(playerid));
                    format(bstring1, sizeof(bstring1), "> %s has stole %i caps from %s.", GetName(id), Lcaps, GetName(playerid));
                    SendClientMessage(id, COLOR_WHITE, string);
                    SetPlayerChatBubble(id, bstring, COLOR_LIGHTPURPLE, 10, 7000);
                    SendClientMessage(id, COLOR_LIGHTPURPLE, bstring1);
                }
            }
        }
Sorry if formatting is off, it's formatted right within the script.
Reply
#2

Anyone?
Reply
#3

"id" will be (by default) 0 in the dialog part. You need to store the player's ID to a variable in the command and then get that value in the dialog part and assign it to "id".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)