SA-MP Forums Archive
Help with Removing Spawned 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: Help with Removing Spawned Vehicle (/showthread.php?tid=549030)



Help with Removing Spawned Vehicle - Zenonz - 04.12.2014

I created a command for players to spawn vehicles, Now i would like to edit the command so that it deletes the previous vehicle spawned by a person when he spawns a new vehicle. Please dictate me as to how i can achieve this.


Re: Help with Removing Spawned Vehicle - CoaPsyFactor - 04.12.2014

pawn Код:
new PlayerSpawnedVehicles[MAX_PLAYERS];

public OnPlayerConnect(playerid) {
    PlayerSpawnedVehicles[playerid] = -1;
}

public OnPlayerDisconnect(playerid, reason) {
    if (PlayerSpawnedVehicles[playerid] != -1) {
        DestroyVehicle(PlayerSpawnedVehicles[playerid]);
    }
}

CMD:spawncar(playerid, params[]) {
    if (PlayerSpawnedVehicles[playerid] != -1) {
        DestroyVehicle(PlayerSpawnedVehicles[playerid]);
    }

    // your code

    PlayerSpawnedVehicles[playerid] = CreateVehicle(...);
}



Re: Help with Removing Spawned Vehicle - Zenonz - 04.12.2014

Works Like a charm, i am grateful to you CoaPsyFactor. Plus i gave you rep


Re: Help with Removing Spawned Vehicle - CoaPsyFactor - 04.12.2014

I'm glad I helped