Lock Commands
#1

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.
Reply
#2

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".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)