A command resetting ALL vehicles (unoccupied) crashes the server... -
Ash. - 22.06.2011
Good Evening, Okay I wouldn't normally post here about things like this, but I thought it was worth mentioning.
I have this command:
pawn Код:
dcmd_resetvehicles(playerid, params[])
{
HMOD_CHECK;
for(new i; i < MAX_VEHICLES; i++)
{
if(IsVehicleEmpty(i) == 1) SetVehicleToRespawn(i);
}
#pragma unused params
return 1;
}
The function it uses:
pawn Код:
stock IsVehicleEmpty(vehicleid)
{
for(new i; i < GetMaxPlayers(); i++)
{
if(GetPlayerVehicleID(i) == vehicleid) return 0;
if(GetVehicleTrailer(GetPlayerVehicleID(i)) == vehicleid) return 0;
}
return 1;
}
However, it crashes the server?! It seems pretty straight forward and I don't see what could crash it.
I have also tried like this:
pawn Код:
dcmd_resetvehicles(playerid, params[])
{
HMOD_CHECK;
for(new i; i < MAX_VEHICLES; i++)
{
for(new p; p < GetMaxPlayers(); p++)
{
if(GetPlayerVehicleID(p) == i) continue;
if(GetVehicleTrailer(GetPlayerVehicleID(p)) == i) continue;
SetVehicleToRespawn(i);
}
}
return 1;
}
This also crashes the server.
I do not see what could be crashing the server.
Also, I know it is this command. I enabled a "crash reporter", to log everything players do (I knew it wasn't in a recurring timer or something, as my test server which is locked; doesn't have this problem - and it doesn't get used that often, if at all)
The crash log has given the same results EVERY time.
Код:
AleXandeR(2): Called Command: /resetvehicles =# System Crash (HALT)
Ash(12): Called Command: /resetvehicles =# System Crash (HALT)
Joe(4): Called Command: /resetvehicles =# System Crash (HALT)
Slithisthroat(0)Called Command: /resetvehicles =# System Crash (HALT)
They are all on separate occasions.
Has anyone got any ideas, I just don't see what could be at fault.
Thanks,
Ash.
Re: A command resetting ALL vehicles (unoccupied) crashes the server... -
Sascha - 22.06.2011
pawn Код:
stock IsVehicleEmpty(vehicleid)
{
new rst = 0;
for(new i; i < GetMaxPlayers(); i++)
{
if(GetPlayerVehicleID(i) == vehicleid) rst = 1;
if(GetVehicleTrailer(GetPlayerVehicleID(i)) == vehicleid) rst = 1;
}
if(rst == 1) return 0;
return 1;
}
and what's this? "HMOD_CHECK;"
edit: uh wait.. I guess your version would work same good..
however I would add a "IsPlayerConnected" above^^
Re: A command resetting ALL vehicles (unoccupied) crashes the server... -
Ash. - 22.06.2011
HMOD_CHECK is a define. It's just a shorter way of writing:
if(!IsHMod(playerid)) return SendClientMessage(...); etc
Also, there can be multiple outcomes in a loop, so your code (with a single variable) won't work.
Re: A command resetting ALL vehicles (unoccupied) crashes the server... -
Ash. - 26.06.2011
Sorry for the bump, however I've tried a fix and still no luck! Has anyone got any ideas?