PDA

View Full Version : Help with car deletion


nickbouwhuis
01/10/2012, 06:33 PM
Hello guys!

I have recently opened a server for A big YouTuber here in the Netherlands and we made a SAMP server for him. We allow vehicle spawning, but it's getting out of control, how can the vehicles be automatically deleted?

Any help would be appreciated!

-Nick

Red_Dragon.
01/10/2012, 06:56 PM
You mean DELETED or DE spawned ?!?!?

nickbouwhuis
01/10/2012, 07:30 PM
You mean DELETED or DE spawned ?!?!?
Yeah, I mean de spawn

Post a code, please.
What kind of code? You mean, from the Spawn Car filterscript?

Red_Dragon.
01/10/2012, 07:50 PM
Hmmm, You may put a command to re-spawn all unoccupied vehicles for example

Dizzle
01/10/2012, 08:39 PM
CMD:respawnallveh(playerid, params[])
{
#pragma unused params
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "All unoccupied vehicles were respawned!");
}
for(new cars=0; cars<MAX_VEHICLES; cars++)
{
if(!VehicleOccupied(cars))
{
SetVehicleToRespawn(cars);
}
}
return 1;
}

And at the bottom of your script -

stock IsVehicleOccupied(vehicleid)
{
for (new i = 0; i < GetMaxPlayers(); i ++)
{
if (GetPlayerVehicleID(playerid) == vehicleid) return true;
}
return false;
}

Untested.

nickbouwhuis
02/10/2012, 08:13 AM
CMD:respawnallveh(playerid, params[])
{
#pragma unused params
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "All unoccupied vehicles were respawned!");

for(new cars=0; cars<MAX_VEHICLES; cars++)
{
if(!VehicleOccupied(cars))
{
SetVehicleToRespawn(cars);
}
}
return 1;
}

And at the bottom of your script -

stock IsVehicleOccupied(vehicleid)
{
for (new i = 0; i < GetMaxPlayers(); i ++)
{
if (GetPlayerVehicleID(playerid) == vehicleid) return true;
}
return false;
}

Untested.

Thanks! I'll test it later today and i'll let you know if it worked!

__EDIT__
Nope does not work