Give Offline Gold Crash the server
#1

Hello,

I created an /giveogold but it will crash the server after using it,

pawn Код:
CMD:giveogold(playerid, params[])
{
    new playerb, amount, string[128], file[32];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 8) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s[32]s[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /giveogold [playername] [amount]");
    format(file, sizeof(file), "users/%s.ini", playerb);
    if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
    format(string, sizeof(string), "AdmWarn: %s has given %s %d gold points(offline).", RPN(playerid), playerb, amount);
    SendAdminMessage(COLOR_LIGHTBLUE, 1, string);
    Log("logs/givemoney.log", string);
    dini_IntSet(file, "Gold", amount);
    foreach(Player, i)
    {
        if(IsPlayerLoggedIn(i) && PlayerInfo[i][pGold] == amount)
        {
            PlayerInfo[i][pGold] = amount;
            format(string, sizeof(string), " Administrator %s Has added Gold Points when you was offline (%d).", RPN(playerid), amount);
            SendClientMessage(i, COLOR_PINK, string);
        }
    }
return 1;
}
Reply
#2

Try to replace this:
pawn Код:
if(sscanf(params, "s[32]s[128]", playerb, params))
With this:
pawn Код:
if(sscanf(params, "us[128]", playerb, params))
Reply
#3

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Try to replace this:
pawn Код:
if(sscanf(params, "s[32]s[128]", playerb, params))
With this:
pawn Код:
if(sscanf(params, "us[128]", playerb, params))
It keeps saying that the playername is not found, and when i remove that line, its still not working, its not giving the gold points when someone is offline
Reply
#4

pawn Код:
if(sscanf(params, "ud", playerb, amount))
Reply
#5

Quote:
Originally Posted by JonathanFeitosa
Посмотреть сообщение
pawn Код:
if(sscanf(params, "ud", playerb, amount))
Still the same, Playername not found.
Reply
#6

What does the string (file) contain when you print it out?

The line may cause some issues with the name of the file. The string 'file' only has a size of 32 but the name of the player combined with "users/[name].ini" might make the file name unfinished like "users/eires_jas" instead of "users/eires_jason.ini". Just a thought.
pawn Код:
format(file, sizeof(file), "users/%s.ini", playerb);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)