Setting peoples money please help
#1

I am trying to make it so you can set other peoples money


It compiles fine but when in game when i do /setmoney (myid) (theamount) it just says


Admin blah has set (persons name ) 0


But when i do /setmoney (myname) (amount)


It says Admin blag has set (persons name ) 65355


pawn Код:
CMD:setmoney(playerid, params[])
{
    if(PlayerData[ID][AdminLevel] >= 3)
    {
        new money;
        if(sscanf(params, "u",ID, money)) return SendClientMessage(playerid, COLOR_GREEN, "/setmoney [ID] [Amount]");
        format(str2, sizeof(str2),"Admin %s has given %s %d",PlayerData[playerid][AdminName],pname,money);
        GivePlayerMoney(playerid, money);
        SendClientMessageToAll(COLOR_GREEN, str2);
    }
    return 1;
}

Thank You



Please Help Me Please
Reply
#2

pawn Код:
CMD:setmoney(playerid, params[])
{
    if(PlayerData[ID][AdminLevel] >= 3)
    {
        new money, toplayerid;

        if(sscanf(params, "u",toplayerid, money)) return SendClientMessage(playerid, COLOR_GREEN, "/setmoney [ID] [Amount]");
        format(str2, sizeof(str2),"Admin %s has given %s %d",PlayerData[playerid][AdminName],pname,money);
        GivePlayerMoney(toplayerid, money);
        SendClientMessageToAll(COLOR_GREEN, str2);
    }
    return 1;
}
If the above code dosn't work try this one

pawn Код:
CMD:setmoney(playerid, params[])
{
    if(PlayerData[ID][AdminLevel] >= 3)
    {
        new money, toplayerid;

        if(sscanf(params, "ii",toplayerid, money)) return SendClientMessage(playerid, COLOR_GREEN, "/setmoney [ID] [Amount]");
        format(str2, sizeof(str2),"Admin %s has given %s %d",PlayerData[playerid][AdminName],pname,money);
        GivePlayerMoney(toplayerid, money);
        SendClientMessageToAll(COLOR_GREEN, str2);
    }
    return 1;
}
The reason it said the playersname then money = 0 is because you were giving the player witch is doing the command the money.
Reply
#3

Both commands are wrong, because you wanna SET the player's money, and not give him (add) money:

pawn Код:
COMMAND:setmoney(playerid,params[])
{
    if(PlayerData[ID][AdminLevel] >= 3)
    {

            new Target;
            new Amount;
            if(sscanf(params, "ui", Target, Amount)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /setmoney [playerid] [amount]");
            if(!IsPlayerConnected(Target))
                return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
            if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED," ERROR: You can't perform this on admins that are higher than your level!");
                            ResetPlayerMoney(Target);
            GivePlayerMoney(Target,Amount);
            new tname[MAX_PLAYER_NAME];
            GetPlayerName(Target,tname,sizeof(tname));
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pname,sizeof(pname));
            new tstring[256];
            new pstring[256];
            format(tstring,sizeof(tstring),"Your money has been set to $%d by %s",Amount,pname);
            format(pstring,sizeof(pstring),"You have set %sґs(%d) money to $%d",tname,Target,Amount);
            SendClientMessage(Target,COLOR_BLUE,tstring);
            SendClientMessage(playerid,COLOR_BLUE,pstring);

    }
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be  level 4 to use this command!");
    return 1;
}
You first gotta reset his money!
Reply
#4

Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
Both commands are wrong, because you wanna SET the player's money, and not give him (add) money:

pawn Код:
COMMAND:setmoney(playerid,params[])
{
    if(PlayerData[ID][AdminLevel] >= 3)
    {

            new Target;
            new Amount;
            if(sscanf(params, "ui", Target, Amount)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /setmoney [playerid] [amount]");
            if(!IsPlayerConnected(Target))
                return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
            if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED," ERROR: You can't perform this on admins that are higher than your level!");
                            ResetPlayerMoney(Target);
            GivePlayerMoney(Target,Amount);
            new tname[MAX_PLAYER_NAME];
            GetPlayerName(Target,tname,sizeof(tname));
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pname,sizeof(pname));
            new tstring[256];
            new pstring[256];
            format(tstring,sizeof(tstring),"Your money has been set to $%d by %s",Amount,pname);
            format(pstring,sizeof(pstring),"You have set %sґs(%d) money to $%d",tname,Target,Amount);
            SendClientMessage(Target,COLOR_BLUE,tstring);
            SendClientMessage(playerid,COLOR_BLUE,pstring);

    }
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be  level 4 to use this command!");
    return 1;
}
You first gotta reset his money!
ye what he said lol thought you wanted to give him money soz.
Reply
#5

Quote:
Originally Posted by jueix
Посмотреть сообщение
ye what he said lol thought you wanted to give him money soz.
Oops sorry


I meam give the player money
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)