So I use [CODE] owner:ChatPrint('You must hit a player! You hit ' .. target) [/CODE] and it gave me a error saying [QUOTE] bad argument #2 to '__concat' (string expected, got userdata)
1. __concat - [C]:-1 [/QUOTE]
Then I tried [CODE] owner:ChatPrint('You must hit a player!') [/CODE] -- Without the var
and it works fine. Can someone help me?
[editline]16th July 2016[/editline]
Yes I did set target to something:
[CODE]
local target = trace.Entity
if target:IsPlayer() then
self:ULXAttack( target:Nick() )
else
owner:ChatPrint('You must hit a player! You hit ' .. target)
end
[/CODE]
Ok, well you can't join a string and an entity. How would that work?
You need to use target:Nick() since that's a string
Use tostring( target ). Nick only works for players.
[editline]15th July 2016[/editline]
Or target:GetClass(), however, you'll need to make sure target isn't NULL first.
Ok now I have another problem, when I do hit the player it says [QUOTE]attempt to call local 'Targetname' (a string value)
[/QUOTE]
Here is where I use the code:
[CODE]
function SWEP:ULXAttack( Targetname )
if self.AttackMode == "freeze" then
RunConsoleCommand('ulx freeze ' ..'"' .. Targetname '"')
ply:ChatPrint('You have frozen ' .. Targetname)
end
end
[/CODE]
RunConsoleCommand uses varargs, not a single string. So it should be RunConsoleCommand( "ulx", "freeze", Targetname )
:snip: nevermind
Oh ok thx
Sorry, you need to Log In to post a reply to this thread.