Destroy -
Desha1 - 02.01.2015
Hello Guys
Guys i want know somthings When im Spawn Vehicle /v
i Want the old Vehicle Destroy
AW: Destroy -
CutX - 02.01.2015
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
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
Re: Destroy -
ATGOggy - 02.01.2015
PHP код:
new vehicle[MAX_PLAYERS];
PHP код:
public OnPlayerCommandText(playerid, cmdtext)
{
if(!IsPlayerAdmin....// Some checks
Destroyveh(vehicle[playerid]);
vehicle[playerid]=CreateVehicle(//...........
return 1;
}
Re: Destroy -
Desha1 - 02.01.2015
i Can Spawn 50000 Vehicle
not fixed
this my full code spawn vehicle
PHP код:
CMD:v(playerid, params[])
{
if(PlayerInfo[playerid][pRank] >= 2 && 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(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
new veh = GetVehicleModelID(Vehicle);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, COLOR_RED, "This is not a valid vehicle name! Please try again ");
if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
GetXYInFrontOfPlayer(playerid, Pos[0], Pos[1], 5);
new PVeh = CreateVehicle(veh, Pos[0], Pos[1], Pos[2], Pos[3]+90, -1, -1, -1);
LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
format(string, sizeof string, "You spawned a %s. ID: %i. ", aVehicleNames[veh - 400], veh);
SendClientMessage(playerid, COLOR_GREEN, string);
}
} else return SendClientMessage(playerid, COLOR_LIGHTGREEN, "Usage: /v [vehiclename] ");
return 1;
}
AW: Re: Destroy -
CutX - 02.01.2015
Quote:
Originally Posted by Desha1
i Can Spawn 50000 Vehicle not fixed
this my full code spawn vehicle
PHP код:
CMD:v(playerid, params[])
{
if(PlayerInfo[playerid][pRank] >= 2 && 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(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
new veh = GetVehicleModelID(Vehicle);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, COLOR_RED, "This is not a valid vehicle name! Please try again ");
if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
GetXYInFrontOfPlayer(playerid, Pos[0], Pos[1], 5);
new PVeh = CreateVehicle(veh, Pos[0], Pos[1], Pos[2], Pos[3]+90, -1, -1, -1);
LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
format(string, sizeof string, "You spawned a %s. ID: %i. ", aVehicleNames[veh - 400], veh);
SendClientMessage(playerid, COLOR_GREEN, string);
}
} else return SendClientMessage(playerid, COLOR_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.
Re: Destroy -
Desha1 - 02.01.2015
i dont need to change my cmd
i want only add i told u it