SA-MP Forums Archive
/veh (vehicle spawner admin cmd) won't destroy vehicles - 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: /veh (vehicle spawner admin cmd) won't destroy vehicles (/showthread.php?tid=143825)



/veh (vehicle spawner admin cmd) won't destroy vehicles - Andy_McKinley - 24.04.2010

This vehicle spawn (admin cmd) won't destroy vehicles but respawn vehicles at the spawn pos... How can I destroy them when actually respawning?

pawn Код:
dcmd_veh(playerid, params[])
{
    new vehicleid, color[2], myString[128];
   
    if(pInfo[playerid][pAdmin] < 4) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"ddd",vehicleid,color[0],color[1])) return SystemMessage(playerid, "USAGE: /veh [vehicleid] [color1] [color2]");
    else
    {
      if(vehicleid < 400 || vehicleid > 611) return SystemMessage(playerid, "Please enter a valid vehicle ID (400 - 611).");
        if((color[0] < 0 || color[0] > 128) || (color[1] < 0 || color[1] > 128)) return SystemMessage(playerid, "Please enter valid color IDs (0-128).");

        new Float:PosX, Float:PosY, Float:PosZ, Float:Angle;
        GetPlayerPos(playerid, PosX, PosY, PosZ);
        GetPlayerFacingAngle(playerid, Angle);
       
        AddStaticVehicle(vehicleid, PosX+1, PosY+1, PosZ, Angle, color[0], color[1]);

        format(myString, sizeof(myString), "You have spawned vehicle id %i.",vehicleid);
        SystemMessage(playerid, myString);
    }
    return 1;
}



Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - DeathOnaStick - 24.04.2010

Use CreateVehicle instead of AddStaticVehicle, because you can destroy them with DestroyVehicle afterwards.
You wanna do it like this?

pawn Код:
//OnPlayerConnect
if(pInfo[playerid][pCarid]!=-1)DestroyVehicle(pInfo[playerid][pCarid]);
pInfo[playerid][Carid]=-1;

//In the command:
if(pInfo[playerid][pCarid]!=-1)DestroyVehicle(pInfo[playerid][pCarid]);
CreateVehicle(vehicleid, PosX+1, PosY+1, PosZ, Angle, color[0], color[1], respawndelay);
You can delete it over OnVehicleSpawn (i guess... maybe over OnVehicleDeath, too?! Never tried.)

Don't forget to put the respawndelay in your sscanf code and putting into pInfo. Enjoy.





Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - Andy_McKinley - 24.04.2010

No, that's not what I want. Just when I spawn a car. For example: /veh 598 0 3 and I drive a little bit and leave the vehicle, then after 120 seconds or less the car destroys and not respawn at the pos I spawned it.


Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - Miguel - 24.04.2010

Search and bit and... http://forum.sa-mp.com/index.php?topic=127129.0


Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - Andy_McKinley - 25.04.2010

Can someone correct my script with after 50-120 seconds vehicle will be destroyed because the one I have respawns the vehicle at the pos I spawned it.

Quote:
Originally Posted by SAWC™
I want to use my own?


Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - woot - 25.04.2010

pawn Код:
forward DestroyVehicleEx(iVehicleID);
public DestroyVehicleEx(iVehicleID)
{
    DestroyVehicle(iVehicleID);
}

dcmd_veh(playerid, params[])
{
    new vehicleid, color[2], myString[128];

    if(pInfo[playerid][pAdmin] < 4) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"ddd",vehicleid,color[0],color[1])) return SystemMessage(playerid, "USAGE: /veh [vehicleid] [color1] [color2]");
    else
    {
      if(vehicleid < 400 || vehicleid > 611) return SystemMessage(playerid, "Please enter a valid vehicle ID (400 - 611).");
        if((color[0] < 0 || color[0] > 128) || (color[1] < 0 || color[1] > 128)) return SystemMessage(playerid, "Please enter valid color IDs (0-128).");

        new Float:PosX, Float:PosY, Float:PosZ, Float:Angle;
        GetPlayerPos(playerid, PosX, PosY, PosZ);
        GetPlayerFacingAngle(playerid, Angle);

        new iID = CreateVehicle(vehicleid, PosX+1, PosY+1, PosZ, Angle, color[0], color[1], 120);
        SetTimerEx("DestroyVehicleEx", 50000 /* 50 seconds */, false, "d", iID);

        format(myString, sizeof(myString), "You have spawned vehicle id %i.",vehicleid);
        SystemMessage(playerid, myString);
    }
    return 1;
}



Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - TouR - 25.04.2010

or you could just /apark it


Re: /veh (vehicle spawner admin cmd) won't destroy vehicles - Andy_McKinley - 25.04.2010

Quote:
Originally Posted by //exora
pawn Код:
forward DestroyVehicleEx(iVehicleID);
public DestroyVehicleEx(iVehicleID)
{
    DestroyVehicle(iVehicleID);
}

dcmd_veh(playerid, params[])
{
    new vehicleid, color[2], myString[128];

    if(pInfo[playerid][pAdmin] < 4) return SystemMessage(playerid, "You are not an Administrator with the required level.");
    if(sscanf(params,"ddd",vehicleid,color[0],color[1])) return SystemMessage(playerid, "USAGE: /veh [vehicleid] [color1] [color2]");
    else
    {
      if(vehicleid < 400 || vehicleid > 611) return SystemMessage(playerid, "Please enter a valid vehicle ID (400 - 611).");
        if((color[0] < 0 || color[0] > 128) || (color[1] < 0 || color[1] > 128)) return SystemMessage(playerid, "Please enter valid color IDs (0-128).");

        new Float:PosX, Float:PosY, Float:PosZ, Float:Angle;
        GetPlayerPos(playerid, PosX, PosY, PosZ);
        GetPlayerFacingAngle(playerid, Angle);

        new iID = CreateVehicle(vehicleid, PosX+1, PosY+1, PosZ, Angle, color[0], color[1], 120);
        SetTimerEx("DestroyVehicleEx", 50000 /* 50 seconds */, false, "d", iID);

        format(myString, sizeof(myString), "You have spawned vehicle id %i.",vehicleid);
        SystemMessage(playerid, myString);
    }
    return 1;
}
Thanks! This one works great! Although... It destroys after 50 seconds even when someone is in the vehicle...