How do I stop vehicle from respawning period?
#1

Heres the script.

if(GetPlayerMoney(playerid) < 1000000)
{
SendClientMessage(playerid,red,"You don't have a million dollars!");
}
else
{

new Float: w, Float:y, Float:z;
GetPlayerPos(playerid,w,y,z);

CreateVehicle(432 , w, y+10, z+7,0, 0, 1,-1);



GivePlayerMoney(playerid,-1000000);
SendClientMessage(playerid,white,"You were also given free armor!");
SetPlayerArmour(playerid,100);
}


And the script works just fine, but I can't figure out how to tweak it so that the tank won't respawn after it is destroyed.
Reply
#2

use OnVehicleDeath public.

pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
    if(GetVehicleModel(vehicleid) == 432) DestroyVehicle(vehicleid);
    return 1;
}
or you can use flag variable in order to prevent destroying tanks that weren't created by this command

pawn Код:
new gTank[MAX_VEHICLES+1]; //must be global

...
if(GetPlayerMoney(playerid) < 1000000)
{
SendClientMessage(playerid,red,"You don't have a million dollars!");
}
else
{

new Float: w, Float:y, Float:z;
GetPlayerPos(playerid,w,y,z);

new vid = CreateVehicle(432 , w, y+10, z+7,0, 0, 1,-1);
gTank[vid] = 1;



GivePlayerMoney(playerid,-1000000);
SendClientMessage(playerid,white,"You were also given free armor!");
SetPlayerArmour(playerid,100);
}
...
public OnVehicleDeath(vehicleid, killerid)
{
    if(gTank[vehicleid])
    {
        DestroyVehicle(vehicleid);
        gTank[vehicleid] = 0;
    }
    return 1;
}
Reply
#3

Thanks man. Gave me everything I needed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)