Server crash after using command -
lulo356 - 07.02.2015
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
Re: Server crash after using command -
HazardouS - 07.02.2015
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.
Re: Server crash after using command -
Tamy - 07.02.2015
Try removing that Log_Write line from your code.
Re: Server crash after using command -
Threshold - 07.02.2015
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.