attempt to concatenate local 'pl_pos' (a userdata value)

gamemodes\undergroundrp\gamemode\init.lua:6: attempt to concatenate local ‘pl_pos’ (a userdata value)

here is the buggy code

[lua]
concommand.Add(“GiveToolGun”, function(sender, command, arguments)
local pl_pos = sender:GetPos()
local bot_pos = bot_toolgun:GetPos()
local distance = pl_pos:Distance( bot_pos )
Msg( "Player Pos = " … pl_pos … "
" )
Msg( "Bot Pos = " … bot_pos … "
" )
Msg( “Distance” … distance … "
" )

if not sender:IsValid() then return end
local money = sender:GetNetworkedInt( "cash" )
Msg( money .. "

" )
if money < 100 then return
elseif money>= 100 then
sender:SetNWInt(“cash”, money - 100)
sender:Give(“gmod_tool”)
end
end)
[/lua]

here is the Entity spawn code

[lua]
function GM:InitPostEntity()
bot_toolgun = ents.Create( “bot_toolgun” )
bot_toolgun:SetAngles( Angle(0, -45, 0) )
bot_toolgun:SetPos( Vector(-1356, 881, -196) )
bot_toolgun:Spawn()
end
[/lua]

Msg(string)

getpos doesn’t return a string

You can’t concatenate a string (like "Player Pos = ") with a Vector the way you’re doing it. You can break the vector into it’s components and then concatenate those, like this:
[lua]local pl_posx, pl_posy, pl_posz = pl:GetPos()
Msg( "Player Pos = " … tostring(pl_posx) … " " … tostring(pl_posy) … " " … tostring(pl_posz) … "
" ) [/lua]

Edit: I assume you are displaying those values for debugging only. If so, save yourself the trouble and do it like this:

[lua]print(“Player Pos:”)
print(sender:GetPos())
[/lua]

[lua]print(“Player Pos:” , sender:GetPos())[/lua]

:eng101:

:golfclap:

its not only for debugging x)

Either way, you should use |FlapJack|'s code.[URL=“http://www.facepunch.com/showthread.php?p=23126844#post23126844”]

PrintTable( derma.GetSkinTable() )
^^ Best Method

Since when did this have to do with this thread at all?

i think he posted wrong …

He thinks you can printtable userdata values. And he is wrong.