Enkanet Posted January 13, 2015 Share Posted January 13, 2015 I want to lock a vehicle. I can lock but it only locks when I am inside it because of the: local vehicle = getPedOccupiedVehicle(Player) code. Any way to make it even if you aren't inside it? And, when I lock the vehicle inside, I still can get out without unlocking. Any way to fix this? Link to comment
Mizudori Posted January 13, 2015 Share Posted January 13, 2015 You need to save element of car in player element data. While creating car for player, or while first enter, or while player targeting the car. There is many possibilities. Those in lua are just examples of couple function that you can use to get car element. setElementData() onPlayerTarget() onVehicleEnter() onClientVehicleEnter() Or you can just setDataElement for car with owner serial, then loop through all cars searching for the right one with owner serial. Yep but this is less efficient way. For exiting you need to check if car is locked on onClientVehicleStartExit event if yes then cancelEvent() with information. onClientVehicleStartExit() cancelEvent Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 Okay, how can I save my player's location and set the vehicle owned by the player? Do I have to use MySQL or can I do it without MySQL? Link to comment
Mizudori Posted January 13, 2015 Share Posted January 13, 2015 mysql,sql,xml recommend mysql or sql, faster If you want to use mysql and sql you need to use serial of player to recognize the owner of car. Link to comment
Enkanet Posted January 13, 2015 Author Share Posted January 13, 2015 Use serial? MTA serial? Do you have skype? So we don't need to spam forum. Link to comment
Moderators Citizen Posted January 14, 2015 Moderators Share Posted January 14, 2015 Two brothers playing MTA on the same computer will have the same serial (even if they are not using the same user session) Link to comment
Enkanet Posted January 14, 2015 Author Share Posted January 14, 2015 Two brothers playing MTA on the same computer will have the same serial (even if they are not using the same user session) Yeah, so I guess I should use setElementData ? Maybe like, setElementData(theVehicle "owner") ? Or setAccountData or sth? I am going to use MySQL for this problems but I am new for MySQL Link to comment
Mizudori Posted January 14, 2015 Share Posted January 14, 2015 Two brothers playing MTA on the same computer will have the same serial (even if they are not using the same user session) Yeah, so I guess I should use setElementData ? Maybe like, setElementData(theVehicle "owner") ? Or setAccountData or sth? I am going to use MySQL for this problems but I am new for MySQL Well you can use setVehiclePlateText and getVehiclePlateText, then just add setElementData to owner of the car text-plate + serial, so you will avoid, doing it by nickname and what Citizen said. Link to comment
Mega9 Posted January 14, 2015 Share Posted January 14, 2015 You can define a lastVehicle variable on client-side using onClientVehicleEnter. And using a command handler on client-side, trigger a server event to lock the vehicle while passing the lastVehicle userdata. Didn't read carefully the rest of the replies. local lastVehicle function defineLastVehicle() lastVehicle = source end addEventHandler ("onClientVehicleEnter", root, defineLastVehicle) 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