Jump to content

[HELP] Teleport System


Recommended Posts

Posted
function goToBeach()
  setElementPosition(source, 343.20026, -1780.60388, 5.22299)
end
addCommandHandler("gotobeach", goToBeach)

Don't forget to add a Thanks reaction if it helped

Posted

[2018-07-10 00:20:43] WARNING: beach\server.lua:75: Bad argument @ 'setElementPosition' [Expected element at argument 1, got nil]
[2018-07-10 00:20:49] WARNING: beach\server.lua:75: Bad argument @ 'setElementPosition' [Expected element at argument 1, got nil]

errors!

 

Posted (edited)
function goToBeach()
  setElementPosition(localPlayer, 343.20026, -1780.60388, 5.22299)
end
addCommandHandler("gotobeach", goToBeach)

 

Edited by Galactix
Posted
12 hours ago, Galactix said:

function goToBeach()
  setElementPosition(localPlayer, 343.20026, -1780.60388, 5.22299)
end
addCommandHandler("gotobeach", goToBeach)

 

this script is not Working ...

  • Discord Moderators
Posted

Because it should be client-side, which is dumb.
 

addCommandHandler("gotobeach", 
  	function goToBeach(source)
  		setElementPosition(source, 343.20026, -1780.60388, 5.22299)
	end
)

 

Posted
4 hours ago, Pirulax said:

Because it should be client-side, which is dumb.
 


addCommandHandler("gotobeach", 
  	function goToBeach(source)
  		setElementPosition(source, 343.20026, -1780.60388, 5.22299)
	end
)

 

this is a client side ?

Posted
10 hours ago, Pirulax said:

Because it should be client-side, which is dumb.
 


addCommandHandler("gotobeach", 
  	function goToBeach(source)
  		setElementPosition(source, 343.20026, -1780.60388, 5.22299)
	end
)

 

not working

 

Posted
1 hour ago, Mr.Loki said:

addCommandHandler("gotobeach", 
    function(plr)
        setElementPosition(plr, 343.20026, -1780.60388, 5.22299)
    end
)

 

your script is not working

im fixed the script and work it!

thanks!

Posted
addCommandHandler("gotobeach", 
    function()
        spawnPlayer(source, 343.20026, -1780.60388, 5.22299,_,_)
    end
)

 

Posted
9 hours ago, EH10 said:

addCommandHandler("gotobeach", 
    function()
        spawnPlayer(source, 343.20026, -1780.60388, 5.22299,_,_)
    end
)

 

Idk if this is a troll or not but this is a bad way of moving the player.

Also the source in your code is nil

@Pirulax your code didn't work because you defined a function name for an anon function.

  • Discord Moderators
Posted (edited)

Happens, I was tired as I said.
Btw, here is the working code then:

addCommandHandler("gotobeach", 
    function(source)
        if (isPedDead(source)) then
      		spawnPlayer(source, 343.20026, -1780.60388, 5.22299)
      	else
      		setElementPosition(source, 343.20026, -1780.60388, 5.22299)
      	end
    end
)

And actually, there is no predefined 'source' variable in addCommandHandler, and why would you spawn a player?

Edited by Pirulax
Posted

teleport_s.lua

addCommandHandler("gotobeach", function(player)
if isElement(player) and not isPedDead(player) then
setElementPosition(player, 343.20026, -1780.60388, 5.22299)
outputChatBox("You have been successfully teleported to the beach.", player, 0, 200, 0, false)
else
outputChatBox("You must be alive in order to use this command.", player, 200, 0, 0, false)
end
end)

meta.xml

<meta>
<script src="teleport_s.lua" type="server"/>
</meta>

http://www.mediafire.com/file/kwz7052k8tltfxf/teleport.zip

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