Server crash after using command
#1

I've created an /givegold but the server will crash after using this command, whats the problem?

pawn Код:
CMD:givegold(playerid, params[])
{
    static
        userid,
        amount;

    if (PlayerData[playerid][pAdmin] > 6)
        return SendErrorMessage(playerid, "You don't have permission to use this command.");
       
    if(sscanf(params, "ud", userid, amount))
        return SendSyntaxMessage(playerid, "/givegold [playerid/name] [amount]");
       
    if (userid == INVALID_PLAYER_ID)
        return SendErrorMessage(playerid, "You have specified an invalid player.");
       
    PlayerData[playerid][pGold] = amount;
    SendClientMessageEx(playerid, COLOR_PINK, "Admin %s has transeferd %d gold points to your account", amount);
   
    SendAdminAlert(COLOR_LIGHTRED, "[ADMIN]: %s has given %s to %s.", ReturnName(playerid, 0), FormatNumber(amount), ReturnName(userid, 0));
    Log_Write("logs/admin_log.txt", "[%s] %s has given %s to %s.", ReturnDate(), ReturnName(playerid, 0), FormatNumber(amount), ReturnName(userid, 0));

    return 1;
}


FIXED, HUMAN MISTAKES
Reply
#2

One of Log_Write, SendAdminAlert or SendClientMessageEx is not written correctly.

Plus:
pawn Код:
SendClientMessageEx(playerid, COLOR_PINK, "Admin %s has transeferd %d gold points to your account", amount);
You're requesting 2 parameters, %s and %d and you're only giving one, amount.
Reply
#3

Try removing that Log_Write line from your code.
Reply
#4

pawn Код:
CMD:givegold(playerid, params[])
{
    if(PlayerData[playerid][pAdmin] > 6) return SendErrorMessage(playerid, "You don't have permission to use this command.");
    new userid, amount;
    if(sscanf(params, "ud", userid, amount)) return SendSyntaxMessage(playerid, "/givegold [playerid/name] [amount]");
    if(!IsPlayerConnected(userid) || userid == INVALID_PLAYER_ID) return SendErrorMessage(playerid, "You have specified an invalid player.");
    PlayerData[playerid][pGold] = amount;
    SendClientMessageEx(playerid, COLOR_PINK, "Admin %s has transferred %d gold points to your account", ReturnName(playerid, 0), amount);
    SendAdminAlert(COLOR_LIGHTRED, "[ADMIN]: %s has given %s to %s.", ReturnName(playerid, 0), FormatNumber(amount), ReturnName(userid, 0));
    Log_Write("logs/admin_log.txt", "[%s] %s has given %s to %s.", ReturnDate(), ReturnName(playerid, 0), FormatNumber(amount), ReturnName(userid, 0));
    return 1;
}
That's correct HazardouS, but that's not likely to crash the server. It will produce a weird string at most.

--

@OP, make sure you have created the folder logs in scriptfiles. If you try to write to a file in a folder that does not exist, this will usually crash the server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)