CreateVehicle & OnVehicleDeath
#1

I am looking to prevent a vehicle created with CreateVehicle from respawning after death

is it as simple as using this to create

Код:
vehiclename = CreateVehicle(veh, xpos, ypos, zpos, angle, -1, -1);
and this to destroy?

Код:
OnVehicleDeath(vehicleid, killerid)
{
DestroyVehicle(vehiclename);
}
Reply
#2

Use this instead (at OnVehicleDeath callback):
pawn Код:
if(vehicleid == vehiclename) DestroyVehicle(vehiclename);
Reply
#3

ok this is where i have a slight problem.

will it delete ALL reference to vehiclename

ie if i created 10 vehicles using the one script, would it remove them all? and would it be player specific or global?
Reply
#4

I'm afraid i don't understand you. You can assign only one vehicle to the vehiclename variable, so if you do it like this:
pawn Код:
public OnGameModeInit()
{
  vehiclename = CreateVehicle(veh, xpos, ypos, zpos, angle, -1, -1); // ID 1.
  vehiclename = CreateVehicle(veh, xpos, ypos, zpos, angle, -1, -1); // ID 2.
  vehiclename = CreateVehicle(veh, xpos, ypos, zpos, angle, -1, -1); // ID 3.
  return true;
}
then the vehiclename will hold the ID of the last assigned vehicle (in this case it will be ID 3).
Reply
#5

im doing it like this:

Код:
if(strcmp(cmd, "/rtrain", true) == 0) {

playercash = GetPlayerMoney(playerid);

      new Float:xpos;
      new Float:ypos;
      new Float:zpos;

      GetPlayerPos(playerid, Float:xpos, Float:ypos, Float:zpos);

      if(playercash > 1400) {
      CreateVehicle(515, xpos, ypos+4, zpos, 90, -1, -1, -1);
      GivePlayerMoney(playerid, -1400);
      }
      else
      {
      SendClientMessage(playerid, 0xFFFFFFAA, "You need more money.");
      }
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)