Dzsipszi Posted March 15, 2013 Share Posted March 15, 2013 Hello! I need some help. I wanna know how to make a bind system to this function. function enterVehicle ( source, seat, jacked ) local playercar = getPedOccupiedVehicle ( source ) if(seat == 0) then if (getElementData ( playercar, "owner" )) then if(getElementData ( playercar, "owner" ) ~= "Nobody" ) then if(getElementData ( playercar, "owner" ) == getPlayerName ( source )) then outputChatBox ("(( Ennek a járműnek a tulajdonosa: "..getElementData ( playercar, "owner" )..". ))",source, 185,86,185 ) end else local price = getElementData ( playercar, "price" ) triggerClientEvent ( source, "showBuyCar", source, price) toggleAllControls ( source, false, true, false ) return true end end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) bindKey -> J -> setengineState 1 if the car owner controll the car? Link to comment
TheIceman1 Posted March 15, 2013 Share Posted March 15, 2013 You mean this? function enterVehicle ( source, seat, jacked ) local playercar = getPedOccupiedVehicle ( source ) if(seat == 0) then if (getElementData ( playercar, "owner" )) then if(getElementData ( playercar, "owner" ) ~= "Nobody" ) then if(getElementData ( playercar, "owner" ) == getPlayerName ( source )) then outputChatBox ("(( Ennek a járműnek a tulajdonosa: "..getElementData ( playercar, "owner" )..". ))",source, 185,86,185 ) end else local price = getElementData ( playercar, "price" ) triggerClientEvent ( source, "showBuyCar", source, price) toggleAllControls ( source, false, true, false ) return true end end end end bindKey ( "j", "down", enterVehicle ) Link to comment
Dzsipszi Posted March 15, 2013 Author Share Posted March 15, 2013 No, i wanna start the engine if i am the car owner, else the engine don't start. Link to comment
TheIceman1 Posted March 15, 2013 Share Posted March 15, 2013 This? function enterVehicle ( source, seat, jacked ) local playercar = getPedOccupiedVehicle ( source ) local player = getVehicleController ( playercar ) if(seat == 0) then if (getElementData ( player, "owner" )) then if(getElementData ( playercar, "owner" ) ~= "Nobody" ) then if(getElementData ( playercar, "owner" ) == getPlayerName ( source )) then outputChatBox ("(( Ennek a járműnek a tulajdonosa: "..getElementData ( player, "owner" )..". ))",source, 185,86,185 ) end else local price = getElementData ( playercar, "price" ) triggerClientEvent ( source, "showBuyCar", source, price) toggleAllControls ( source, false, true, false ) return true end end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) Link to comment
Dzsipszi Posted March 15, 2013 Author Share Posted March 15, 2013 Nope I try something like this, but i always failed | Line:6 fail function toggleVehicleEngine(source) local vehicle = getPedOccupiedVehicle(source) if vehicle then local control = getVehicleController(vehicle) if control == source then if player own the car then local state = getVehicleEngineState(vehicle) if state == false then setVehicleEngineState(vehicle, true) setElementData(vehicle, "vehicle.engine", 1) else setVehicleEngineState(vehicle, false) setElementData(vehicle, "vehicle.engine", 0) end else outputChatBox("NO KEY.", source, 255, 0, 0, false) end end end end bindKey ( "j", "down", toggleVehicleEngine ) Link to comment
PaiN^ Posted March 15, 2013 Share Posted March 15, 2013 How do you set The element data ' owner' ? Link to comment
Dzsipszi Posted March 15, 2013 Author Share Posted March 15, 2013 local owner = xmlNodeGetAttribute (v,"owner") Link to comment
PaiN^ Posted March 15, 2013 Share Posted March 15, 2013 And you want the car engine to start when the owner presses 'j' ? Link to comment
Jaysds1 Posted March 15, 2013 Share Posted March 15, 2013 try this: function enterVehicle ( source, seat, jacked ) local playercar = getPedOccupiedVehicle ( source ) local vOwner = getElementData ( playercar, "owner" ) if seat ~= 0 then return end if vOwner and vOwner ~= "Nobody" then if vOwner == getPlayerName ( source ) then outputChatBox ("(( Ennek a járműnek a tulajdonosa: "..vOwner..". ))",source, 185,86,185 ) bindKey(source,"j","down",function(_,_,_,curVeh) setVehicleEngineState(curVeh,true) end,playercar) end else local price = getElementData ( playercar, "price" ) triggerClientEvent ( source, "showBuyCar", source, price) toggleAllControls ( source, false, true, false ) end end addEventHandler ( "onVehicleEnter",root, enterVehicle ) Link to comment
Dzsipszi Posted March 15, 2013 Author Share Posted March 15, 2013 Not working... but i solved the problem. thank you all! 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