raynner Posted March 3, 2017 Share Posted March 3, 2017 (edited) function PlayerHitInMarkerLeaveBox(hitElement) if (isElement(hitElement) and getElementType(hitElement) == "player") then if TbPlEmp[hitElement] and source == TbPlEmp[hitElement]["marker"] then if TbPlEmp[hitElement]["box"] and isElement(TbPlEmp[hitElement]["box"]) and isElementWithinMarker(TbPlEmp[hitElement]["box"],source) then outputChatBox("#FFAA00||#00FF00 ✔ #FFAA00||#00FF00 ok !",hitElement,255,255,255,true) else outputChatBox("#FFAA00||#FF0000 ✘ #FFAA00||#FF0000 error !",hitElement,255,255,255,true) end end end end addEventHandler("onMarkerHit",root,PlayerHitInMarkerLeaveBox) My problem here is, everything works fine excerpt box check in marker does anyone have any idea why? - Always returns false Edited March 3, 2017 by raynner correction in text Link to comment
Moderators Citizen Posted March 3, 2017 Moderators Share Posted March 3, 2017 What's the purpose of TbPlEmp[hitElement]["marker"] and how do you create it ? Link to comment
raynner Posted March 4, 2017 Author Share Posted March 4, 2017 (edited) 13 hours ago, Citizen said: What's the purpose of TbPlEmp[hitElement]["marker"] and how do you create it ? TbPlEmp = {} function StartJobEmpilhadeiraForPlayer() --> verifica se não há uma tabela e cria uma no nome do player ! if not(TbPlEmp[source]) then TbPlEmp[source] = {} end --> Verifica se o player tem um veículo e destroy se houver ! if TbPlEmp[source]["veh"] then destroyElement(TbPlEmp[source]["veh"]) TbPlEmp[source]["veh"] = nil end TbPlEmp[source]["veh"] = createVehicle(530,2799,-2401,13,0,0,93) warpPedIntoVehicle(source,TbPlEmp[source]["veh"]) TbPlEmp[source]["box"] = createObject(1558,2779.2048,-2485.4523,13.1577,0,0,0,false) TbPlEmp[source]["marker"] = createMarker(2724,-2398,12,"cylinder",3,0,255,150,255,source) end addEvent("GiveItensForJobEmpilhadeira",true) addEventHandler("GiveItensForJobEmpilhadeira",root,StartJobEmpilhadeiraForPlayer) function PlayerHitInMarkerLeaveBox(hitElement) if (isElement(hitElement) and getElementType(hitElement) == "player") then if TbPlEmp[hitElement] and source == TbPlEmp[hitElement]["marker"] then if TbPlEmp[hitElement]["box"] and isElement(TbPlEmp[hitElement]["box"]) and isElementWithinMarker(TbPlEmp[hitElement]["box"],source) then outputChatBox("#FFAA00||#00FF00 ✔ #FFAA00||#00FF00 ok !",hitElement,255,255,255,true) else outputChatBox("#FFAA00||#FF0000 ✘ #FFAA00||#FF0000 error !",hitElement,255,255,255,true) end end end end addEventHandler("onMarkerHit",root,PlayerHitInMarkerLeaveBox) Edited March 4, 2017 by raynner script .. Link to comment
MIKI785 Posted March 5, 2017 Share Posted March 5, 2017 Try this: TbPlEmp = {} function StartJobEmpilhadeiraForPlayer() --> verifica se não há uma tabela e cria uma no nome do player ! if not(TbPlEmp[source]) then TbPlEmp[source] = {} end --> Verifica se o player tem um veículo e destroy se houver ! if TbPlEmp[source]["veh"] then destroyElement(TbPlEmp[source]["veh"]) TbPlEmp[source]["veh"] = nil end TbPlEmp[source]["veh"] = createVehicle(530,2799,-2401,13,0,0,93) warpPedIntoVehicle(source,TbPlEmp[source]["veh"]) TbPlEmp[source]["box"] = createObject(1558,2779.2048,-2485.4523,13.1577,0,0,0,false) TbPlEmp[source]["marker"] = createMarker(2724,-2398,12,"cylinder",3,0,255,150,255,source) setElementPosition(TbPlEmp[source]["box"], 1558,2779.2048,-2485.4523) end addEvent("GiveItensForJobEmpilhadeira",true) addEventHandler("GiveItensForJobEmpilhadeira",root,StartJobEmpilhadeiraForPlayer) function PlayerHitInMarkerLeaveBox(hitElement) if (isElement(hitElement) and getElementType(hitElement) == "player") then if TbPlEmp[hitElement] and source == TbPlEmp[hitElement]["marker"] then if TbPlEmp[hitElement]["box"] and isElement(TbPlEmp[hitElement]["box"]) and isElementWithinMarker(TbPlEmp[hitElement]["box"],source) then outputChatBox("#FFAA00||#00FF00 ✔ #FFAA00||#00FF00 ok !",hitElement,255,255,255,true) else outputChatBox("#FFAA00||#FF0000 ✘ #FFAA00||#FF0000 error !",hitElement,255,255,255,true) end end end end addEventHandler("onMarkerHit",root,PlayerHitInMarkerLeaveBox) All I did was set the box's position to the same position, you might think that it makes no sense but it should work. Link to comment
raynner Posted March 5, 2017 Author Share Posted March 5, 2017 9 hours ago, MIKI785 said: All I did was set the box's position to the same position, you might think that it makes no sense but it should work. note : not is postion (1558,2779.2048,-2485.4523) is correct: (2779.2048,-2485.4523,13.1577) And it did not work Link to comment
Ayush Rathore Posted March 6, 2017 Share Posted March 6, 2017 (edited) TbPlEmp = {} function StartJobEmpilhadeiraForPlayer(source) --> verifica se não há uma tabela e cria uma no nome do player ! if not(TbPlEmp[source]) then TbPlEmp[source] = {} end --> Verifica se o player tem um veículo e destroy se houver ! if TbPlEmp[source]["veh"] then destroyElement(TbPlEmp[source]["veh"]) TbPlEmp[source]["veh"] = nil end TbPlEmp[source]["veh"] = createVehicle(530,2799,-2401,13,0,0,93) warpPedIntoVehicle(source,TbPlEmp[source]["veh"]) TbPlEmp[source]["box"] = createObject(1558,2779,-2401,13.3,0,0,0,false) TbPlEmp[source]["marker"] = createMarker(2724,-2401,12,"cylinder",3,0,255,150,255,source) end addCommandHandler("cc",function() StartJobEmpilhadeiraForPlayer(getRandomPlayer()) end) function PlayerHitInMarkerLeaveBox(hitElement) if (isElement(hitElement) and getElementType(hitElement) == "player") then if TbPlEmp[hitElement] and source == TbPlEmp[hitElement]["marker"] then if TbPlEmp[hitElement]["box"] and isElement(TbPlEmp[hitElement]["box"]) then local x,y,z = getElementPosition(TbPlEmp[hitElement]["box"]) local x1,y1,z1 = getElementPosition(source) outputChatBox(getDistanceBetweenPoints3D ( x,y,z,x1,y1,z1 )) if getDistanceBetweenPoints3D ( x,y,z,x1,y1,z1 ) < 56 then outputChatBox("#FFAA00||#00FF00 ✔ #FFAA00||#00FF00 ok !",hitElement,255,255,255,true) else outputChatBox("#FFAA00||#FF0000 ✘ #FFAA00||#FF0000 error !",hitElement,255,255,255,true) end end end end end addEventHandler("onMarkerHit",root,PlayerHitInMarkerLeaveBox) this might work.When in-game type /cc to check change the positions of object as per your need Edited March 6, 2017 by Ayush Rathore Link to comment
raynner Posted March 6, 2017 Author Share Posted March 6, 2017 2 hours ago, Ayush Rathore said: this might work.When in-game type /cc to check change the positions of object as per your need I liked it more, it's still not correct because the player with or without box will always return true and I want it to really carry the box up to the marker! I could see from your output that the box position is not updated as it moves .. why does this happen? Link to comment
Ayush Rathore Posted March 8, 2017 Share Posted March 8, 2017 the only solution to your problem is attaching object to forklift as gta physics engine do not capture the event when forklift picks up an oject Link to comment
raynner Posted March 8, 2017 Author Share Posted March 8, 2017 11 minutes ago, Ayush Rathore said: the only solution to your problem is attaching object to forklift as gta physics engine do not capture the event when forklift picks up an oject I can not think of any way to do this! Any idea ? Link to comment
Ayush Rathore Posted March 8, 2017 Share Posted March 8, 2017 wait i will surely give you an idea Link to comment
raynner Posted March 8, 2017 Author Share Posted March 8, 2017 (edited) Resolved thanks to Ayush Rathore and all others for helping me. Edited March 8, 2017 by raynner 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