Server Crashes due to some weird reasons
#12

Hi OP:
-What i suggest you to do to track down /What/ causes this, is to debug the code.
Createplayercar is not a large snippet of code, and could lead us in some direction with debug messages added to it.
Here is an example, look at the prints. When the server crashes, it won't handle the prints, so that way you can locate where it stops exactly.

Can you try something like this, and come back with the results?
PHP Code:
YCMD:createplayercar(playeridparams[], help) { 
    new 
model,c1,c2,lock
    new 
playa
    print(
"debug message 1"); //prints to log 
    
if(help) { 
        
SendClientMessage(playeridX11_WHITE"Creates a car for a player"); 
        return 
1
    } 
    if (!
sscanf(params"k<playerLookup_acc>dddd"playa,modelc1c2lock)) 
    { 
        if(!
IsPlayerConnectEx(playa)) { 
            
SendClientMessage(playeridX11_WHITE"Error: player not connected"); 
            return 
1
        } 
        print(
"debug message 2"// and so on.
        
new EAdminFlags:aflags EAdminFlags:GetPVarInt(playerid"AdminFlags"); 
        if(
playerid == playa) { 
            if(~
aflags EAdminFlags_CanRefundSelf) { 
                
SendClientMessage(playeridX11_TOMATO_2"You cannot refund yourself!"); 
                return 
1
            } 
        } 
        new 
Float:X,Float:Y,Float:Z,Float:A
        
GetPlayerPos(playeridXYZ); 
        print(
"debug message 3"//
        
GetPlayerFacingAngle(playeridA); 
        if(
c1 || c1 255 || c2 || c2 255
        { 
            
SendClientMessage(playeridX11_RED2"   Color ID can't be below 0 or above 255!"); 
            return 
1
        } 
        if(
lock || lock 7
        { 
            
SendClientMessage(playeridX11_RED2"   The lock ID can't be below 0 or above 7!"); 
            return 
1
        }
        print(
"debug message 4"//
        
if(!isValidModel(model)) { 
            
SendClientMessage(playeridX11_RED2"   Invalid Vehicle Model"); 
            return 
1
        } 
        print(
"debug message 5"//
        
CreatePlayerCar(playamodelc1c2XYZAELockType:lock); 
        print(
"debug message 6"//for example, if createplayercar above caused the crash, this message will not appear in the log.
        
new string[128]; 
        
format(stringsizeof(string), "* Vehicle successfully created."); 
        
SendClientMessage(playeridCOLOR_LIGHTGREENstring); 
        
format(stringsizeof(string), "An admin added a %s to your cars."VehiclesName[model-400]); 
        
SendClientMessage(playaX11_ORANGEstring); 
        if(
GetPVarInt(playerid"AdminHidden") != 2) { 
            
format(stringsizeof(string), "* %s has given %s a %s",GetPlayerNameEx(playeridENameType_AccountName), GetPlayerNameEx(playaENameType_CharName),  VehiclesName[model-400]);
        print(
"debug message 7"// 
            
ABroadcast(X11_YELLOWstringEAdminFlags_AdminManage); 
        } 
    } else { 
        
SendClientMessage(playeridX11_WHITE"USAGE: /createplayercar [playerid/name] [model] [colour1] [colour2] [locktype]"); 
        
SendClientMessage(playeridX11_WHITE"Lock types: 0 = Default, 1 = Simple, 2 = remote, 3 = remote, 4 = advanced, 5 = satelitte, 6 = titanium laser, 7 = bio"); 
    } 
    return 
1

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)