Flaqko Posted February 24, 2018 Share Posted February 24, 2018 is there a way to add more parked cars with a lua script? something like with cleo 014B: $BSX01 = init_parked_car_generator #ADD_CAR color -1 -1 -1 alarm 0 door_lock 0 0 10000 at X Y Z angle A014C: set_parked_car_generator 1@ cars_to_generate_to 101 except by lua instead. Please. any help will very much be appreciated! Link to comment
ShayF2 Posted February 24, 2018 Share Posted February 24, 2018 (edited) local parked = {} function parkedCar(player,seat,owner) if source and player and seat and owner then if seat == 0 then if not player == owner then cancelEvent() outputChatBox('You cannot enter this vehicle, it is parked by '..getPlayerName(owner),player,255,0,0) outputChatBox(getPlayerName(player)..' has tried to get access to your parked vehicle.',owner,255,0,0) end end end end setTimer(function() for i=1,#parked do if parked[i].park then parked[i].event = addEventHandler('onVehicleStartEnter',parked[i].vehicle,parkedCar,parked[i].vehicle,parked[i].owner) setElementFrozen(parked[i].vehicle,true) else parked[i].event = removeEventHandler('onVehicleStartEnter',parked[i].vehicle,parkedCar) setElementFrozen(parked[i].vehicle,false) end end end,1000,0) addCommandHandler('parkcar',function(player,cmd) local vehicle = getPedOccupiedVehicle(player) if vehicle then local driver = getVehicleOccupant(vehicle) if driver == player then local self = {} self.owner = player self.vehicle = vehicle self.park = true table.insert(parked,self) end end end) addCommandHandler('unparkcar',function(player,cmd) local vehicle = getPedOccupiedVehicle(player) if vehicle then local driver = getVehicleOccupant(vehicle) if driver == player then for i=1,#parked do if parked[i].vehicle == vehicle then parked[i].park = false end end end end end) Something like that idk. This is untested code and may need modifications, good luck. Edited February 24, 2018 by ShayF Link to comment
MTA Anti-Cheat Team Dutchman101 Posted February 24, 2018 MTA Anti-Cheat Team Share Posted February 24, 2018 He probably means just vehicles like they are spawned and neatly parked in GTA's streets. You can use https://wiki.multitheftauto.com/wiki/SpawnVehicle and place cars at the location (coordinates) you wish, you could attach that function to a resource that spawns all vehicles defined, when the resource starts. The coordinates would be chosen to make it look like GTA spawned them there (on sidewalks, in similar parking spots) as that's probably what you want. @Flaqko 1 Link to comment
Flaqko Posted February 25, 2018 Author Share Posted February 25, 2018 6 hours ago, Dutchman101 said: He probably means just vehicles like they are spawned and neatly parked in GTA's streets. You can use https://wiki.multitheftauto.com/wiki/SpawnVehicle and place cars at the location (coordinates) you wish, you could attach that function to a resource that spawns all vehicles defined, when the resource starts. The coordinates would be chosen to make it look like GTA spawned them there (on sidewalks, in similar parking spots) as that's probably what you want. @Flaqko yes that is exactly what i want! I don't understand what you mean by attach it to a resource. So the recourse is like main() or what? Is there an actual tutorial anywhere? With cleo this was easy because all i had to do was copy and paste that cleo script and changed the vehicles and coordinates. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now