SA-MP Forums Archive
Wierd (/ban & /kick) server crash - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wierd (/ban & /kick) server crash (/showthread.php?tid=464158)



Wierd (/ban & /kick) server crash - Patrick - 15.09.2013

pawn Код:
CMD:ban(playerid, params[])
{
    new ID, string[128], reason[24];
    if(!(PlayerInfo[playerid][pAdmin] >= 3)) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]"COL_LIGHTBLUE" - You are not high enough to use this command.");
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]"COL_LIGHTBLUE" - The player you're trying to ban isn't connected to the server.");
    if(sscanf(params, "us[24]", ID, reason)) return SendClientMessage(playerid, -1, "[USAGE] - /ban ( ID ) ( Reason )");

    format(string, sizeof(string), "** %s(%d) Has been banned by Administrator %s(%d) - Reason: %s",PlayerName(ID), ID, PlayerName(playerid), playerid, reason);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    Log("Log/ban.log", string);
    PlayerInfo[ID][pBanned] =1;
    Kick(ID);
    return 1;
}

CMD:kick(playerid, params[])
{
    new ID, string[90], reason[24];
    if(!(PlayerInfo[playerid][pAdmin] >= 3)) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]"COL_LIGHTBLUE" - You are not high enough to use this command.");
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]"COL_LIGHTBLUE" - The player you're trying to kick isn't connected to the server.");
    if(sscanf(params, "us[24]", ID, reason)) return SendClientMessage(playerid, -1, "[USAGE] - /kick ( ID ) ( Reason )");

    format(string, sizeof(string), "** %s(%d) Has been kicked by Administrator %s(%d) - Reason: %s",PlayerName(ID), ID, PlayerName(playerid), playerid, reason);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    Log("Log/kick.log", string);
    Kick(playerid);
    return 1;
}
I have no idea what the problem is, I've use this same process before in my other script but on this one, everytime I execute this command the samp-server.exe crashes for some reason, any Idea why does this happen? I know you've seen my reputtion and stuff but I can't fix this no more, I did try my best yet I did not see the problem

PS: I also tried it with Crash Detect plugin and it doesn't give me any debug or and text about it on server.log, and I find it weird, I left scripting 7 months ago and I just came back like 4 days ago, so yeah if you think I'm noob


Re: Wierd (/ban & /kick) server crash - Jstylezzz - 15.09.2013

The kick.log file, does it exist and is it writable?


Re: Wierd (/ban & /kick) server crash - Patrick - 15.09.2013

Yes it is writable and Here's my Log Stock

pawn Код:
stock Log(sz_fileName[], sz_input[]) {

    new sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
   
    gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
    getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
   
    format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
    fwrite(fileHandle, sz_logEntry);
    return fclose(fileHandle);
}



Re: Wierd (/ban & /kick) server crash - Konstantinos - 15.09.2013

Change to:
pawn Код:
stock Log(sz_fileName[], sz_input[]) {

    new sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
   
    gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
    getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
   
    format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
    if(fileHandle)
    {
        fwrite(fileHandle, sz_logEntry);
        fclose(fileHandle);
    }
}
Test it and let us know.


Re: Wierd (/ban & /kick) server crash - Patrick - 15.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Change to:
pawn Код:
stock Log(sz_fileName[], sz_input[]) {

    new sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
   
    gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
    getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
   
    format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
    if(fileHandle)
    {
        fwrite(fileHandle, sz_logEntry);
        fclose(fileHandle);
    }
}
Test it and let us know.
Yo' man, thanks alot, I can't say anything else than thanks :P