[SOLVED] lags the server - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] lags the server (
/showthread.php?tid=90628)
[SOLVED] lags the server -
SiJ - 09.08.2009
Hey,
Here's my code for vehicles respawn:
pawn Код:
if (strcmp(cmdtext, "/respawnvehicles", true) == 0 && pAdminLvl[playerid] >= 3)
{
SystemMsg(playerid,"Respawning all vehicles in server.. Please wait..");
for(new v = 0; v < MAX_VEHICLES; v++)
{
for(new i = 0; i <MAX_PLAYERS; i++)
{
if(!IsPlayerInAnyVehicle(i))
{
SetVehicleToRespawn(v);
}
}
}
SystemMsg(playerid,"All vehicles has been respawned!");
return 1;
}
Earlier it respawned vehicles like in 5 - 10 seconds.. (The code was without IsPlayerInAnyVehicle check) EDIT: But IsPlayerInAnyVehicle doesn't help cause even if player is in vehicle, his vehicle gets respawned..
But now it takes about 25-35 seconds to respawn (vehicle count is almost same as it was before) and it lags the server... Why?
And BTW Why vehicles usually spawn in wrong place? I save them to spawn in parking lot but they spawn in front of the road... After /respawnvehicles, they spawn correctly
And I do not use any vehicle streamer!
Re: /RespawnVehicles lags the server -
dice7 - 09.08.2009
Use GetPlayerState with PLAYER_STATE_DRIVER, because IsPlayerInAnyVehicle lags a little, since it needs to check through ~200 vehicles times MAX_PLAYERS which is 40000 times
Re: /RespawnVehicles lags the server -
SiJ - 09.08.2009
Quote:
Originally Posted by dice7
Use GetPlayerState with PLAYER_STATE_DRIVER, because IsPlayerInAnyVehicle lags a little, since it needs to check through ~200 vehicles times MAX_PLAYERS which is 40000 times
|
I just saw that maybe IsPlayerInVehicle(i,v) would be ok.. I'll try that and then try yours and tell which was better.
EDIT: This code:
pawn Код:
if (strcmp(cmdtext, "/respawnvehicles", true) == 0 && pAdminLvl[playerid] >= 3)
{
SystemMsg(playerid,"Respawning all vehicles in server.. Please wait..");
for(new v = 0; v < MAX_VEHICLES; v++)
{
for(new i = 0; i <MAX_PLAYERS; i++)
{
if(GetPlayerState(i) != PLAYER_STATE_DRIVER)
{
SetVehicleToRespawn(v);
}
}
}
SystemMsg(playerid,"All vehicles has been respawned!");
return 1;
}
Respawned vehicle I was in, and took about 30 seconds..
My code with IsPlayerInVehicle(i,v) Took about 10-15 seconds :P