More DCMD problems
#1

pawn Код:
dcmd_setmoney(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, amount;
if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /setmoney [playerid/name] [amount]");
if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
PlayerInfo[target][pMoney] = amount;
ResetPlayerMoney(target);
new newmoney = PlayerInfo[target][pMoney];
GivePlayerMoney(target, newmoney);
new string[128];
format(string, sizeof(string), "Admin %s has set your money to %d !", PlayerName(playerid), newmoney);
SendClientMessage(target, COLOR_LIGHTGREEN, string);
foreach(Player, i)
{
    if (PlayerInfo[playerid][pAdmin] >= 1)
    {
        format(string, sizeof(string), "Admin %s has set %s's money to %d !", PlayerName(playerid), PlayerName(target), amount);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        return 1;
    }
}
return 1;
}

dcmd_givemoney(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, money;
if(sscanf(params, "ud", target, money)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givemoney [playerid/name] [amount]");
if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
if(money < 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't givemoney below 0!");
GivePlayerMoney(target, money);
PlayerInfo[target][pMoney] += money;
new string[128];
format(string, sizeof(string), "Admin %s has given you %d !", PlayerName(playerid), money);
SendClientMessage(target, COLOR_LIGHTGREEN, string);
foreach(Player ,i)
{
    if(PlayerInfo[i][pAdmin] >=1)
    {
        format(string, sizeof(string), "Admin %s has given %s %d !", PlayerName(playerid), PlayerName(target), money);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        return 1;
    }
}
return 1;
}

EDIT: fixed myself
used
Код:
if(!IsPlayerConnected(target))
instead of
Код:
if(target == INVALID_PLAYER_ID)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)