Server Crashes on this CMD?
#1

Like the title says, no server log entries.
pawn Код:
CMD:accepthelp(playerid, params[])
{
    new playerb, string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pHelper] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /accepthelp [playerid]");
    if(HelpPending[playerb] == 0) return SendClientMessage(playerid, COLOR_GREY, "This player doesn't have a pending help request.");
    if(Helping[playerid] != -1) return SendClientMessage(playerid, COLOR_GREY, "You are already helping someone.");
    Helping[playerid] = playerb;
    Helping[playerb] = playerid;
    format(string, sizeof(string), "* %s %s has accepted your help request, please wait.", RPHLN(playerid), RPN(playerid));
    SendClientMessage(playerb, COLOR_GREEN, string);
    format(string, sizeof(string), "* You have accepted %s help request, use /helpermenu to start helping him.", RPN(playerb));
    SendClientMessage(playerid, COLOR_GREEN, string);
    HelpPending[playerb] = 0;
    return 1;
}
Reply
#2

Trying checking if playerb exists? You don't seem to do it, so if the player is invalid you will have array index out of bound error
Reply
#3

I indeed didn't check for that but as far as i know if that is so sscanf will return INVALID_PLAYER_ID. Before that occurs.
Reply
#4

I don't think so, as it happened to me before. You got nothing to lose anyway and check if playerid == playerb
Reply
#5

Why would it be a problem if playerid == playerb?
Reply
#6

pawn Код:
CMD:accepthelp(playerid, params[])
{
    new targetid, string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pHelper] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /accepthelp [playerid]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid id");
    if(HelpPending[targetid] == 0) return SendClientMessage(playerid, COLOR_GREY, "This player doesn't have a pending help request.");
    if(Helping[playerid] != -1) return SendClientMessage(playerid, COLOR_GREY, "You are already helping someone.");
    Helping[playerid] = targetid;
    Helping[targetid] = playerid;
    format(string, sizeof(string), "* %s %s has accepted your help request, please wait.", RPHLN(playerid), RPN(playerid));
    SendClientMessage(targetid, COLOR_GREEN, string);
    format(string, sizeof(string), "* You have accepted %s help request, use /helpermenu to start helping him.", RPN(targetid));
    SendClientMessage(playerid, COLOR_GREEN, string);
    HelpPending[targetid] = 0;
    return 1;
}
Reply
#7

Quote:
Originally Posted by Facerafter
Посмотреть сообщение
Why would it be a problem if playerid == playerb?
It wouldn't but why would you allow your admins to respond to their own request?
Reply
#8

Added IsPlayerLoggedIn in the command, server still crashes.
Reply
#9

Or try the printf method so you can see what's causing the server to crash.
Reply
#10

Tty crash detect plugins and post server.log
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)