CreateVehicle & OnVehicleDeath - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: CreateVehicle & OnVehicleDeath (
/showthread.php?tid=119032)
CreateVehicle & OnVehicleDeath -
adsy - 06.01.2010
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);
}
Re: CreateVehicle & OnVehicleDeath -
Correlli - 06.01.2010
Use this instead (at OnVehicleDeath callback):
pawn Код:
if(vehicleid == vehiclename) DestroyVehicle(vehiclename);
Re: CreateVehicle & OnVehicleDeath -
adsy - 06.01.2010
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?
Re: CreateVehicle & OnVehicleDeath -
Correlli - 06.01.2010
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).
Re: CreateVehicle & OnVehicleDeath -
adsy - 06.01.2010
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;
}