mjau Posted March 29, 2011 Share Posted March 29, 2011 Now i have gotten a bit into scripting bur i still wonders how and what commands should i use to make a script wich you can lock cars to accounts? like in saes if you donate you get a car locked to your account if someone could tell me the comands i should use i will be happy becas many people in my server want a car LOL Link to comment
proracer Posted March 29, 2011 Share Posted March 29, 2011 You can use: https://wiki.multitheftauto.com/wiki/SetAccountData or with xml or sql. But setAccountData is easiest by far now. Link to comment
mjau Posted March 29, 2011 Author Share Posted March 29, 2011 EXAMPLE i want to give somone a sultan but not every sultan ingame how do i do that Link to comment
Castillo Posted March 30, 2011 Share Posted March 30, 2011 Well, you could create a vehicle and then set an element data on it, like "Owner", "Solidsnake14", and then when he tryies to enter the vehicle, if the account name is equal to "Owner" data from the vehicle, he will able to drive it, else it will output some message. functions required for this: createVehicle setElementData getElementData getPlayerAccount getAccountName getAccountData cancelEvent() - Required to cancel the player from entering the vehicle. events required for this: onVehicleStartEnter Good luck. Link to comment
mjau Posted April 5, 2011 Author Share Posted April 5, 2011 Ftw is wrong with this im still a noob LOL function lockcar() local x = -682.4951171875 local y = 952.8115234375 local z = 12.1328125 createVehicle(source, x, y, z) setElementData(owner "kimmis9") end addEventHandler("onClientResourceStart", getRootElement(), lockcar] Link to comment
proracer Posted April 5, 2011 Share Posted April 5, 2011 Try this. function lockcar ( ) local x = -682.4951171875 local y = 952.8115234375 local z = 12.1328125 createVehicle ( 432, x, y, z ) setElementData ( getLocalPlayer(), 'kimmis9' ) end addEventHandler ( 'onClientResourceStart', resourceRoot, lockcar ) Link to comment
Castillo Posted April 5, 2011 Share Posted April 5, 2011 Omg, proracer, i can't really understand how you did such thing... function lockcar ( ) local x = -682.4951171875 local y = 952.8115234375 local z = 12.1328125 myVehicle = createVehicle ( 432, x, y, z ) setElementData ( myVehicle, "owner", 'kimmis9' ) end addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), lockcar ) Link to comment
proracer Posted April 5, 2011 Share Posted April 5, 2011 Sorry .. I wrote it too fast. Link to comment
Castillo Posted April 5, 2011 Share Posted April 5, 2011 Proracer, you ever say the same Link to comment
qaisjp Posted April 6, 2011 Share Posted April 6, 2011 function lockcar ( ) local x = -682.4951171875 local y = 952.8115234375 local z = 12.1328125 myVehicle = createVehicle ( 432, x, y, z ) setElementData ( myVehicle, "owner", 'kimmis9' ) end addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), lockcar ) function lockca2 (veh ) if getElementData(veh, "owner") ~= getAccountName(getPlayerAccount(source)) then cancelEvent() end end addEventHandler ( 'onVehicleEnter', getRootElement(), lockca2 ) You could also just automatically lock the doors (client side) Link to comment
Castillo Posted April 6, 2011 Share Posted April 6, 2011 Qais, the point was to let him learn . Link to comment
mjau Posted April 8, 2011 Author Share Posted April 8, 2011 still dont work the vehicle doesent appear Link to comment
proracer Posted April 8, 2011 Share Posted April 8, 2011 Probably because you have to be at those co-ordinates, try this: function lockcar ( ) local x,y,z = getElementPosition(getLocalPlayer()) myVehicle = createVehicle ( 432, x, y+2, z ) setElementData ( myVehicle, "owner", 'kimmis9' ) end addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), lockcar ) Link to comment
mjau Posted April 8, 2011 Author Share Posted April 8, 2011 nahh dont know where to put the cordinates ? Link to comment
Castillo Posted April 8, 2011 Share Posted April 8, 2011 (edited) vehicle = createVehicle ( 411, -682.4951171875, 952.8115234375, 12.1328125 ) setElementData(vehicle, "owner", "kimmis9") function enterOwnedVehicle ( player, seat, jacked ) if getElementData(source, "owner") and getElementData(source, "owner" ) ~= getPlayerName(player) then outputChatBox ( "Vehicle owner: "..tostring(getElementData(source, "owner" )), player, 255, 0, 0 ) cancelEvent() end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterOwnedVehicle ) This should work (not tested) it is server-side btw. Edited April 8, 2011 by Guest Link to comment
mjau Posted April 8, 2011 Author Share Posted April 8, 2011 when i debug it it says ) expected near then Link to comment
Castillo Posted April 8, 2011 Share Posted April 8, 2011 My bad, i forgot something, try it now. Link to comment
qaisjp Posted April 12, 2011 Share Posted April 12, 2011 Qais, the point was to let him learn . Well, I just gave him a little more boost 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