SA-MP Forums Archive
Lock Commands - 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: Lock Commands (/showthread.php?tid=166797)



Lock Commands - ScottCFR - 10.08.2010

Okay, I am working on lock commands. Though I wasn't sure how to go about it. I tried making a new VehInfo[MAX_VEHICLES][vInfo] so I could use an enum. But I thought that MAX_VEHICLES was a function. Can someone correct me or tell me what the value of MAX_VEHICLE should be?

Edit: My errors were with vehicleid.


Re: Lock Commands - [HUN]Jaki - 10.08.2010

MAX_VEHICLES is the maximum amount of the vehicles. (2000)
https://sampwiki.blast.hk/wiki/Limits

Any you can
if ("/lock"){
vehicle[GetPlayerVehicleID(playerid)]=playerid;
}
And at OnVehicleStreamIn, you have to
vehicle[vehicleid]!=-1 && vehicle[vehicleid]!=playerid, than it is locked. (SetVehicleParamsForPlayer(playerid, locked))

Of course you have to reset vehicle[playerid] to -1, when the player disconnects, at OnGameModeInit, you have to reset the whole array to -1 (with a loop).

OnVehicleStreamIn
SetVehicleParamsForPlayer

If every player can only have one locked vehicle, this version uses less memory:
vehicle[MAX_PLAYERS];
if ("/lock") vehicle[playerid]=GetPlayerVehicleID();
OnVehicleStreamIn: if (vehicle[i]==TheVehicleWeAreLookingFor) SetVehicleParamsForPlayer(playerid, locked); //It is locked by player "i".