Set Cash help
#1

Hello,
my admin command to set cash:
Код:
dcmd_setcash(playerid, params[])
{
    new pID;
    if(PlayerInfo[playerid][pAdminLevel] >= 1) {
    if(sscanf(params, "us[128]", pID, params[2])) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setcash [playerid] [amount of money]");
    if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
    ResetPlayerMoney(pID);
    return SetPlayerMoney(pID,params[2]);
    } else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
When I want to set example player with 0 id,I type /setcash 0 1000 .It should give 1000 ,but it gives only 49.
It always gives max amount 49.Any help ?
Reply
#2

Try this:
pawn Код:
dcmd_setcash(playerid, params[])
{
    new pID, cash;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "ud", pID, cash)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setcash [playerid] [amount of money]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        ResetPlayerMoney(pID);
        return SetPlayerMoney(pID,cash);
    }
    else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Haven't tested it, but it should work.
Reply
#3

Use zcmd, much better.... And what admin system you use?
Reply
#4

Works,thx.

I don't want to use admin system from forums ,because there is too many admin commands.
Reply
#5

aqu I see you changed the ban command alot. The online mistake in this cmd is your sscanf line.

Here are some sscanf tutorials

https://sampforum.blast.hk/showthread.php?tid=232129
https://sampforum.blast.hk/showthread.php?tid=225746
https://sampforum.blast.hk/showthread.php?tid=206237

EDIT: xRyder, this
pawn Код:
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
is better than IsPlayerConnected
Reply
#6

Quote:
Originally Posted by xir
Посмотреть сообщение
xRyder, this
pawn Код:
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
is better than IsPlayerConnected
Nope, it's not. It could be bugged (at least more that IsPlayerConnected()).
Reply
#7

hmm really? I saw ****** use with his sscanf code?
Reply
#8

Yeah, I think it's better to use IsPlayerConnected(). But if ****** used that, hmm now I'm confused too...
But still from my experience I prefer IsPlayerConnected() since I never had any problems with that...
Reply
#9

try read from calgoones post and up

http://forum.sa-mp.com/showthread.ph...50#post1104150

and i dont get how it can get bugged? it should just match the id, how can it be bugged?
Reply
#10

Hmmm, but still if you use IsPlayerConnected() and if player isn't connected it will return INVALID_PLAYER_ID so it's basically the same... :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)