Lietuvis Posted August 11, 2014 Posted August 11, 2014 setElementData(veh, "owner", getPlayerName(source)) I set the element data. How do i getElementData exactly ? Edited..
Et-win Posted August 11, 2014 Posted August 11, 2014 local gData = getElementData(source, "owner") local gPlayerName = getPlayerName(source) if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then if (gPlayerName == gData) then --Do something else outputChatBox("You are not the owner.", source) end else outputChatBox("Error getting data or player name.", source) end
Lietuvis Posted August 11, 2014 Author Posted August 11, 2014 Error getting data or player name. Everytime sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) function sellVeh(source) local gData = getElementData(source, "owner") local gPlayerName = getPlayerName(source) if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then if (gPlayerName == gData) then outputChatBox("You are owner so bla bla", source) -- i will put more things later here else outputChatBox("You are not the owner.", source) end else outputChatBox("Error getting data or player name.", source) end end addEventHandler( 'onMarkerHit', sellMarker, sellVeh)
Et-win Posted August 11, 2014 Posted August 11, 2014 sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) function sellVeh(tElement) if (getElementType(tElement) == "player") then local gData = getElementData(tElement, "owner") local gPlayerName = getPlayerName(tElement) if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then if (gPlayerName == gData) then outputChatBox("You are owner so bla bla", tElement) -- i will put more things later here else outputChatBox("You are not the owner.", tElement) end else outputChatBox("Error getting data or player name.", tElement) end end addEventHandler( 'onMarkerHit', sellMarker, sellVeh)
Et-win Posted August 11, 2014 Posted August 11, 2014 Still same.. And you forgot end sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) function sellVeh(tElement) if (getElementType(tElement) == "player") then local gData = getElementData(tElement, "owner") outputChatBox(tostring(gData)) local gPlayerName = getPlayerName(tElement) if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then if (gPlayerName == gData) then outputChatBox("You are owner so bla bla", tElement) -- i will put more things later here else outputChatBox("You are not the owner.", tElement) end else outputChatBox("Error getting data or player name.", tElement) end end end addEventHandler( 'onMarkerHit', sellMarker, sellVeh) What does it output?
Lietuvis Posted August 11, 2014 Author Posted August 11, 2014 false Error getting data or player name.
Et-win Posted August 11, 2014 Posted August 11, 2014 Oops, sorry. I checked the data of the player and not of the vehicle. sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) function sellVeh(tElement) if (getElementType(tElement) == "player") then local gVehicle = getPedOccupiedVehicle(tElement) if (gVehicle ~= false) and (gVehicle ~= nil) then local gData = getElementData(gVehicle , "owner") outputChatBox(tostring(gData)) local gPlayerName = getPlayerName(tElement) if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then if (gPlayerName == gData) then outputChatBox("You are owner so bla bla", tElement) -- i will put more things later here else outputChatBox("You are not the owner.", tElement) end else outputChatBox("Error getting data or player name.", tElement) end end end end addEventHandler( 'onMarkerHit', sellMarker, sellVeh)
Lietuvis Posted August 11, 2014 Author Posted August 11, 2014 God the same again.. lol Might this will help: function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle if ( getElementData(source, "owner") and getPlayerName(player) ~= getElementData(source, "owner") ) then cancelEvent() outputChatBox ( "You dont have this vehicle keys..", player, 255, 255, 255, true ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle This works perfectly .. I'am trying to make a script to sell owned car i guess you understand that
Et-win Posted August 11, 2014 Posted August 11, 2014 Yes I understand. And yes. Are you sure you are setting the data correctly? Give the function or atleast the event+function line where you set the data.
Lietuvis Posted August 11, 2014 Author Posted August 11, 2014 Sure. function Buy1 () local money = getPlayerMoney(source) if (money > 5000) then takePlayerMoney(source,5000) local vehicleModel = 602 local x,y,z = getElementPosition(source) y = y + 10 z = z + 5 local veh = createVehicle(tonumber(vehicleModel),x,y,z) setElementData(veh, "owner", getPlayerName(source)) else outputChatBox ( "You need more cash bro..", source, 255, 255, 255, true ) end end addEvent("Car1",true) addEventHandler( "Car1", getRootElement(), Buy1 )
Et-win Posted August 11, 2014 Posted August 11, 2014 function Buy1 () local money = getPlayerMoney(source) if (money > 5000) then takePlayerMoney(source,5000) local vehicleModel = 602 local x,y,z = getElementPosition(source) y = y + 10 z = z + 5 local veh = createVehicle(tonumber(vehicleModel),x,y,z) local lol = setElementData(veh, "owner", getPlayerName(source)) outputChatBox(tostring(lol)) else outputChatBox ( "You need more cash bro..", source, 255, 255, 255, true ) end end addEvent("Car1",true) addEventHandler( "Car1", getRootElement(), Buy1 ) What does it output? If it output's 'true', then I give up. x:
Lietuvis Posted August 11, 2014 Author Posted August 11, 2014 Kinda interesting.. When i bought car it output true but when i come to marker it writes that im owner hehe wtf Works i guess
Lietuvis Posted August 11, 2014 Author Posted August 11, 2014 Tested everything and it looks working fine now -.- Thanks.
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