Vehicles Not respawning! Help please
#1

Hello people of the forum.

I have currently added vehicles using
Код:
CreateVehicle
since it allows respawn.


Then sometimes using the vehicle spawner shit gets really messed up I needed to clear all them vehicles, so I searched a bit and someone had made this.


Код:
if( strcmp( cmdtext, "/deleteallcars", true ) == 0 )
     {
         for( new veh; veh < MAX_VEHICLES; veh ++ )
         {
             if ( veh != INVALID_VEHICLE_ID )
             {
             DestroyVehicle( veh );
             }
         }
         SendClientMessage(playerid, 0xFFFF00AA, "Deleted all cars on the server!");
         return 1;
	 }
This deletes all the cars like needed.

But the vehicles WONT Respawn after 15 seconds, YES I have added a 15 sec timer I know how
Код:
CreateVehicle
works.

Why won't they respawn? what am I doing wrong?

Helper will be repped,

Regards, Eemale


EDIT: Also this destorys my BOT's lawn mower how would I avoid that?
Reply
#2

Can you show us part of code where you respawn vehicles.
Reply
#3

Well, you destroy them, so they won't get back to they spot...

You can use "SetVehicleToRespawn" to reset a vehicles' start position.
Reply
#4

Oh, I didn't figured out ok what he wanted to say.

+1 to dusk , but if you destroy all vehicles you'll need to CreateVehicle again
Reply
#5

Edit: Already answered.
Reply
#6

Like dusk said, you destroy the vehicles so you cannot respawn invalid vehicles back.

I'm sure you declare a variable for the NPC's vehicle. If so,
pawn Код:
if ( veh != INVALID_VEHICLE_ID && veh != /* the one you stored the vehicle for the NPC */)
Reply
#7

pawn Код:
if( strcmp( cmdtext, "/deleteallcars", true ) == 0 )
     {
         for( new veh=0; veh < MAX_VEHICLES; veh ++ )
         {
             if ( veh != INVALID_VEHICLE_ID )
             {
             DestroyVehicle( veh );
             }
         }
         SendClientMessage(playerid, 0xFFFF00AA, "Deleted all cars on the server!");
         return 1;
     }
Reply
#8

Why have you just copied and pasted the code and re-posted it?
Reply
#9

So is there any other way to remove all the vehicles, and those added in the script as

"CreateVehicle" will respawn?

Under where and how should I use
Код:
SetVehicleToRespawn?
Reply
#10

I don't follow you anymore...but if you want the vehicles to be set to respawn:
pawn Код:
if(!strcmp(cmdtext,"respawnallvehicles"))
{
   for(new i = 1; i < MAX_VEHICLES; i++)
   {
       if(IsValidVehicle(i))
       {
              SetVehicleToRespawn(i);
       }
    }
    return 1;
}


Note that the function IsValidVehicle must be declared native:
pawn Код:
native IsValidVehicle(vehicleid);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)