Car Respawn Command doesn't work
#1

Pawn Code:

CMD:respawncars(playerid, params[])
{
for(new i=0; i<MAX_VEHICLES; i++)
SetVehicleToRespawn(i);
SCMToAll(gelb,"Alle Autos wurden respawned.");
return 1;
}

When i type ingame. /respawncars the cars just disappear and don't respawn
Reply
#2

Код:
for(new i = GetVehiclePoolSize(); i > 0; i--)
{
	SetVehicleToRespawn(i);
}
https://sampwiki.blast.hk/wiki/Function:SetVehicleToRespawn
Reply
#3

Doesn't work...
The Cars just disappear but don't respawn
Reply
#4

Don't use SCMToAll() in the loop. It'll spam the message depending on the amount of vehicles respawned.

PHP код:
CMD:respawncars(playeridparams[])
{
    new 
vehiclesExist 0;
    for(new 
GetVehiclePoolSize(); 0i--)
    {
        
SetVehicleToRespawn(i);
        
vehiclesExist++;
    }
    if (
vehiclesExist)
        
SCMToAll(gelb,"Alle Autos wurden respawned.");
    else
        
SendClientMessage(playerid, -1"No vehicles were available to respawn.");
         
    return 
true;

EDIT:

It isn't possible to destroy the vehicle using SetVehicleToRespawn.

Check public OnVehicleSpawn(vehicleid) and see if DestroyVehicle(vehicleid) is in there.
Reply
#5

I have this in there:
public OnVehicleSpawn(vehicleid,playerid)
{
SetVehiclePos(vehicleid,vx,vy,vz);
SetVehicleZAngle(vehicleid,vr);
SetVehicleHealth(vehicleid,399);
return 1;
}

Because when a car explodes, it respawns where it exploded

Edit: Without it, it works..
But i still want this in there
Reply
#6

Remove that completely. It doesn't help you at all having that.

There's no playerid parameter in OnVehicleSpawn and where are you grabbing vx, vy, vz and vr from to set their positions?



OnVehicleDeath is called when a vehicle is destroyed.

https://sampwiki.blast.hk/wiki/OnVehicleDeath
Reply
#7

I already fixed it, thank you all <3
My Vehicles Spawn where they exploded, and i can respawn all cars, Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)