Andres99907 Posted April 7, 2019 Share Posted April 7, 2019 (edited) This is the script: function check ( player, seat, jacked ) if getElementData(source, "privado") then if getElementData(source, "dueño") == getAccountName(getPlayerAccount(player)) then else cancelEvent() outputChatBox("Este vehículo no es tuyo.", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), check ) function adueñar(playerSource, player, cmd, who) local who = getPlayerName(playerSource), playerSource(who) local co = getPedOccupiedVehicle(who) setElementData(co, "privado", true) setElementData(co, "dueño", getPlayerName(who)) outputChatBox("Este auto ahora es de:"..getPlayerName(who), player) end addEventHandler ( "onVehicleEnter", getRootElement(), adueñar ) the script makes that when a player gets into a car it is saved in his account so no other can use it, the script needs to get the player's name, but I think that in a server-type script it is impossible :(, I have tried everything and nothing has worked... Help :C the script works when you change "addEventHandler" to "addCommandHandler" but, i want everything to be automatic. Edited April 7, 2019 by Andres99907 Link to comment
Overkillz Posted April 7, 2019 Share Posted April 7, 2019 function check ( player, seat, jacked ) if getElementData(source, "privado") then if getElementData(source, "owner") ~= getAccountName(getPlayerAccount(player)) then cancelEvent() outputChatBox("Este vehículo no es tuyo.", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), check ) function aduenar(thePlayer, seat, jacket) local playerName = getPlayerName(thePlayer) local playerAccount = getAccountName(getPlayerAccount(thePlayer)) or false if playerAccount then setElementData(source,"privado",true) setElementData(source,"owner",playerAccount) outputChatBox("Este auto ahora es de: "..playerName, thePlayer) end end addEventHandler ( "onVehicleEnter", getRootElement(), aduenar ) Not tested. Anyways you should avoid using Ñ. Might it drops you an error while players are not logged (Guest) No lo he testeado, tal vez te salte un error en el check con un jugador q no este logeado. 1 Link to comment
Andres99907 Posted April 8, 2019 Author Share Posted April 8, 2019 It worked!! I really appreciate it very much 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