mjau Posted March 29, 2011 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
proracer Posted March 29, 2011 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.
mjau Posted March 29, 2011 Author Posted March 29, 2011 EXAMPLE i want to give somone a sultan but not every sultan ingame how do i do that
Castillo Posted March 30, 2011 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.
mjau Posted April 5, 2011 Author 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]
proracer Posted April 5, 2011 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 )
Castillo Posted April 5, 2011 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 )
MTA Team qaisjp Posted April 6, 2011 MTA Team 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)
proracer Posted April 8, 2011 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 )
Castillo Posted April 8, 2011 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
MTA Team qaisjp Posted April 12, 2011 MTA Team Posted April 12, 2011 Qais, the point was to let him learn . Well, I just gave him a little more boost
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