SA-MP Forums Archive
Delete vehicle when you spawn another vehicle - 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)
+--- Thread: Delete vehicle when you spawn another vehicle (/showthread.php?tid=443747)



Delete vehicle when you spawn another vehicle - mickos - 13.06.2013

Hi,

I've a vehicle system in my server, but when I spawn a vehicle, and later spawn another vehicle, the previsious vehicle will stays there, so my question is... How can I remove the previsious vehicle when I spawn a another vehicle?

Thanks!


Re: Delete vehicle when you spawn another vehicle - IstuntmanI - 13.06.2013

Use variables, like:
pawn Код:
new PlayerVehicle[ MAX_PLAYERS ];

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if( !strcmp( cmdtext, "/spawncar" ) )
    {
        DestroyVehicle( PlayerVehicle[ playerid ] );
        PlayerVehicle[ playerid ] = CreateVehicle( ... );
        return 1;
    }
    return 1;
}

public OnPlayerDisconnect( playerid, reason )
{
    if( PlayerVehicle[ playerid ] )
    {
        DestroyVehicle( PlayerVehicle[ playerid ] );
        PlayerVehicle[ playerid ] = 0;
    }
    return 1;
}