/adminveh - 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: /adminveh (
/showthread.php?tid=644120)
/adminveh -
Maky184 - 04.11.2017
How to make it when a player writes /adminveh if he has already created a vehicle to clear it?
Re: /adminveh -
Skimmer - 04.11.2017
You can create a variable for each player which saves the last ID of vehicle that has been created by him.
Код:
new LastVehicleID[MAX_PLAYERS];
Reset and delete it on join and on leave.
Код:
public OnPlayerConnect(playerid)
{
LastVehicleID[playerid] = INVALID_VEHICLE_ID;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(LastVehicleID[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(LastVehicleID[playerid]);
LastVehicleID[playerid] = INVALID_VEHICLE_ID;
return 1;
}
And when you spawn a new vehicle just check whether the LastVehicleID is valid or not.
Код:
if(LastVehicleID[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(LastVehicleID[playerid]);
Don't forget to assign the ID of the new vehicle after it's spawned.
Код:
LastVehicleID[playerid] = CreateVehicle(...);
Re: /adminveh -
Maky184 - 04.11.2017
Tnx