Get player by name
#3
Quote:function DetectcPlayerByName(GivenName)
cRoot:Get():FindAndDoWithPlayer(GivenName,
function(a_Player)
if (a_Player:GetName() ~= GivenName) then
-- Callback is called for the player who matches the target playername the closest.
return false
end
-- Do stuff with the player
return(a_Player)
end

I've tried that to convert the string to a cPlayer, but the console says

Quote:LUA: Plugins/Sniper/main.lua~:86: error in function 'TakeDamage'.
argument #2 is 'number'; 'cEntity' expected.

Line 86 is
Quote:Entity:TakeDamage(dtArrow, DetectcPlayerByName(ShooterName), 18, ProjectileEntity:GetPosition())
Reply
Thanks given by:


Messages In This Thread
Get player by name - by JuliB - 01-08-2016, 02:40 AM
RE: Get player by name - by NiLSPACE - 01-08-2016, 02:48 AM
RE: Get player by name - by JuliB - 01-08-2016, 03:06 AM
RE: Get player by name - by NiLSPACE - 01-08-2016, 03:13 AM
RE: Get player by name - by JuliB - 01-08-2016, 03:25 AM
RE: Get player by name - by NiLSPACE - 01-08-2016, 03:35 AM
RE: Get player by name - by JuliB - 01-08-2016, 03:50 AM
RE: Get player by name - by xoft - 01-08-2016, 07:55 AM
RE: Get player by name - by NiLSPACE - 01-08-2016, 05:45 PM
RE: Get player by name - by xoft - 01-08-2016, 11:44 PM
RE: Get player by name - by NiLSPACE - 01-09-2016, 12:03 AM



Users browsing this thread: 1 Guest(s)