SA-MP Forums Archive
cmd resets server - 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: cmd resets server (/showthread.php?tid=454400)



cmd resets server - BossZk - 28.07.2013

I'm having a problem, can't seem to find the solution to it, I only ask for help here when I have searched for hours and can't find anything, so hopefully you guys can help me out, but my kick/ban/set admin level command resets the server

It works all fine on my test server, which isn't hosted, which is on my own ip. But those same commands on the host keeps resetting the server as they are used etc..

here's my kick command so you guys can see if there's any issues with it or something

pawn Код:
CMD:kick(playerid,params[])
{
    new string[200];
    if(pInfo[playerid][Adminlevel] < 2) return SendClientMessage(playerid, COLOR_ERROR, "Error: Insufficient Permission");
    if(sscanf(params, "us[200]", ID, string))
    {
        SendClientMessage(playerid, COLOR_ADCMD, "Usage: /kick (id) (reason)");
        SendClientMessage(playerid, COLOR_ADCMD2, "Function: Will kick the specified player");
        return 1;
    }
    if(pInfo[ID][Adminlevel] > pInfo[playerid][Adminlevel])
    {
        SendClientMessage(playerid, COLOR_ERROR, "Error: You cannot kick higher level staff members");
        return 1;
    }
    if(pInfo[playerid][Adminlevel] >= 2)
    {
        if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID)
        {
            format(string, sizeof(string), "**%s(%d) has been kicked by an Administrator | Reason: %s", GetName(ID), ID, string);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            format(string, sizeof(string), "**%s has been kicked by Administrator %s | Reason: %s", GetName(ID), GetName(playerid), string);
            SaveIn("KickLog",string);
            pInfo[ID][Kicked] ++;
            SetTimerEx("KickEx", 500, false, "d", ID);
            return 1;
        }
    }
    return 1;
}



Re: cmd resets server - Jstylezzz - 28.07.2013

pawn Код:
SaveIn("KickLog",string);
Maybe if the 'KickLog' file isn't writable, it could be the server crashes. Make sure that the file exists and is writable. Also, do some debugging; Place print's all over one of the commands, like this:
pawn Код:
CMD:kick(playerid,params[])
{
    print("1");
    new string[200];
    if(pInfo[playerid][Adminlevel] < 2) return SendClientMessage(playerid, COLOR_ERROR, "Error: Insufficient Permission");
    print("2");
    if(sscanf(params, "us[200]", ID, string))
    {
        SendClientMessage(playerid, COLOR_ADCMD, "Usage: /kick (id) (reason)");
        SendClientMessage(playerid, COLOR_ADCMD2, "Function: Will kick the specified player");
        return 1;
    }
    print("3");
    if(pInfo[ID][Adminlevel] > pInfo[playerid][Adminlevel])
    {
        SendClientMessage(playerid, COLOR_ERROR, "Error: You cannot kick higher level staff members");
        return 1;
    }
    print("4");
    if(pInfo[playerid][Adminlevel] >= 2)
    {
        if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID)
        {
            format(string, sizeof(string), "**%s(%d) has been kicked by an Administrator | Reason: %s", GetName(ID), ID, string);
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            format(string, sizeof(string), "**%s has been kicked by Administrator %s | Reason: %s", GetName(ID), GetName(playerid), string);
            print("before kicklog");
            SaveIn("KickLog",string);
            print("after kiclog");
            pInfo[ID][Kicked] ++;
            print("before timer");
            SetTimerEx("KickEx", 500, false, "d", ID);
            print("after timer");
            return 1;
        }
    }
    print("end of command");
    return 1;
}
If you use the code provided above, just execute the command and check the server log after the crash. You'll be able to narrow down the problematic point a little easier that way.
Another thing you can do is use the crashdetect plugin.


Re: cmd resets server - EvanA - 28.07.2013

Maybe its the host.


Re: cmd resets server - CmZxC - 28.07.2013

SaveIn problably saves a file in the folder, and the folder isnt created. This error is commonly known to me, and has lead to many rage moments. Make sure you have folders required for SaveIn function to actually create files in folders.


Re: cmd resets server - BossZk - 28.07.2013

Quote:
Originally Posted by CmZxC
Посмотреть сообщение
SaveIn problably saves a file in the folder, and the folder isnt created. This error is commonly known to me, and has lead to many rage moments. Make sure you have folders required for SaveIn function to actually create files in folders.
i was thinking the same thing, but my folders are created, which is why I'm really confused


Re: cmd resets server - SuperViper - 28.07.2013

Unless you're using io_append or io_readwrite, make sure the actual FILE is created.


Re: cmd resets server - BossZk - 28.07.2013

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Unless you're using io_append or io_readwrite, make sure the actual FILE is created.
I am using io_append

but here's my SaveIn function:

pawn Код:
public SaveIn(filename[],text[])
{
    new File:Lfile;
    new filepath[256];
    new string[256];
    new year,month,day;
    new hour,minute,second;

    getdate(year,month,day);
    gettime(hour,minute,second);
    format(filepath,sizeof(filepath),"Logs/%s.txt",filename);
    Lfile = fopen(filepath,io_append);
    format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
    fwrite(Lfile,string);
    fclose(Lfile);
    return 1;
}

EDIT: Removed it from saving in the logs just to test it, now it is working fine, so it does have an issue with writing the logs, could someone help me fix this?


Re: cmd resets server - BossZk - 30.07.2013

Bump


Re: cmd resets server - Jstylezzz - 30.07.2013

The folder it's attempting to save it to, 'Logs', is with a capital letter. Make sure that the actual folder you created is exactly the same, this includes the uppercase letter.


Re: cmd resets server - BossZk - 07.08.2013

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
The folder it's attempting to save it to, 'Logs', is with a capital letter. Make sure that the actual folder you created is exactly the same, this includes the uppercase letter.
Thanks bud, that was the issue. Was really stupid of me for not trying that earlier loool.
+repped