Destroy Vehicle After Spawn Another One
#1

look at this script:


emenu.pwn

i got this script from this forum. it's called EMenu.
the script works great but i need this script to destroy vehicle after i spawned another one.
(btw i don't know anything about scripting.)
can anyone edit the scirpt so the script destroy vehicle after a layer spawned another one?
also, don't bother giving me other FS coz i want to use this one on my server.

thanks
Reply
#2

The script is really messy.

But you can save the vehicle ID in a variable and remove it after spawn another one.

pawn Код:
new SpawnedVehicle[MAX_PLAYERS];

if(IsValidVehicle(SpawnedVehicle[playerid]))
    DestroyVehicle(SpawnedVehicle[playerid]);
   
SpawnedVehicle[playerid] = CreateVehicle(...);
Important! Don't forgot to reset the variable and remove the vehicle after the player leaves the server.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(IsValidVehicle(SpawnedVehicle[playerid]))
        DestroyVehicle(SpawnedVehicle[playerid]);
       
    SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
    return 1;
}
The function IsValidVehicle is not defined in a_samp include, because of that don't forgot to add.

pawn Код:
native IsValidVehicle(vehicleid);
Top of your script.
Reply
#3

Quote:
Originally Posted by MouseBreaker
Посмотреть сообщение
The script is really messy.

But you can save the vehicle ID in a variable and remove it after spawn another one.

pawn Код:
new SpawnedVehicle[MAX_PLAYERS];

if(IsValidVehicle(SpawnedVehicle[playerid]))
    DestroyVehicle(SpawnedVehicle[playerid]);
   
SpawnedVehicle[playerid] = CreateVehicle(...);
Important! Don't forgot to reset the variable and remove the vehicle after the player leaves the server.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(IsValidVehicle(SpawnedVehicle[playerid]))
        DestroyVehicle(SpawnedVehicle[playerid]);
       
    SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
    return 1;
}
The function IsValidVehicle is not defined in a_samp include, because of that don't forgot to add.

pawn Код:
native IsValidVehicle(vehicleid);
Top of your script.
umm i don't understand the part
pawn Код:
SpawnedVehicle[playerid] = CreateVehicle(...);
what should i put in the (...) ?
Reply
#4

bump
Reply
#5

CreateVehicle(520, Float,Float:y,Float:z, Float:Angle, 0, 1, Float:timerespawn);

https://sampwiki.blast.hk/wiki/CreateVehicle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)