Jump to content

Teleports


Timiimit

Recommended Posts

Posted

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?

in game nickname: [GFL]TimiimiT

Posted
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 ) 

Posted
???

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.

Posted
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 ) 

Posted

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!

in game nickname: [GFL]TimiimiT

Posted
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.

Posted

Xeno dosnt the event must be after end end end right ?

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

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] 
  

in game nickname: [GFL]TimiimiT

Posted (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 by Guest

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

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!!!!!

:D

finally!

thx for all.

in game nickname: [GFL]TimiimiT

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...