HustraDev Posted September 5, 2014 Share Posted September 5, 2014 Hi all i'm working on new job script i have problem in this code : i made marker in a function and i want to add handler for ("onMarkerHit") but when i test it not working the code : addEvent("ib",true) addEventHandler("ib",root, function () marker1 = createmarker (...) end ) addEventHandler( "onMarkerHit", marker1, function() warpPedIntoVehicle ( client1, Vehicle) end ) Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 Hi alli'm working on new job script i have problem in this code : i made marker in a function and i want to add handler for ("onMarkerHit") but when i test it not working the code : addEvent("ib",true) addEventHandler("ib",root, function () marker1 = createmarker (...) end ) addEventHandler( "onMarkerHit", marker1, function() warpPedIntoVehicle ( client1, Vehicle) end ) Link to comment
./BlackBird# Posted September 5, 2014 Share Posted September 5, 2014 createmarker | | V createMarker Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 not working ! Link to comment
./BlackBird# Posted September 5, 2014 Share Posted September 5, 2014 addEvent("ib",true) addEventHandler("ib",root, function () marker1 = createMarker(...) addEventHandler( "onMarkerHit", marker1,onHit) end ) function onHit() if getElementType(source) == "player" then warpPedIntoVehicle ( source, Vehicle) end end Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 addEvent("ib",true) addEventHandler("ib",root, function () marker1 = createMarker(...) addEventHandler( "onMarkerHit", marker1,onHit) end ) function onHit() if getElementType(source) == "player" then warpPedIntoVehicle ( source, Vehicle) end end \not working\@_2 Link to comment
Anubhav Posted September 5, 2014 Share Posted September 5, 2014 addEvent("ib", true) addEventHandler("ib", root, function() marker1 = createMarker(...) addEventHandler("onMarkerHit", marker1, onHit, false) end ) function onHit(hitElement) if getElementType(hitElement) == "player" then warpPedIntoVehicle(hitElement, Vehicle) end end Link to comment
</Mr.Tn6eL> Posted September 5, 2014 Share Posted September 5, 2014 addEvent("ib",true) addEventHandler("ib",root, function () marker1 = createMarker(...) addEventHandler( "onMarkerHit", marker1,onHit) end ) function onHit() if getElementType(source) == "player" then warpPedIntoVehicle ( source, Vehicle) end end The source of this event is the marker that got hit by the element. Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 all code's not working post all code :- addEvent("ib",true) addEventHandler("ib",root, function () local x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) local client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit,false) end ) function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehiclee = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehiclee ) == 420 ) then warpPedIntoVehicle ( client1, Vehicle) end end end Help Please Link to comment
Anubhav Posted September 5, 2014 Share Posted September 5, 2014 addEvent("ib",true) addEventHandler("ib",root, function () local x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) local client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit,false) end ) function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehiclee = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehiclee ) == 420 ) then warpPedIntoVehicle ( thePlayer , Vehicle) end end end Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 addEvent("ib",true) addEventHandler("ib",root, function () local x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) local client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit,false) end ) function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehiclee = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehiclee ) == 420 ) then warpPedIntoVehicle ( thePlayer , Vehicle) end end end i want the marker when i hit it warp the ped client1 into my vehicle no warp me $>$ Link to comment
Anubhav Posted September 5, 2014 Share Posted September 5, 2014 addEvent("ib", true) addEventHandler("ib", root, function() local x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit,false) end ) function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehiclee = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehiclee ) == 420 ) then warpPedIntoVehicle ( client1, Vehicle) end end end Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 addEvent("ib", true) addEventHandler("ib", root, function() local x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) local arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit,false) end ) function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehiclee = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehiclee ) == 420 ) then warpPedIntoVehicle ( client1, Vehicle) end end end Not Working Man This Resource Drive Me Crezy Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 Please Guy's Help Me i'm gone lose my mind@_________@ Link to comment
Ab-47 Posted September 5, 2014 Share Posted September 5, 2014 Please Guy's Help Me i'm gone lose my mind@_________@ Lol, post your client side code. I'm sure your problem lies between triggering across file types. Furthermore, use /debugscript 3 and tell us what bad arguments are being output. Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 addEventHandler ("onClientGUIClick", resourceRoot, function () if source == btntwd then triggerServerEvent("ib", localPlayer) end end ) Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 ~ HELP HELP HELP H E L P > H E L P #_______@ Link to comment
Moderators IIYAMA Posted September 5, 2014 Moderators Share Posted September 5, 2014 keep your patience addEventHandler ("onClientGUIClick", resourceRoot, addEventHandler ("onClientGUIClick", root, Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 Now 100%( not )working it was when i use this addEvent("ib", true) addEventHandler("ib", root, function() x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit) end ) function onHit(source) if getElementType(source) == "player" then warpPedIntoVehicle ( client1, Vehicle) end end but the problem i need to get out of the car to warp the ped into vehicel not warping the ped when i'm in the car !! @_@ Link to comment
Moderators IIYAMA Posted September 5, 2014 Moderators Share Posted September 5, 2014 Well why don't you check if he is in a vehicle? Here you can find your solution/solutions. https://wiki.multitheftauto.com/wiki/Se ... _Functions Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 i try isPedInVehicle and NotWorking *_*" addEvent("ib", true) addEventHandler("ib", root, function() x, y, z = getElementPosition ( source ) Vehicle = createVehicle (443, x+2, y, z ) warpPedIntoVehicle ( source, Vehicle) setElementData ( source, "destroy", Vehicle ) client1 = createPed(36, 2851.8000488281,-1911.4000244141,11.10000038147,318.001373) arrow1 = createMarker ( 2851.8000488281,-1911.4000244141,13, "arrow", 1, 255, 255, 0, 170 ) marker1 = createMarker ( 2854.3000488281,-1911,10, "cylinder", 1, 255, 255, 0, 170 ) addEventHandler("onMarkerHit", marker1, onHit) end ) function onHit(source) if getElementType(source) == "player" and isPedInVehicle(source) then warpPedIntoVehicle ( client1, Vehicle) end end Link to comment
Moderators IIYAMA Posted September 5, 2014 Moderators Share Posted September 5, 2014 but the problem i need to get out of the car to warp the ped into vehicel Perhaps you should try to add "not", because you are doing the opposite of what you are saying. Never use source as parameter or you will not be able to access the source element any more.(in this case the marker itself) and not isPedInVehicle(source) then You never wondering why something isn't working, don't you? Link to comment
HustraDev Posted September 5, 2014 Author Share Posted September 5, 2014 i'm sorry man but you understand me wrong i need to pickup the ped when i'm [ in The Vehicle ] like the taxi job ## Link to comment
Moderators IIYAMA Posted September 5, 2014 Moderators Share Posted September 5, 2014 anyway, why are you use this variable for defining the ped that must be teleported in? Because now ped/peds will be shared with other taxi drives. and why don't you check if client1 is an element? Always keep an eye on the unpredictable. You should save everything with elementdata, tables or a database per player. Like you did on line 8. and you should debug your code before you ask again why it doesn't work. outputDebugString("It doesn't get triggered!!!! Please try again!") /debugscript 3 Here a nice example: https://wiki.multitheftauto.com/wiki/Debugging 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