Jump to content

[Help]getPlayerName outputChatbox


spoty

Recommended Posts

Hi There i need some help how can i getPlayerName in outputchatbox?

here is the code

i have 0 errors but it dont take the player name

i had searched on wiki and this what i did :P

addCommandHandler( "akina", function( player ) 
        setElementPosition( player, -2499.77466, 2135.24170, 320.54016  ) 
        outputChatBox( "#FF0000[#FF00FFakina#FF0000]getPlayerFromName( Player ).. '#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, true )  
    end 
) 
Link to comment

Because you're not concatenating it properly. Read this article for more information regarding concatenation.

addCommandHandler( "akina", function(player) 
        setElementPosition(player, -2499.77466, 2135.24170, 320.54016) 
        outputChatBox("#FF0000[#FF00FFakina#FF0000]"..getPlayerFromName(Player).."#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, true) 
    end 
) 

Link to comment
addCommandHandler( "akina",  
function(player) 
        setElementPosition( player, -2499.77466, 2135.24170, 320.54016  ) 
        outputChatBox( "#FF0000[#FF00FFakina#FF0000]"..getPlayerFromName(player).. "#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, true ) 
    end 
) 

Link to comment
addCommandHandler( "akina",  
function(player) 
        setElementPosition( player, -2499.77466, 2135.24170, 320.54016  ) 
        outputChatBox( "#FF0000[#FF00FFakina#FF0000]"..getPlayerFromName(player).. "#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, true ) 
    end 
) 

ERROR: akina\object\akina.lua:44: attempt to concatenate a boolean value 

thats this line

outputChatBox( "#FF0000[#FF00FFakina#FF0000]"..getPlayerFromName(player).. "#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000] 
 

i dont know that the error wanne say with that

Link to comment

Oh my bad, this should work

Forgot to change getPlayerFromName to getPlayerName

addCommandHandler( "akina", 
function(player) 
        setElementPosition( player, -2499.77466, 2135.24170, 320.54016  ) 
        outputChatBox( "#FF0000[#FF00FFakina#FF0000]"..getPlayerName(player).. "#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, true ) 
    end 
) 

Link to comment

It is possible, using this code

If you don't want the vehicle to be warped also, then you can remove line 5 and replace that with destroyElement(vehicle)

addCommandHandler( "akina", 
function(player) 
    if isPedInVehicle(player) then 
    local vehicle = getPedOccupiedVehicle(player) 
    setElementPosition( vehicle, -2499.77466, 2135.24170, 320.54016  ) 
    setElementPosition( player, -2499.77466, 2135.24170, 320.54016  ) 
    outputChatBox( "#FF0000[#FF00FFakina#FF0000]"..getPlayerName(player).. "#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, true ) 
    else 
    setElementPosition( player, -2499.77466, 2135.24170, 320.54016  ) 
    outputChatBox( "#FF0000[#FF00FFakina#FF0000]"..getPlayerName(player).. "#FF00FFHave Joined #FF0000[#FF00FF/akina#FF0000]", getRootElement(), 255, 255, 255, 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...