Money bug ( GTA )
#1

Hi guys

i make this CMD

pawn Код:
CMD:givemoney(playerid, params[])
{
    new playerb, amount, string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givemoney [playerid] [amount]");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    PlayerInfo[playerb][pMoney] = PlayerInfo[playerb][pMoney]+amount;
    GiveZaiatMoney(playerb, amount);
    format(string, sizeof(string), " Administrator %s has given you $%d", RPN(playerid), amount);
    SendClientMessage(playerb, COLOR_WHITE, string);
    format(string, sizeof(string), "AdmWarn: %s has given %s $%d.", RPN(playerid), RPN(playerb), amount);
    SendAdminMessage(COLOR_DARKRED, 1, string);
    Log("logs/givemoney.log", string);
    OnPlayerSave(playerb);
    return 1;
}

CMD:setmoney(playerid, params[])
{
    new playerb, amount, string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setmoney [playerid] [amount]");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    PlayerInfo[playerb][pMoney] = amount;
    SetZaiatMoney(playerb, amount);
    format(string, sizeof(string), " Administrator %s has set your money to $%d", RPN(playerid), amount);
    SendClientMessage(playerb, COLOR_WHITE, string);
    format(string, sizeof(string), "AdmWarn: %s has set %s's money to $%d.", RPN(playerid), RPN(playerb), amount);
    SendAdminMessage(COLOR_DARKRED, 1, string);
    Log("logs/setmoney.log", string);
    OnPlayerSave(playerb);
    return 1;
}




Reply
#2

Can you explain what is wrong with it? Also make sure that GiveZaiatMoney adds the money to the variable, I assume it's server-side money.
Reply
#3

Fix !

Old
pawn Код:
stock GiveZaiatMoney(playerid, amount)
{
    new string[128];
    if(amount < 0) format(string, sizeof(string), "~r~-$%d", amount*-1);
    else if(amount > 0) format(string, sizeof(string), "~g~+$%d", amount);
    GameTextForPlayer(playerid, string, 3000, 1);
    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
    return 1;
}
New
pawn Код:
stock GiveZaiatMoney(playerid, amount)
{
    new string[128];
    if(amount < 0) format(string, sizeof(string), "~r~-$%d", amount*-1);
    else if(amount > 0) format(string, sizeof(string), "~g~+$%d", amount);
    GameTextForPlayer(playerid, string, 3000, 1);
    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
    PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney]+amount;
    GivePlayerMoney(playerid,amount);
    return 1;
}
Reply
#4

Nice! Make sure that SetZaiatMoney function sets the value to the PlayerInfo[playerid][pMoney] too.

Off-topic: you can also use
pawn Код:
PlayerInfo[playerid][pMoney] += amount;
// instead of
PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney]+amount;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)