Jump to content

[Help] Concatenate


Wumbaloo

Recommended Posts

Hi! I have a mystery error in the console, here's the error:

"script.lua:5: attempt to concatenate local 'sourcePlayer' (a userdata value) 

but no error in my code I think..

function setHP(sourcePlayer, command, targetPlayerName, value) 
        targetPlayer = getPlayerFromName (targetPlayerName) 
        setElementHealth (targetPlayer, value) 
        outputChatBox("Vous avez mis " .. value .. " HP à " .. targetPlayerName, sourcePlayer) 
        outputChatBox("L'Admin: " .. sourcePlayer " vous à mis votre HP à " .. value .. ".", targetPlayer) 
end 
addCommandHandler("setHP", setHP) 
addCommandHandler("sethp", setHP) 

Can you help me? Thanks! :)

Link to comment

script.lua:5: attempt to concatenate local 'sourcePlayer' (a userdata value)

means that you tried to join a string with a userdata (more specifically, userdata:element:player) value. You tried to embed the memory address for a player instead of his nickname (getPlayerName)

        outputChatBox("L'Admin: " .. sourcePlayer " vous à mis votre HP à " .. value .. ".", targetPlayer) 

should be

        outputChatBox("L'Admin: " .. getPlayerName(sourcePlayer) .." vous à mis votre HP à " .. value .. ".", targetPlayer) 

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