NotAvailable Posted January 22, 2011 Share Posted January 22, 2011 Hi, i have a little problem. I made a teleport script when u enter the marker and u type: /leave u will be teleported. But i get a error: local myMarker = createMarker( -2284.4592285156, 1909.6333007813, 7.9688625335693, "Cylinder", 1, 255, 0, 0, 140) function openForMe(hitElement, matchingDimension) if getElementType ( hitElement ) == "player" then local vehicle = getPlayerOccupiedVehicle ( hitElement ) if vehicle or not vehicle then local wanted = getPlayerWantedLevel ( hitElement ) if wanted == 0 then addCommandHandler("leave", teleportMassive) end end end end addEventHandler("onMarkerHit", myMarker,openForMe) function teleportMassive(hitElement, matchingDimension) if getElementType ( hitElement ) == "player" then local vehicle = getPlayerOccupiedVehicle ( hitElement ) if vehicle or not vehicle then setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) setElementRotation(player, 270.36642456055) removeCommandHandler("leave") end end end Whats wrong with it? Im not getting any errors in the script editor. Regards, Jesseunit Link to comment
Aibo Posted January 22, 2011 Share Posted January 22, 2011 in your teleportMassive() function player who typed the command is put in «hitElement» variable, while you teleporting the «player» variable. also getPlayerOccupiedVehicle() is deprecated, use getPedOccupiedVehicle() and what is the point of «if vehicle or not vehicle then»? Link to comment
NotAvailable Posted January 23, 2011 Author Share Posted January 23, 2011 (edited) Its still not working i get this error: [18:04:24] WARNING: editor_test\misc_S.lua:13: Bad argument @ 'addEventHandler' Heres the code: function openForMe(hitElement, matchingDimension) if getElementType ( hitElement ) == "player" then local wanted = getPlayerWantedLevel ( hitElement ) if wanted == 0 then outputChatBox("Are you sure you want to leave Alcatraz?", hitElement, 0, 255, 0) outputChatBox("Say: /leave if u want to leave", hitElement, 255, 200, 0) addCommandHandler("leave", teleportMassive) end end end addEventHandler("onMarkerHit", myMarker,openForMe) function teleportMassive(player, matchingDimension) local player = getPlayerFromName(player); setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) setElementRotation(player, 270.36642456055) removeCommandHandler("leave") end Edited January 23, 2011 by Guest Link to comment
Aibo Posted January 23, 2011 Share Posted January 23, 2011 where's myMarker? and player is already player element, you dont need this: local player = getPlayerFromName(player); Link to comment
NotAvailable Posted January 23, 2011 Author Share Posted January 23, 2011 i still get the same error. This is the full code: local myMarker = createMarker( -2284.4592285156, 1909.6333007813, 7.9688625335693, "Cylinder", 1, 255, 0, 0, 140) function openForMe(hitElement, matchingDimension) if getElementType ( hitElement ) == "player" then local wanted = getPlayerWantedLevel ( hitElement ) if wanted == 0 then outputChatBox("Are you sure you want to leave Alcatraz?", hitElement, 0, 255, 0) outputChatBox("Say: /leave if u want to leave", hitElement, 255, 200, 0) addCommandHandler("leave", teleportMassive) end end end addEventHandler("onMarkerHit", myMarker,openForMe) function teleportMassive(player, matchingDimension) setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) setElementRotation(player, 270.36642456055) removeCommandHandler("leave") end Link to comment
Castillo Posted January 23, 2011 Share Posted January 23, 2011 uhm, the marker wasn't being created, how do i know? i simply added a small check and results not being created, anyway i've fixed the marker and here is the code: local myMarker = createMarker ( -2284.4592285156, 1909.6333007813, 7.9688625335693, "cylinder", 1, 255, 0, 140, getRootElement()) if myMarker then outputChatBox("Marker created!") else outputChatBox("Marker couldn't be created!") end function openForMe(hitElement, matchingDimension) if getElementType ( hitElement ) == "player" then local wanted = getPlayerWantedLevel ( hitElement ) if wanted == 0 then outputChatBox("Are you sure you want to leave Alcatraz?", hitElement, 0, 255, 0) outputChatBox("Say: /leave if u want to leave", hitElement, 255, 200, 0) addCommandHandler("leave", teleportMassive) end end end addEventHandler("onMarkerHit", myMarker, openForMe) function teleportMassive(player, matchingDimension) setElementPosition(player, -2279.3093261719, 1909.4665527344, 8.9688625335693) setElementRotation(player, 270.36642456055) removeCommandHandler("leave") end Link to comment
Aibo Posted January 23, 2011 Share Posted January 23, 2011 marker type should be "cylinder", not "Cylinder". it's case-sensitive Link to comment
Castillo Posted January 23, 2011 Share Posted January 23, 2011 That's what i expected aibo Link to comment
NotAvailable Posted January 24, 2011 Author Share Posted January 24, 2011 Thanks man its working 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