Destroy
#1

Hello Guys
Guys i want know somthings When im Spawn Vehicle /v
i Want the old Vehicle Destroy
Reply
#2

Quote:
Originally Posted by Desha1
Посмотреть сообщение
Hello Guys
Guys i want know somthings When im Spawn Vehicle /v
i Want the old Vehicle Destroy
you would have to save that vehicle id somewhere
if you want the old veh. to be destroyed when you spawn a new one.

lets say we have a small cmd to spawn some cars
we also have 1 var
pawn Код:
new myVeh[MAX_PLAYERS];
if we want this to work, we have to
write the vehicle id of the car we spawned into "myVeh"
and also check if theres already a id so we can destroy the old one.
pawn Код:
//inside that cmd:
if(myVeh[playerid]) DestroyVehicle(myVeh[playerid]);
myVeh[playerid] = CreateVehicle(//and so on...
//...
it first checks if there's already a vehicle id and if there is, destroy it
and then create the new vehicle.
like this, the old one will always be destroyed once you spawn a new one
Reply
#3

PHP код:
new vehicle[MAX_PLAYERS]; 
PHP код:
 public OnPlayerCommandText(playeridcmdtext)
{
   if(!
IsPlayerAdmin....// Some checks
 
   
Destroyveh(vehicle[playerid]);
   
vehicle[playerid]=CreateVehicle(//...........
   
return 1;

Reply
#4

i Can Spawn 50000 Vehicle not fixed
this my full code spawn vehicle
PHP код:
CMD:v(playeridparams[])
{
if(
PlayerInfo[playerid][pRank] >= && PlayerInfo[playerid][pRank] <= 8)
{
        new 
Vehicle[50];
        if(!
sscanf(params"s[50]"Vehicle))
        {
                if(
Myveh[playerid]) DestroyVehicle(Myveh[playerid]);
                new 
string[128], Float:Pos[4];
                
GetPlayerPos(playeridPos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playeridPos[3]);
                new 
veh GetVehicleModelID(Vehicle);
                if(
veh 400 || veh 611) return SendClientMessage(playeridCOLOR_RED"This is not a valid vehicle name! Please try again ");
                if(
IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
                
GetXYInFrontOfPlayer(playeridPos[0], Pos[1], 5);
                new 
PVeh CreateVehicle(vehPos[0], Pos[1], Pos[2], Pos[3]+90, -1, -1, -1);
                
LinkVehicleToInterior(PVehGetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVehGetPlayerVirtualWorld(playerid));
                
format(stringsizeof string"You spawned a %s. ID: %i. "aVehicleNames[veh 400], veh);
                
SendClientMessage(playeridCOLOR_GREENstring);
        }
        } else return 
SendClientMessage(playeridCOLOR_LIGHTGREEN"Usage: /v [vehiclename] ");
return 
1;

Reply
#5

Quote:
Originally Posted by Desha1
Посмотреть сообщение
i Can Spawn 50000 Vehicle not fixed
this my full code spawn vehicle
PHP код:
CMD:v(playeridparams[])
{
if(
PlayerInfo[playerid][pRank] >= && PlayerInfo[playerid][pRank] <= 8)
{
        new 
Vehicle[50];
        if(!
sscanf(params"s[50]"Vehicle))
        {
                if(
Myveh[playerid]) DestroyVehicle(Myveh[playerid]);
                new 
string[128], Float:Pos[4];
                
GetPlayerPos(playeridPos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playeridPos[3]);
                new 
veh GetVehicleModelID(Vehicle);
                if(
veh 400 || veh 611) return SendClientMessage(playeridCOLOR_RED"This is not a valid vehicle name! Please try again ");
                if(
IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
                
GetXYInFrontOfPlayer(playeridPos[0], Pos[1], 5);
                new 
PVeh CreateVehicle(vehPos[0], Pos[1], Pos[2], Pos[3]+90, -1, -1, -1);
                
LinkVehicleToInterior(PVehGetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVehGetPlayerVirtualWorld(playerid));
                
format(stringsizeof string"You spawned a %s. ID: %i. "aVehicleNames[veh 400], veh);
                
SendClientMessage(playeridCOLOR_GREENstring);
        }
        } else return 
SendClientMessage(playeridCOLOR_LIGHTGREEN"Usage: /v [vehiclename] ");
return 
1;

it appears that you did not read correctly.
this line:
pawn Код:
new PVeh = CreateVehicle(veh, Pos[0], Pos[1], Pos[2], Pos[3]+90, -1, -1, -1);
is wrong, you have to write the vehicle id in "myVeh" so that we can destroy it later on
just as said before
Quote:
Originally Posted by CutX
Посмотреть сообщение
pawn Код:
//inside that cmd:
if(myVeh[playerid]) DestroyVehicle(myVeh[playerid]);
myVeh[playerid] = CreateVehicle(//and so on...
//...
of course nothing changes if you never ever actually write something
to "myVeh" that should be obvious.
Reply
#6

i dont need to change my cmd
i want only add i told u it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)