24.08.2017, 08:28
(
Last edited by denNorske; 24/08/2017 at 09:45 AM.
)
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?
-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(playerid, params[], help) {
new model,c1,c2,lock;
new playa;
print("debug message 1"); //prints to log
if(help) {
SendClientMessage(playerid, X11_WHITE, "Creates a car for a player");
return 1;
}
if (!sscanf(params, "k<playerLookup_acc>dddd", playa,model, c1, c2, lock))
{
if(!IsPlayerConnectEx(playa)) {
SendClientMessage(playerid, X11_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(playerid, X11_TOMATO_2, "You cannot refund yourself!");
return 1;
}
}
new Float:X,Float:Y,Float:Z,Float:A;
GetPlayerPos(playerid, X, Y, Z);
print("debug message 3") //
GetPlayerFacingAngle(playerid, A);
if(c1 < 0 || c1 > 255 || c2 < 0 || c2 > 255)
{
SendClientMessage(playerid, X11_RED2, " Color ID can't be below 0 or above 255!");
return 1;
}
if(lock < 0 || lock > 7)
{
SendClientMessage(playerid, X11_RED2, " The lock ID can't be below 0 or above 7!");
return 1;
}
print("debug message 4") //
if(!isValidModel(model)) {
SendClientMessage(playerid, X11_RED2, " Invalid Vehicle Model");
return 1;
}
print("debug message 5") //
CreatePlayerCar(playa, model, c1, c2, X, Y, Z, A, ELockType: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(string, sizeof(string), "* Vehicle successfully created.");
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
format(string, sizeof(string), "An admin added a %s to your cars.", VehiclesName[model-400]);
SendClientMessage(playa, X11_ORANGE, string);
if(GetPVarInt(playerid, "AdminHidden") != 2) {
format(string, sizeof(string), "* %s has given %s a %s",GetPlayerNameEx(playerid, ENameType_AccountName), GetPlayerNameEx(playa, ENameType_CharName), VehiclesName[model-400]);
print("debug message 7") //
ABroadcast(X11_YELLOW, string, EAdminFlags_AdminManage);
}
} else {
SendClientMessage(playerid, X11_WHITE, "USAGE: /createplayercar [playerid/name] [model] [colour1] [colour2] [locktype]");
SendClientMessage(playerid, X11_WHITE, "Lock types: 0 = Default, 1 = Simple, 2 = remote, 3 = remote, 4 = advanced, 5 = satelitte, 6 = titanium laser, 7 = bio");
}
return 1;
}