Timiimit Posted December 23, 2011 Posted December 23, 2011 Hi! I have started to make some teleports for admins, moderators and super moderators only. i want to make commandHandler (showadminmarker) and then if you are admin, it create marker and after 3 seconds it dessapears! if you touch it (when visible) it should teleport you! this is what I have: function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) local theMarker = createMarker ( some X, some Y, some Z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setTimer ( consoleUnshowMarker, 3000, 1 ) end end end function consoleUnshowMarker () destroyElement ( theMarker ) end addCommandHandler ( "showAdminMarker", consoleShowMarker ) how to continue?
Xeno Posted December 23, 2011 Posted December 23, 2011 function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) local theMarker = createMarker ( some X, some Y, some Z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setTimer (destroyElement, 3000, 1, theMarker ) end end end addCommandHandler ( "showAdminMarker", consoleShowMarker )
Xeno Posted December 23, 2011 Posted December 23, 2011 ??? Sorry. I turned the destroyMarker into a timer to make it easier.. If you want to continue, use an onMarkerHit event and trigger another function that uses setElementPosition to move the perosn.
Timiimit Posted December 23, 2011 Author Posted December 23, 2011 i would if marker show (its not???)!
Xeno Posted December 23, 2011 Posted December 23, 2011 function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) local theMarker = createMarker (x,y, z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setTimer (destroyElement, 3000, 1, theMarker ) end end end addCommandHandler ( "showAdminMarker", consoleShowMarker )
Timiimit Posted December 23, 2011 Author Posted December 23, 2011 I forgot to put in cordinates !! thx for help!
Timiimit Posted December 23, 2011 Author Posted December 23, 2011 WORKS! + what is "global" and what is "local"? (i dont know differance)
mjau Posted December 23, 2011 Posted December 23, 2011 https://wiki.multitheftauto.com/wiki/Local Global is the opposite
Timiimit Posted December 26, 2011 Author Posted December 26, 2011 Ok!?? this is what I have: function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local theMarker = createMarker (X, Y, Z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setTimer (destroyElement, 3000, 1, theMarker ) end end end function teleportPlayerIfModSmodOrAdmin ( thePlayer ) if hasObjectPermissionTo ( player, "command.kick", false ) then setElementPosition ( thePlayer,X, Y,Z ) end end addCommandHandler ( "showadminmarker", consoleShowMarker ) addEventHandler( "onMarkerHit", theMarker, MarkerHit ) it doesn't work but if I put global not local, it works even less. HELP!
Xeno Posted December 26, 2011 Posted December 26, 2011 function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local theMarker = createMarker (X, Y, Z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setTimer (destroyElement, 3000, 1, theMarker ) addEventHandler( "onMarkerHit", theMarker, MarkerHit ) end end end function teleportPlayerIfModSmodOrAdmin ( thePlayer ) if hasObjectPermissionTo ( player, "command.kick", false ) then setElementPosition ( thePlayer,X, Y,Z ) end end addCommandHandler ( "showadminmarker", consoleShowMarker ) Put the onMarkerHit inside the function with the marker in it. PS - There is no function called markerHit in your script, so that addEventHandler wont work. You only have functions called consoleShowMarker and teleportPlayerIfModSmodOrAdmin in your script.
Evil-Cod3r Posted December 26, 2011 Posted December 26, 2011 Xeno dosnt the event must be after end end end right ?
Xeno Posted December 26, 2011 Posted December 26, 2011 Xeno dosnt the event must be after end end end right ? No because the marker is inside the function.
Timiimit Posted December 27, 2011 Author Posted December 27, 2011 still doesn't work...?? log: when server starts [2011-12-27 10:33:43] SCRIPT ERROR: myscripts\adminTeleport.lua:3: '=' expected near 'theMarker' [2011-12-27 10:33:43] WARNING: Loading script failed: myscripts\adminTeleport.lua:3: '=' expected near 'theMarker' when command entered. WARNING: myscripts\adminTeleport.lua:6: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil]
Jaysds1 Posted December 27, 2011 Posted December 27, 2011 (edited) for the marker, what's the coordinate for where you want to place the marker? function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local theMarker = createMarker (X, Y, Z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then addEventHandler( "onMarkerHit", theMarker, teleportPlayerIfModSmodOrAdmin ) setTimer (destroyElement, 3000, 1, theMarker ) end end end function teleportPlayerIfModSmodOrAdmin ( thePlayer ) if hasObjectPermissionTo ( player, "command.kick", false ) then setElementPosition ( thePlayer,X, Y,Z ) end end addCommandHandler ( "showadminmarker", consoleShowMarker ) you didn't attached the function for when an admin goes in the marker Edited December 27, 2011 by Guest
Timiimit Posted December 27, 2011 Author Posted December 27, 2011 script: function consoleShowMarker ( thePlayer, commandName ) if ( thePlayer ) then local theMarker = createMarker (x,y,z, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then addEventHandler( "onMarkerHit", theMarker, teleportPlayerIfModSmodOrAdmin ) setTimer (destroyElement, 3000, 1, theMarker ) end end end function teleportPlayerIfModSmodOrAdmin ( thePlayer ) if hasObjectPermissionTo ( thePlayer, "command.kick", false ) then setElementPosition ( thePlayer, x,y,z ) end end addCommandHandler ( "showadminmarker", consoleShowMarker ) works!!!!! finally! thx for all.
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