Time freeze using CMDS [vehicle] -
PepsiCola23 - 19.05.2015
Hello guys ,right now i`m improving my dynamic dealership that i made almost from scrathch.
I made a basic comand [ /buyinfernus] to see if its working.
And i also made /v park /v color etc.
All of them work,except 1 thing: after i use one of those cmds[/buyinfernus , /v park , /v color etc] the time freezes for ~11 seconds,and then everything works fine.
I dont know why after one of those cmds ,the time stopps for 11 seconds.
I accept any tips,thanks in advance.
/buyinfernus cmd
PHP код:
// comanda buy infernus//
if(strcmp(cmd, "/buyinfernus", true) == 0)
{
if(PlayerInfo[playerid][pPcarkey] == -1) { }
else if(PlayerInfo[playerid][pPcarkey2] == -1) { }
else if(PlayerInfo[playerid][pPcarkey3] == -1) { }
else { SendClientMessage(playerid, COLOR_GREY, "* Detii 3 masini!"); return 1; }
if(PlayerInfo[playerid][pLevel] >= 5 )
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /buyinfernus [color1] [color2] ");
return 1;
}
// new car;
// car = strval(tmp);
// if(car < 411 || car > 411) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}*Aceasta este comanda de a cumpara infernus !"); return 1; }
// tmp = strtok(cmdtext, idx);
// if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /buyinfernus"); return 1; }
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}* Color Number can't be below 0 or above 126 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}* Color Number can't be below 0 or above 126 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
new thiscar = CreateVehicle(411,X,Y,Z,1,color1,color2,99999999);
if(PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = thiscar; }
else if(PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = thiscar; }
else if(PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = thiscar; }
else { return 1; }
// new value = strval(tmp);
CarInfo[thiscar][cModel] = 411; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
CarInfo[thiscar][paintjob] = -1; LoadComponents(thiscar); PutPlayerInVehicle(playerid,thiscar,0);
CarInfo[thiscar][cOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[thiscar][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-150000);
//Delete3DTextLabel(TextUpCar[idcar]);
OnCarUpdate(); SavePlayerData(playerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid, "~w~Felicitari~n~ai platit 150k pentru infernus !", 5000, 3);
TogglePlayerControllable(playerid, 1);
return 1;
}
}
And the v color/park etc cmds:
PHP код:
//==========================[/v(ehicle)]========================================
if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new x_nr[64];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "____________[Personal Vehicle Help]____________");
SendClientMessage(playerid, COLOR_WHITE, "** {1AFF00}(/v)ehicle {09DFF7}[name]");
SendClientMessage(playerid, COLOR_WHITE, "**buy, park, color, tow(1-3), fix(1-3), model");
return 1;
}
if(strcmp(x_nr,"park",true) == 0)
{
new Float:x,Float:y,Float:z;
new Float:a;
new carid;
new getcarid = GetPlayerVehicleID(playerid);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
else { return 1; }
GetPlayerName(playerid, playername, sizeof(playername));
GetVehiclePos(carid, x, y, z);
GetVehicleZAngle(carid, a);
if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
{
if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
{
SendClientMessage(playerid, COLOR_GREY, "N ai o masina personala.");
return 1;
}
if(getcarid == carid)
{
new Float:CarHP, Float:OldCarHP; new panels,doors,lights,tires;
CarInfo[carid][cLocationx] = x;
CarInfo[carid][cLocationy] = y;
CarInfo[carid][cLocationz] = z;
CarInfo[carid][cAngle] = a;
GetVehicleDamageStatus(carid,panels,doors,lights,tires);
GetVehicleHealth(carid, CarHP); OldCarHP = CarHP;
OnCarUpdate(); DestroyVehicle(carid);
CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
// format(TextCar, sizeof(TextCar), "{EE1111}Owner: {0099FF}• %s •", CarInfo[carid][cOwner]);
// Update3DTextLabelText(TextUpCar[carid], 0x33AAFFFF, TextCar);
LoadComponents(carid);
SendClientMessage(playerid, COLOR_BLUE, "* Noua pozitie a fost salvata!");
SetVehicleHealth(carid, OldCarHP);
UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
return 1;
}
}
}
/* else if(strcmp(x_nr,"buy",true) == 0)
{
if(IsAnOwnableCar(idcar))
{
if(PlayerInfo[playerid][pPcarkey] == -1) { }
else if(PlayerInfo[playerid][pPcarkey2] == -1) { }
else if(PlayerInfo[playerid][pPcarkey3] == -1) { }
else { SendClientMessage(playerid, COLOR_GREY, "* Detii 3 masini!"); return 1; }
if(CarInfo[idcar][cOwned]==1)
{
SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car.");
return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo[idcar][cValue])
{
if(PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = idcar; }
else if(PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = idcar; }
else if(PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = idcar; }
else { return 1; }
CarInfo[idcar][cOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo[idcar][cValue]);
Delete3DTextLabel(TextUpCar[idcar]);
//format(TextCar, sizeof(TextCar), "{EE1111}Owner: {0099FF}• %s •", CarInfo[idcar][cOwner]);
//TextUpCar[idcar] = Create3DTextLabel(TextCar, 0x33AAFFFF, 0.0, 0.0, 0.0, 25, 0, 1);
//Attach3DTextLabelToVehicle(TextUpCar[idcar], idcar, 0.0, 0.0, 0.1);
OnCarUpdate(); SavePlayerData(playerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid, "~w~Felicitari~n~Nu uita sa o parchezi cu /v park !", 5000, 3);
TogglePlayerControllable(playerid, 1);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have enough cash with you!");
return 1;
}
}
} */
else if(strcmp(x_nr,"color",true) == 0)
{
if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
{
SendClientMessage(playerid, COLOR_GREY," You don't have a Vehicle to respray.");
return 1;
}
if(GetPlayerMoney(playerid) < 1000)
{
SendClientMessage(playerid, COLOR_GREY," You don't have enough money for vehicle respray.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 && color1 > 126)
{
SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 && color2 > 126)
{
SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
return 1;
}
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid = PlayerInfo[playerid][pPcarkey]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid = PlayerInfo[playerid][pPcarkey2]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { vehid = PlayerInfo[playerid][pPcarkey3]; }
else { return 1; }
if(IsPlayerInVehicle(playerid, vehid))
{
new Float:CarHP, Float:OldCarHP;
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehid, panels, doors, lights, tires);
GetVehicleHealth(vehid, CarHP); OldCarHP = CarHP;
CarInfo[vehid][cColorOne] = color1;
CarInfo[vehid][cColorTwo] = color2;
GivePlayerMoney(playerid, -1000);
GameTextForPlayer(playerid, "~w~Masina Personala~n~~g~Revopsita cu succes~n~~r~$-100", 5000, 1);
ChangeVehicleColor(vehid, color1, color2);
SetVehicleToRespawn(vehid);
SetVehicleHealth(vehid, OldCarHP);
UpdateVehicleDamageStatus(vehid, panels, doors, lights, tires);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
OnCarUpdate();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not in your Personal car.");
return 1;
}
}
/*else if(strcmp(x_nr,"locate1",true) == 0)
{
if(!IsPlayerConnected(playerid)) { return 1; }
new Float:x,Float:y,Float:z;
new car = PlayerInfo[playerid][pPcarkey];
if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
GetVehiclePos(car, x, y, z);
SetPlayerCheckpoint(playerid, x, y, z, 6);
return 1;
}
else if(strcmp(x_nr,"locate2",true) == 0)
{
if(!IsPlayerConnected(playerid)) { return 1; }
new Float:x,Float:y,Float:z;
new car = PlayerInfo[playerid][pPcarkey2];
if(PlayerInfo[playerid][pPcarkey2]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
GetVehiclePos(car, x, y, z);
SetPlayerCheckpoint(playerid, x, y, z, 6);
return 1;
}
else if(strcmp(x_nr,"locate3",true) == 0)
{
if(!IsPlayerConnected(playerid)) { return 1; }
new Float:x,Float:y,Float:z;
new car = PlayerInfo[playerid][pPcarkey3];
if(PlayerInfo[playerid][pPcarkey3]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
GetVehiclePos(car, x, y, z);
SetPlayerCheckpoint(playerid, x, y, z, 6);
return 1;
}*/
else if(strcmp(x_nr,"tow1",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Float:CarHP, Float:OldCarHP;
new panels,doors,lights,tires;
new car = PlayerInfo[playerid][pPcarkey];
GetPlayerName(playerid, playername, sizeof(playername));
if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
{
GetVehicleDamageStatus(car,panels,doors,lights,tires);
GetVehicleHealth(car, CarHP); OldCarHP = CarHP;
GameTextForPlayer(playerid, "~w~Masina personala~n~~g~Tractata cu succes~n~~r~$-1.500", 5000, 1);
GivePlayerMoney(playerid,-1500);
SetVehicleToRespawn(car);
SetVehicleHealth(car, OldCarHP);
UpdateVehicleDamageStatus(car, panels, doors, lights, tires);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else
{
GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
}
}
}
else if(strcmp(x_nr,"tow2",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Float:CarHP, Float:OldCarHP;
new panels,doors,lights,tires;
new car = PlayerInfo[playerid][pPcarkey2];
GetPlayerName(playerid, playername, sizeof(playername));
if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
{
GetVehicleDamageStatus(car,panels,doors,lights,tires);
GetVehicleHealth(car, CarHP); OldCarHP = CarHP;
GameTextForPlayer(playerid, "~w~Masina personala~n~~g~Tractata cu succes~n~~r~$-1.500", 5000, 1);
GivePlayerMoney(playerid,-1500);
SetVehicleToRespawn(car);
SetVehicleHealth(car, OldCarHP);
UpdateVehicleDamageStatus(car, panels, doors, lights, tires);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else
{
GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
}
}
}
else if(strcmp(x_nr,"tow3",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Float:CarHP, Float:OldCarHP;
new panels,doors,lights,tires;
new car = PlayerInfo[playerid][pPcarkey3];
GetPlayerName(playerid, playername, sizeof(playername));
if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
{
GetVehicleDamageStatus(car,panels,doors,lights,tires);
GetVehicleHealth(car, CarHP); OldCarHP = CarHP;
GameTextForPlayer(playerid, "~w~Masina personala~n~~g~Tractata cu succes~n~~r~$-1.500", 5000, 1);
GivePlayerMoney(playerid,-1500);
SetVehicleToRespawn(car);
SetVehicleHealth(car, OldCarHP);
UpdateVehicleDamageStatus(car, panels, doors, lights, tires);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else
{
GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
}
}
}
else if(strcmp(x_nr,"fix1",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new car = PlayerInfo[playerid][pPcarkey];
GetPlayerName(playerid, playername, sizeof(playername));
if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
{
GameTextForPlayer(playerid, "~w~Masina personala~n~~g~Reparata cu succes~n~~r~$-2.500", 5000, 1);
GivePlayerMoney(playerid,-2500);
SetVehicleToRespawn(car);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else
{
GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
}
}
}
else if(strcmp(x_nr,"fix2",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new car = PlayerInfo[playerid][pPcarkey2];
GetPlayerName(playerid, playername, sizeof(playername));
if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
{
GameTextForPlayer(playerid, "~w~Masina personala~n~~g~Reparata cu succes~n~~r~$-2.500", 5000, 1);
GivePlayerMoney(playerid,-2500);
SetVehicleToRespawn(car);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else
{
GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
}
}
}
else if(strcmp(x_nr,"fix3",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new car = PlayerInfo[playerid][pPcarkey3];
GetPlayerName(playerid, playername, sizeof(playername));
if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
{
GameTextForPlayer(playerid, "~w~Masina personala~n~~g~Reparata cu succes~n~~r~$-2.500", 5000, 1);
GivePlayerMoney(playerid,-2500);
SetVehicleToRespawn(car);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
}
else
{
GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
}
}
}
else if(strcmp(x_nr,"x2x1x4x4x1",true) == 0)
{
new Float:x,Float:y,Float:z;
new carid;
new Float:a;
new Float:CarHP, Float:OldCarHP;
new panels,doors,lights,tires;
carid = GetPlayerVehicleID(playerid);
GetVehiclePos(carid, x, y, z);
GetVehicleZAngle(carid, a);
if(IsPlayerInVehicle(playerid,carid))
{
if(PlayerInfo[playerid][pDonateRank] < 3)
{
SCM(playerid, COLOR_GREY, "* Trebuie sa ai cont EXTRA VIP pentru acces la /v model!");
return 1;
}
if(GetPlayerMoney(playerid) < 5000)
{
SendClientMessage(playerid, COLOR_GREY,"Nu ai destui bani.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SCM(playerid, COLOR_GREY, "USAGE: x");
return 1;
}
new model;
model = strval(tmp);
if(model < 400 || model > 611)
{
SCM(playerid, COLOR_GREY, "* x");
return 1;
}
else
{
//new tittle[128];
//new carkey = PlayerInfo[playerid][pPcarkey];
//format(tittle,128,"%s", CarInfo[carkey][cModel]);
//else
//{
CarInfo[carid][cModel] = model;
CarInfo[carid][cLocationx] = x;
CarInfo[carid][cLocationy] = y;
CarInfo[carid][cLocationz] = z;
CarInfo[carid][cAngle] = a;
//format(string, sizeof(string), "~n~ You changed Car's Model~n~");
GetVehicleDamageStatus(carid,panels,doors,lights,tires);
GetVehicleHealth(carid, CarHP); OldCarHP = CarHP;
OnCarUpdate(); DestroyVehicle(carid);
CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
LoadComponents(carid);
GivePlayerMoney(playerid, -5000);
SendClientMessage(playerid, COLOR_BLUE, "* Schimbarea modelului te-a costat $5.000!");
//format(string, sizeof(string), "~n~ You changed Car's Model~n~");
SetVehicleHealth(carid, OldCarHP);
UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
format(CarInfo[carid][cDescription], 32, "%s",vehName[model-400]);
return 1;
}
/*else
{
SCM(playerid, COLOR_GREY, "* Trebuie sa fi in masina pentru a utiliza comanda!");
return 1;
}*/
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "____________[Personal Vehicle Help]____________");
SendClientMessage(playerid, COLOR_WHITE, "** {1AFF00}(/v)ehicle {09DFF7}[name]");
SendClientMessage(playerid, COLOR_WHITE, "**buy, park, color, tow(1-3), fix(1-3), model");
return 1;
}
}
return 1;
}
REMIND: everything works fine after those 11 seconds[not just for me,for the hole server] but i want to remove this time freeze/bug/stop .Thanks in advance.
Re: Time freeze using CMDS [vehicle] -
azzerking - 19.05.2015
What do you mean by time freeze?
As in the server freezes for some time? or do you mean you made a textdraw with server time and it stopped updating?
if its the server freezing then you are calling an update function which is hanging for 11 seconds causing any other server actions/processes to wait. Remember SA-MP is single threaded, meaning if you had:
Код:
public OnGameModeInit()
{
FunctionOne();
FunctionTwo();
return 1;
}
public FunctionOne()
{
for(;;) { print("Never Ending Loop"); }
return 1;
}
public FunctionTwo()
{
print("Function Two Called");
return 1;
}
Function Two will never get called as function one will never complete its process. So you need to check your script for endless or wasted for loops.
- Think clearly about what your for loops are being used for.
- Also if you can I would suggest using something other then 'strcmp' for commands, try (ZCMD, DCMD, etc)
Re: Time freeze using CMDS [vehicle] -
PepsiCola23 - 19.05.2015
I searched but the problem is just at CMDS with vehicles involved such as /buyinfernus , /v color , /vpark so i think its from one of those cmds.
yes the server freezes for 11 seconds and then it come`s back.
I might think of trying the ZCMD,maybe it will help,but any other suggestions?[i will edit if its working]
Until then,please suggest me what to do.
Re: Time freeze using CMDS [vehicle] -
azzerking - 19.05.2015
I think it might be this:
It looks like your updating every vehicle currently loaded in game and not the one car that needs updating? But that's just an observation because you didn't provide that in your code.
Re: Time freeze using CMDS [vehicle] -
PepsiCola23 - 19.05.2015
I still dont get it,i loocked in public oncarupdate ,i think the problem is from new idx = carsonserver but i dont really dont know how to fix it.
PHP код:
public OnCarUpdate()
{
new idx;
new File: file2;
idx = carsonserver;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo],
CarInfo[idx][cOwner],
CarInfo[idx][cDescription],
CarInfo[idx][cValue],
CarInfo[idx][cOwned],
CarInfo[idx][mod1],
CarInfo[idx][mod2],
CarInfo[idx][mod3],
CarInfo[idx][mod4],
CarInfo[idx][mod5],
CarInfo[idx][mod6],
CarInfo[idx][mod7],
CarInfo[idx][mod8],
CarInfo[idx][mod9],
CarInfo[idx][mod10],
CarInfo[idx][mod11],
CarInfo[idx][mod12],
CarInfo[idx][mod13],
CarInfo[idx][mod14],
CarInfo[idx][mod15],
CarInfo[idx][mod16],
CarInfo[idx][mod17],
CarInfo[idx][paintjob]);
if(idx == carsonserver)
{
file2 = fopen("masini.cfg", io_write);
}
else
{
file2 = fopen("masini.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
I really apreciate your support guys,thanks.
Re: Time freeze using CMDS [vehicle] -
Konstantinos - 19.05.2015
Opening, writing and closing files 2000 times. You set idx to the value "carsonserver" is so what's the point of checking all the time instead of just opening the file once.
Plus you never check for invalid file handles and that can crash the server and declaring a string 2000 times as well (keep it outside of the loop).
PHP код:
public OnCarUpdate()
{
new coordsstring[256], File: file2 = fopen("masini.cfg", io_write);
if (!file2) return 0;
for (new idx = carsonserver; idx != sizeof (CarInfo); ++idx)
{
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo],
CarInfo[idx][cOwner],
CarInfo[idx][cDescription],
CarInfo[idx][cValue],
CarInfo[idx][cOwned],
CarInfo[idx][mod1],
CarInfo[idx][mod2],
CarInfo[idx][mod3],
CarInfo[idx][mod4],
CarInfo[idx][mod5],
CarInfo[idx][mod6],
CarInfo[idx][mod7],
CarInfo[idx][mod8],
CarInfo[idx][mod9],
CarInfo[idx][mod10],
CarInfo[idx][mod11],
CarInfo[idx][mod12],
CarInfo[idx][mod13],
CarInfo[idx][mod14],
CarInfo[idx][mod15],
CarInfo[idx][mod16],
CarInfo[idx][mod17],
CarInfo[idx][paintjob]);
fwrite(file2, coordsstring);
}
fclose(file2);
return 1;
}
Re: Time freeze using CMDS [vehicle] -
azzerking - 19.05.2015
Make a new function called OnUpdateVehicle(vehicleid)
copy everything from OnCarUpdate(); and make idx = vehicleid;
that should work for it.
Re: Time freeze using CMDS [vehicle] -
PepsiCola23 - 19.05.2015
EDIT: IT IS WORKING,thanks azzerking for support and Konstantinos for the solution. THANKS Konstantinos,it worked!