NotAvailable Posted March 8, 2011 Share Posted March 8, 2011 Hi, Im learning how to use: setElementData getElementData So me & my friend created a delivery man job. the purpose of setElementData in this script is that the player can only spawn 1 van. If he tries to spawn another 1 the old 1 will be destroyed and there will be a new Van spawned. But i have 1 problem. When i step in the marker there will be no van spawned and i get this message: [DELIVERY MAN]Your old van is succesfully destroyed and there is a new Van spawned! This is my code: DJmarker = createMarker ( 83.796, -149.400, 1.684, "cylinder", 1, 255, 0, 0, 100, getRootElement() ) DJblip = createBlip ( 83.796, -149.400, 1.584, 51 ) function startMission (player) blip0 = createBlip ( 269.329, -220.570, 0.427, 41 ) blip1 = createBlip ( 215.279, 32.975, 1.462, 41 ) blip2 = createBlip ( -60.394, 83.554, 2.136, 41 ) blip3 = createBlip ( -116.719, -319.788, 0.171, 41 ) blip4 = createBlip ( 867.670, -31.795, 62.195, 41 ) setTimer(setElementPosition, 2200, 1, player, 94.952682495117, -162.39546203613, 2.59375 ) setTimer(setElementRotation, 2200, 1, player, 0, 0, 173.87872314453 ) fadeCamera ( player, false, 1.0, 0, 0, 0 ) setTimer ( fadeCamera, 2500, 1, player, true, 1.0 ) TheDV = createVehicle ( 440, 93.857, -164.925, 2.806 ) setElementRotation( TheDV, 0, 0, 270 ) local dlvan = getElementData(player, "got.van" ) if ( dlvan == false ) then setElementData(player,"got.van", TheDV) outputChatBox ( "[DELIVERY MAN]You are now a Delivery man!", player, 0, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Drive trough the markers to deliver the crates, And earn money.", player, 255, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Use /quitjob to quit this job.", player, 255, 255, 0, true ) end end addEventHandler( "onMarkerHit", DJmarker, startMission ) function stopjobCommand ( player ) setTimer(setElementPosition, 1000, 1, player, 85.138, -149.441, 2.583 ) setTimer(setElementRotation, 1000, 1, player, 0, 0, 270 ) fadeCamera ( player, false, 1.0, 0, 0, 0 ) setTimer ( fadeCamera, 1100, 1, player, true, 1.0 ) outputChatBox ( "[DELIVERY MAN]You are no longer Delivery man.", player, 255, 0, 0, true ) setTimer(destroyElement, 100, 1, TheDV) destroyElement(blip0) destroyElement(blip1) destroyElement(blip2) destroyElement(blip3) destroyElement(blip4) end addCommandHandler ("quitjob", stopjobCommand) function checkVan (player,matchingDimension) local dlvan = getElementData( player, "got.van" ) if ( dlvan ) then setElementData (player, "got.van", false ) destroyElement(TheDV) destroyElement(blip0) destroyElement(blip1) destroyElement(blip2) destroyElement(blip3) destroyElement(blip4) outputChatBox("[DELIVERY MAN]Your old van is succesfully destroyed and there is a new Van spawned!",player,0,255,0) end end addEventHandler( "onMarkerHit", DJmarker, checkVan ) Can someone help me? Regards, Jesseunit Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 It's very simple, at this line you get the Van: local dlvan = getElementData( player, "got.van" ) So the van to destroy is dlvan yeah ? So why you try to destroy TheDV ? : destroyElement(TheDV) replace by this: destroyElement(dlvan) Be careful with the name of your variables Link to comment
NotAvailable Posted March 8, 2011 Author Share Posted March 8, 2011 Aaah. thanks. i was getting a headache Link to comment
NotAvailable Posted March 8, 2011 Author Share Posted March 8, 2011 Hmmm... its still not working Picture: Wheres the van? Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 Maybe here 93.857, -164.925, 2.806 ? IDK No errors or warnings ? Link to comment
NotAvailable Posted March 8, 2011 Author Share Posted March 8, 2011 Nope i dont have any errors, Maybe its causing cause i enter the same marker Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 You have 2 addEventHandler( "onMarkerHit", ...., .... ) for 2 functions so I think that he creates the new van and setElementData(player,"got.van", TheDV) before the destroyElement( dlvan ) of the second function, so he creates the new van and he destroys it immediatly. Try to make only one function for this system EDIT: Like this: function startMission (player) local dlvan = getElementData( player, "got.van" ) if ( dlvan ) then setElementData (player, "got.van", false ) destroyElement(dlvan) destroyElement(blip0) destroyElement(blip1) destroyElement(blip2) destroyElement(blip3) destroyElement(blip4) outputChatBox("[DELIVERY MAN]Your old van is succesfully destroyed and there is a new Van spawned!",player,0,255,0) end blip0 = createBlip ( 269.329, -220.570, 0.427, 41 ) blip1 = createBlip ( 215.279, 32.975, 1.462, 41 ) blip2 = createBlip ( -60.394, 83.554, 2.136, 41 ) blip3 = createBlip ( -116.719, -319.788, 0.171, 41 ) blip4 = createBlip ( 867.670, -31.795, 62.195, 41 ) setTimer(setElementPosition, 2200, 1, player, 94.952682495117, -162.39546203613, 2.59375 ) setTimer(setElementRotation, 2200, 1, player, 0, 0, 173.87872314453 ) fadeCamera ( player, false, 1.0, 0, 0, 0 ) setTimer ( fadeCamera, 2500, 1, player, true, 1.0 ) local TheDV = createVehicle ( 440, 93.857, -164.925, 2.806 ) setElementRotation( TheDV, 0, 0, 270 ) local dlvan = getElementData(player, "got.van" ) if ( dlvan == false ) then setElementData(player,"got.van", TheDV) outputChatBox ( "[DELIVERY MAN]You are now a Delivery man!", player, 0, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Drive trough the markers to deliver the crates, And earn money.", player, 255, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Use /quitjob to quit this job.", player, 255, 255, 0, true ) end end addEventHandler( "onMarkerHit", DJmarker, startMission ) Link to comment
NotAvailable Posted March 8, 2011 Author Share Posted March 8, 2011 omg, thanks man its working. lua knowledge + 10% Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 omg, thanks man its working. lua knowledge + 10% Haha thanks now my lua knowledge is 110% I'm kidding, I still learns some things in lua Link to comment
#Paper Posted March 8, 2011 Share Posted March 8, 2011 Mhhh maybe i know the error: There is an error in the "onMarkerHit", the maker don't be getted just in the setted coords: in the x and y setteds yes, but not just in the "Z" coord setted, but in all Z (vertical)... Idk if somone get me Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 Mhhh maybe i know the error:There is an error in the "onMarkerHit", the maker don't be getted just in the setted coords: in the x and y setteds yes, but not just in the "Z" coord setted, but in all Z (vertical)... Idk if somone get me Sorry but the problem is already solved Link to comment
#Paper Posted March 8, 2011 Share Posted March 8, 2011 Mhhh maybe i know the error:There is an error in the "onMarkerHit", the maker don't be getted just in the setted coords: in the x and y setteds yes, but not just in the "Z" coord setted, but in all Z (vertical)... Idk if somone get me Sorry but the problem is already solved When? Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 Haha here : https://forum.multitheftauto.com/viewtopic.php?f=91&t=32218#p340795 Link to comment
#Paper Posted March 8, 2011 Share Posted March 8, 2011 Haha here : https://forum.multitheftauto.com/viewtopic.php?f=91&t=32218#p340795 are you crazy or what? Link to comment
Moderators Citizen Posted March 8, 2011 Moderators Share Posted March 8, 2011 No and you ? this is a direct link to this post: omg, thanks man its working. lua knowledge + 10% Link to comment
#Paper Posted March 9, 2011 Share Posted March 9, 2011 No and you ? this is a direct link to this post:omg, thanks man its working. lua knowledge + 10% and here there is the problem solved? Link to comment
Castillo Posted March 9, 2011 Share Posted March 9, 2011 Acitano, your post is not needed, you already know it's solved. Link to comment
#Paper Posted March 9, 2011 Share Posted March 9, 2011 Acitano, your post is not needed, you already know it's solved. I just want to know where's it solved... Link to comment
InDev Posted March 9, 2011 Share Posted March 9, 2011 You have 2 addEventHandler( "onMarkerHit", ...., .... ) for 2 functions so I think that he creates the new van and setElementData(player,"got.van", TheDV) before the destroyElement( dlvan ) of the second function, so he creates the new van and he destroys it immediatly.Try to make only one function for this system EDIT: Like this: function startMission (player) local dlvan = getElementData( player, "got.van" ) if ( dlvan ) then setElementData (player, "got.van", false ) destroyElement(dlvan) destroyElement(blip0) destroyElement(blip1) destroyElement(blip2) destroyElement(blip3) destroyElement(blip4) outputChatBox("[DELIVERY MAN]Your old van is succesfully destroyed and there is a new Van spawned!",player,0,255,0) end blip0 = createBlip ( 269.329, -220.570, 0.427, 41 ) blip1 = createBlip ( 215.279, 32.975, 1.462, 41 ) blip2 = createBlip ( -60.394, 83.554, 2.136, 41 ) blip3 = createBlip ( -116.719, -319.788, 0.171, 41 ) blip4 = createBlip ( 867.670, -31.795, 62.195, 41 ) setTimer(setElementPosition, 2200, 1, player, 94.952682495117, -162.39546203613, 2.59375 ) setTimer(setElementRotation, 2200, 1, player, 0, 0, 173.87872314453 ) fadeCamera ( player, false, 1.0, 0, 0, 0 ) setTimer ( fadeCamera, 2500, 1, player, true, 1.0 ) local TheDV = createVehicle ( 440, 93.857, -164.925, 2.806 ) setElementRotation( TheDV, 0, 0, 270 ) local dlvan = getElementData(player, "got.van" ) if ( dlvan == false ) then setElementData(player,"got.van", TheDV) outputChatBox ( "[DELIVERY MAN]You are now a Delivery man!", player, 0, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Drive trough the markers to deliver the crates, And earn money.", player, 255, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Use /quitjob to quit this job.", player, 255, 255, 0, true ) end end addEventHandler( "onMarkerHit", DJmarker, startMission ) Here =) Link to comment
#Paper Posted March 9, 2011 Share Posted March 9, 2011 You have 2 addEventHandler( "onMarkerHit", ...., .... ) for 2 functions so I think that he creates the new van and setElementData(player,"got.van", TheDV) before the destroyElement( dlvan ) of the second function, so he creates the new van and he destroys it immediatly.Try to make only one function for this system EDIT: Like this: function startMission (player) local dlvan = getElementData( player, "got.van" ) if ( dlvan ) then setElementData (player, "got.van", false ) destroyElement(dlvan) destroyElement(blip0) destroyElement(blip1) destroyElement(blip2) destroyElement(blip3) destroyElement(blip4) outputChatBox("[DELIVERY MAN]Your old van is succesfully destroyed and there is a new Van spawned!",player,0,255,0) end blip0 = createBlip ( 269.329, -220.570, 0.427, 41 ) blip1 = createBlip ( 215.279, 32.975, 1.462, 41 ) blip2 = createBlip ( -60.394, 83.554, 2.136, 41 ) blip3 = createBlip ( -116.719, -319.788, 0.171, 41 ) blip4 = createBlip ( 867.670, -31.795, 62.195, 41 ) setTimer(setElementPosition, 2200, 1, player, 94.952682495117, -162.39546203613, 2.59375 ) setTimer(setElementRotation, 2200, 1, player, 0, 0, 173.87872314453 ) fadeCamera ( player, false, 1.0, 0, 0, 0 ) setTimer ( fadeCamera, 2500, 1, player, true, 1.0 ) local TheDV = createVehicle ( 440, 93.857, -164.925, 2.806 ) setElementRotation( TheDV, 0, 0, 270 ) local dlvan = getElementData(player, "got.van" ) if ( dlvan == false ) then setElementData(player,"got.van", TheDV) outputChatBox ( "[DELIVERY MAN]You are now a Delivery man!", player, 0, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Drive trough the markers to deliver the crates, And earn money.", player, 255, 255, 0, true ) outputChatBox ( "[DELIVERY MAN]Use /quitjob to quit this job.", player, 255, 255, 0, true ) end end addEventHandler( "onMarkerHit", DJmarker, startMission ) Here =) Thanks 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