Jump to content

Warpto problem


Snakegold

Recommended Posts

hello community

i want when i type /warpto "playername"

i go near him, even if i'm in vehicle

i tried this code

function warpto (thePlayer, playername)
    if (isElement( thePlayer )) then
	local player = getPlayerFromNamePart(playername or "")
	local name = getPlayerName(thePlayer)
	if player then
	getElementPosition ( source, posX, posY, posZ )
	if isPedInVehicle (source) then
	setElementPosition (source, posX, posY, posZ)
					outputChatBox("You have been warped to "..getPlayerName(player).."",thePlayer, 0, 255, 0)
			else
					outputChatBox("Couldn't find the player",thePlayer, 255, 0, 0)
					end
				end
			end
		end
addCommandHandler ( "warpto", warpto )

 

Link to comment

 

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

addCommandHandler ( "warptop" , function ( player , cmd , name ) 
local thePlayer = getPlayerFromPartialName ( name ) 
if ( thePlayer ) then 
local pos = { getElementPosition ( thePlayer ) } 
setElementPosition ( player , pos[1] + 1 , pos[2] , pos[3] )
outputChatBox("you have been warped to "..getPlayerName(thePlayer).." .",player,255,255,255,true)
else 
outputChatBox("you can't find player",player,255,0,0,true)
end
end ) 

 

Link to comment

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