Snakegold Posted August 14, 2018 Posted August 14, 2018 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 )
Trefeor Posted August 14, 2018 Posted August 14, 2018 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 )
Discord Moderators Pirulax Posted August 14, 2018 Discord Moderators Posted August 14, 2018 No money for indentation? 1
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