19.04.2013, 22:50
Okay I am having a server crash... When I use a command that will open up my logs from IG so lets say '/bugs low' and there is no buglow.cfg in scriptfiles it causes a the server to crash, So how would I make it so if no buglow.cfg is found it will send a client message and wont let the server crash...
command I am using for this to happen.
command I am using for this to happen.
Код:
CMD:bugs(playerid,params[]) { // Calculating new Year, Month, Day; getdate(Year, Month, Day); { new ActualDay; PlayerInfo[playerid][pIDay] = ActualDay; PlayerInfo[playerid][pIMonth] = Month; PlayerInfo[playerid][pIDay] = Day; PlayerInfo[playerid][pIMonth] = Month; PlayerInfo[playerid][pIYear] = Year; } new bugtype[64], bugname; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(sscanf(params, "s[64]", bugtype)) { SendClientMessage(playerid, COLOR_WHITE, "** [Usage]:/bugs [type]"); SendClientMessage(playerid, COLOR_WHITE, "Valid types are: Low, Mid, High, fixed, all"); return 1; } if(!strcmp(bugtype, "low", true)) { if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128."); new string[128], File: file = fopen("buglow.cfg", io_read), idx=1; format(string, sizeof(string), "American Roleplay - Bugs until %d/%d/%d", PlayerInfo[playerid][pIMonth], PlayerInfo[playerid][pIDay], PlayerInfo[playerid][pIYear]); SendClientMessage(playerid, COLOR_LIGHTRED, string); while(fread(file, string)) { format(string, sizeof(string), "[%d] Bug: %s - Info: %s - Status:", idx, bugname, string); SendClientMessage(playerid, COLOR_YELLOW, string); idx ++; } fclose(file); } if(!strcmp(bugtype, "mid", true)) { if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128."); new string[128], File: file = fopen("bugmid.cfg", io_read), idx=1; format(string, sizeof(string), "American Roleplay - Bugs until %d/%d/%d", PlayerInfo[playerid][pIMonth], PlayerInfo[playerid][pIDay], PlayerInfo[playerid][pIYear]); SendClientMessage(playerid, COLOR_LIGHTRED, string); while(fread(file, string)) { format(string, sizeof(string), "[%d] Bug: %s - Info: %s - Status:", idx, bugname, string); SendClientMessage(playerid, COLOR_ORANGE, string); idx ++; } fclose(file); } return 1; }