Create Vehicle Help
#1

How can i make it so when they /hydra then after thay leave it it disappears after 2mins un-used instead of staying there untill restart,Any help??

Heres Code:


pawn Код:
if(strcmp("/hydra", cmdtext, true, 7) == 0)
        {
        if(gTeam[playerid] != CLASS_MERC) return SendClientMessage(playerid,RED,"[ATT]:Your Not A Mercenary!");

        if(PlayerInfo[playerid][FuelAmount] < 1000)
        {
        return SendClientMessage(playerid, RED, "[ATT]: You Dont Have Enough Fuel For This To Be Delivered!");
        }
        new Float:x, Float:y, Float:z, Float:az;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, az);
        CreateVehicle(520, x+5, y+5, z, az, -1, -1, 520);
        SendClientMessage(playerid, RED, "[ATT]: Special Aircraft Has Arrived! (Cost: 1000 Fuel To Deliver)");
        PlayerInfo[playerid][FuelAmount] = PlayerInfo[playerid][FuelAmount] -1000;
        return 1;
        }
Thanks In Advanced!
Reply
#2

pawn Код:
CreateVehicle(520, x+5, y+5, z, az, -1, -1, 60000);
Reply
#3

can u explain how that works plz :S
Reply
#4

Basically, there are 8 parameters when creating a vehicle using that function

pawn Код:
CreateVehicle(520, x+5, y+5, z, az, -1, -1, 600000);
// MODEL | X | Y | Z | ANGLE | COLOR 1 | COLOR 2 | RESPAWN TIME (Milliseconds) //
In your code, the Milliseconds were 520 - 520 Milliseconds = 0.52 Seconds, meaning the vehicle would respawn if empty for 0.52 seconds.

As we increased it to 600000, it's now 10 minutes respawn.
Reply
#5

Dude thats what i thought i dont want it to respawn at its location i want it to disappear after 2mins if it hasnt been used within 2 mins....Possible
Reply
#6

pawn Код:
new spawncar[MAX_PLAYERS]; // At the top of your script, anywhere under your includes.

        if(strcmp("/hydra", cmdtext, true, 7) == 0)
        {
        if(gTeam[playerid] != CLASS_MERC) return SendClientMessage(playerid,RED,"[ATT]:Your Not A Mercenary!");

        if(PlayerInfo[playerid][FuelAmount] < 1000)
        {
        return SendClientMessage(playerid, RED, "[ATT]: You Dont Have Enough Fuel For This To Be Delivered!");
        }
        new Float:x, Float:y, Float:z, Float:az;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, az);
        spawncar[playerid] = CreateVehicle(520, x+5, y+5, z, az, -1, -1, 6000000);
        SetTimerEx("DestroyCar",1000,1,"i",spawncar[playerid]);
        SendClientMessage(playerid, RED, "[ATT]: Special Aircraft Has Arrived! (Cost: 1000 Fuel To Deliver)");
        PlayerInfo[playerid][FuelAmount] = PlayerInfo[playerid][FuelAmount] -1000;
        return 1;
        }

// Bottom of your script

forward DestroyCar(vehicleid);
public DestroyCar(vehicleid)
{
    new destroy = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerInVehicle(i, vehicleid))
        {
            destroy++;
            if(destroy == 120000)
            {
                DestroyVehicle(vehicleid);
            }
        }
    }
    return 1;
}
I haven't tested it, but feel free to ask me if you encounter any problems.
Reply
#7

@Shadow™

Thanks dude complies but dont work :S

Any help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)