toptional Posted April 17, 2013 Share Posted April 17, 2013 Im using destroyElement alot in this script and i keep getting errors on all the lines saying bad element pointer and bad arguments? It's weird take a look. Note this is just some of the code, all you will need i think. addEventHandler ( 'onClientGUIClick', ButtonBaggage, function ( ) triggerServerEvent ('spawnBaggage', localPlayer ) guiSetVisible ( Window1, false ) showCursor ( false ) destroyElement ( MissionMarker ) local dodoMarker1 = createMarker (1286.41077, 1345.46094, 10, "cylinder", 2, 255, 255, 0, 255 ) blip1 = createBlipAttachedTo ( dodoMarker1, 41 ) local dodoMarker2 = createMarker (1285.84778, 1309.42847, 10, "cylinder", 2, 255, 255, 0, 255 ) blip2 = createBlipAttachedTo ( dodoMarker2, 41 ) addEventHandler('onClientMarkerHit',dodoMarker1,showGui2,false) addEventHandler('onClientMarkerHit',dodoMarker2,showGui3,false) end ) addEventHandler ( 'onClientGUIClick', ButtonFaggio, function ( ) triggerServerEvent ('spawnFaggio', localPlayer ) guiSetVisible ( Window1, false ) showCursor ( false ) destroyElement ( MissionMarker ) local dodoMarker1 = createMarker (1286.41077, 1345.46094, 10, "cylinder", 2, 255, 255, 0, 255 ) blip1 = createBlipAttachedTo ( dodoMarker1, 41 ) local dodoMarker2 = createMarker (1285.84778, 1309.42847, 10, "cylinder", 2, 255, 255, 0, 255 ) blip2 = createBlipAttachedTo ( dodoMarker2, 41 ) addEventHandler('onClientMarkerHit',dodoMarker1,showGui2,false) addEventHandler('onClientMarkerHit',dodoMarker2,showGui3,false) end ) addEventHandler ( 'onClientGUIClick', ButtonTug, function ( ) triggerServerEvent ('spawnTug', localPlayer ) guiSetVisible ( Window1, false ) showCursor ( false ) destroyElement ( MissionMarker ) local dodoMarker1 = createMarker (1286.41077, 1345.46094, 10, "cylinder", 2, 255, 255, 0, 255 ) blip1 = createBlipAttachedTo ( dodoMarker1, 41 ) local dodoMarker2 = createMarker (1285.84778, 1309.42847, 10, "cylinder", 2, 255, 255, 0, 255 ) blip2 = createBlipAttachedTo ( dodoMarker2, 41 ) addEventHandler('onClientMarkerHit',dodoMarker1,showGui2,false) addEventHandler('onClientMarkerHit',dodoMarker2,showGui3,false) end ) addEventHandler('onClientGUIClick',Button2, function () triggerServerEvent('spawnDodo1',localPlayer ) destroyElement(dodoMarker1) destroyElement(dodoMarker2) destroyElement(blip1) destroyElement(blip2) guiSetVisible(Window2, false) showCursor(false) end ) addEventHandler('onClientGUIClick',Button3, function () triggerServerEvent('spawnDodo2',localPlayer ) destroyElement(dodoMarker1) destroyElement(dodoMarker2) destroyElement(blip1) destroyElement(blip2) guiSetVisible(Window3, false) showCursor(false) end ) Link to comment
toptional Posted April 17, 2013 Author Share Posted April 17, 2013 Note - seems like when i type faggio it turns into a ":O" I think a Forum bug there... as faggio is not a swearword :facepalm: Link to comment
OGF Posted April 17, 2013 Share Posted April 17, 2013 Don't use 'local' when you create your markers. Link to comment
Mega9 Posted April 17, 2013 Share Posted April 17, 2013 Try this and change the event name at line 16 and 18 since I don't think it's called ":O" addEventHandler ( 'onClientGUIClick', ButtonBaggage, function ( ) triggerServerEvent ('spawnBaggage', localPlayer ) guiSetVisible ( Window1, false ) showCursor ( false ) destroyElement ( MissionMarker ) dodoMarker1 = createMarker (1286.41077, 1345.46094, 10, "cylinder", 2, 255, 255, 0, 255 ) blip1 = createBlipAttachedTo ( dodoMarker1, 41 ) dodoMarker2 = createMarker (1285.84778, 1309.42847, 10, "cylinder", 2, 255, 255, 0, 255 ) blip2 = createBlipAttachedTo ( dodoMarker2, 41 ) addEventHandler('onClientMarkerHit',dodoMarker1,showGui2,false) addEventHandler('onClientMarkerHit',dodoMarker2,showGui3,false) end ) addEventHandler ( 'onClientGUIClick', , function ( ) triggerServerEvent (':O', localPlayer ) guiSetVisible ( Window1, false ) showCursor ( false ) destroyElement ( MissionMarker ) dodoMarker1 = createMarker (1286.41077, 1345.46094, 10, "cylinder", 2, 255, 255, 0, 255 ) blip1 = createBlipAttachedTo ( dodoMarker1, 41 ) dodoMarker2 = createMarker (1285.84778, 1309.42847, 10, "cylinder", 2, 255, 255, 0, 255 ) blip2 = createBlipAttachedTo ( dodoMarker2, 41 ) addEventHandler('onClientMarkerHit',dodoMarker1,showGui2,false) addEventHandler('onClientMarkerHit',dodoMarker2,showGui3,false) end ) addEventHandler ( 'onClientGUIClick', ButtonTug, function ( ) triggerServerEvent ('spawnTug', localPlayer ) guiSetVisible ( Window1, false ) showCursor ( false ) destroyElement ( MissionMarker ) dodoMarker1 = createMarker (1286.41077, 1345.46094, 10, "cylinder", 2, 255, 255, 0, 255 ) blip1 = createBlipAttachedTo ( dodoMarker1, 41 ) dodoMarker2 = createMarker (1285.84778, 1309.42847, 10, "cylinder", 2, 255, 255, 0, 255 ) blip2 = createBlipAttachedTo ( dodoMarker2, 41 ) addEventHandler('onClientMarkerHit',dodoMarker1,showGui2,false) addEventHandler('onClientMarkerHit',dodoMarker2,showGui3,false) end ) addEventHandler('onClientGUIClick',Button2, function () triggerServerEvent('spawnDodo1',localPlayer ) destroyElement(dodoMarker1) destroyElement(dodoMarker2) destroyElement(blip1) destroyElement(blip2) guiSetVisible(Window2, false) showCursor(false) end ) addEventHandler('onClientGUIClick',Button3, function () triggerServerEvent('spawnDodo2',localPlayer ) destroyElement(dodoMarker1) destroyElement(dodoMarker2) destroyElement(blip1) destroyElement(blip2) guiSetVisible(Window3, false) showCursor(false) end ) Link to comment
OGF Posted April 17, 2013 Share Posted April 17, 2013 mega9, It isn't that hard to do, let him do it. Link to comment
Mega9 Posted April 17, 2013 Share Posted April 17, 2013 If he made the whole code then he knows what he is doing, so its not such a big deal but mkay. Link to comment
toptional Posted April 17, 2013 Author Share Posted April 17, 2013 Perfect it works! Thanks for your help Link to comment
toptional Posted April 17, 2013 Author Share Posted April 17, 2013 Oh btw! another slight issue with destroyElement. it doesn't destroy the cars addEvent ( "spawnBaggage", true) addEventHandler ("spawnBaggage", root, function () local baggage = createVehicle ( 485, 1713.62378, 1458.48633, 10.73280, 0, 0,-3 ) warpPedIntoVehicle( source, baggage ) outputChatBox ("Please make your way to Las Venturas Airport! A Blip has been marked on you map.", source,255,255,0, false) fixVehicle ( baggage ) end ) addEvent ( "spawnFaggio", true) addEventHandler ("spawnFaggio", root, function () local faggio = createVehicle ( 462, 1713.62378, 1458.48633, 10.73280, 0, 0,-3 ) warpPedIntoVehicle( source, faggio ) outputChatBox ("Please make your way to Las Venturas Airport! A Blip has been marked on you map, choose which terminal to spawn your plane.", source,255,255,0, false) fixVehicle ( faggio ) end ) addEvent ( "spawnTug", true) addEventHandler ("spawnTug", root, function () local tug = createVehicle ( 583, 1713.62378, 1458.48633, 10.73280, 0, 0,-3 ) warpPedIntoVehicle( source, tug ) outputChatBox ("Please make your way to Las Venturas Airport! A Blip has been marked on you map, choose which terminal to spawn your plane.", source,255,255,0, false) fixVehicle ( tug ) end ) addEvent ( "spawnDodo1", true) addEventHandler ("spawnDodo1", root, function () local dodo1 = createVehicle ( 593, 1277.43933, 1361.18616, 10.81298, 0, 0,-90) warpPedIntoVehicle( source, dodo1 ) outputChatBox ("Please make your way to the terminal your passasengers await you.", source,255,255,0, false) fixVehicle ( dodo1 ) destroyElement(faggio) destroyElement(tug) destroyElement(baggage) end ) addEvent ( "spawnDodo2", true) addEventHandler ("spawnDodo2", root, function () local dodo2 = createVehicle ( 593, 1278.48193, 1324.14075, 10.82031, 0, 0,-90) warpPedIntoVehicle( source, dodo2 ) outputChatBox ("Please make your way to the terminal your passasengers await you.", source,24,116,205, false) fixVehicle ( dodo2 ) destroyElement(faggio) destroyElement(tug) destroyElement(baggage) end ) Link to comment
manve1 Posted April 17, 2013 Share Posted April 17, 2013 'local' variables are only in one function, unless its out of function, remove 'local' and that will make it global, which will for a certain work if you create a vehicle in one function, then try to destroy it in another one. Link to comment
toptional Posted April 17, 2013 Author Share Posted April 17, 2013 But i don't want the vehicle being spawned for everyone only the person who called the function Link to comment
manve1 Posted April 17, 2013 Share Posted April 17, 2013 It doesn't contain an effect on the spawning of an element, local variable just makes it local or global, remove all of the 'local' bits in your script and try it. Link to comment
Moderators IIYAMA Posted April 17, 2013 Moderators Share Posted April 17, 2013 @Robbster That's not a problem, the problem you have to solve is "how to destroy them for every single player". and then we are going to talk about tables. Or other storage possibility's. Link to comment
manve1 Posted April 17, 2013 Share Posted April 17, 2013 (edited) I forgot to mention, that before destroying and element, always check if it exists, or else you just going to get an error. (( you can getPedOccupiedVehicle to get the vehicle a person is in and then if it returns true you can destroy it. )) Edited April 17, 2013 by Guest Link to comment
toptional Posted April 17, 2013 Author Share Posted April 17, 2013 Ok it seems to work but i hope it's all local! Link to comment
manve1 Posted April 17, 2013 Share Posted April 17, 2013 Ok it seems to work but i hope it's all local! What do you mean "it's all local"? Link to comment
Moderators IIYAMA Posted April 17, 2013 Moderators Share Posted April 17, 2013 When you make it global and recreate those vehicles, you will overwrite the vehicles(user-data). baggage = createVehicle ( 485, 1713.62378, 1458.48633, 10.73280, 0, 0,-3 ) baggage = createVehicle ( 485, 1713.62378, 1458.48633, 10.73280, 0, 0,-3 ) -- overwrite the data. Link to comment
OGF Posted April 18, 2013 Share Posted April 18, 2013 It's not a forum bug. Whenever you say a swear word that is mta's way of censoring. FUCK YOU BITCH SHIT CUNT --see ? 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