PDA

View Full Version : cmd resets server


BossZk
28/07/2013, 07:15 PM
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


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;
}

Jstylezzz
28/07/2013, 07:38 PM
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:

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.

EvanA
28/07/2013, 07:45 PM
Maybe its the host.

CmZxC
28/07/2013, 07:55 PM
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.

BossZk
28/07/2013, 08:02 PM
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

SuperViper
28/07/2013, 08:05 PM
Unless you're using io_append or io_readwrite, make sure the actual FILE is created.

BossZk
28/07/2013, 08:26 PM
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:

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?

BossZk
30/07/2013, 06:12 PM
Bump

Jstylezzz
30/07/2013, 06:33 PM
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.

BossZk
07/08/2013, 04:08 PM
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