• Comparing steam ids not working?
    7 replies, posted
Hello, I want to compare steam ids, but this isn't working. I have: [CODE] local IDs = { "STEAM_0:1:53797886", "STEAM_0:1:44343401", } function kickonjoin(ply) for k, v in pairs( IDs ) do if v == ply:SteamID() then ply:Kick("This is a test!") end end end hook.Add( "PlayerConnect", "playerConnectHook", kickonjoin )[/CODE] And I get this error: [CODE] L 03/13/2014 - 19:29:25: Lua Error: [ERROR] lua/autorun/server/kick.lua:8: bad key to string index (number expected, got string) 1. error - [C]:-1 2. __index - lua/includes/extensions/string.lua:262 3. fn - lua/autorun/server/kick.lua:8 4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/CODE] Can you help me? Maksimo007
Show us the whole code...
Okay, I updated it.
What made you think that the PlayerConnect hook's first parameter is a player? [url=http://wiki.garrysmod.com/page/GM/PlayerConnect]Wiki is your friend[/url]
-snip-
[QUOTE]What made you think that the PlayerConnect hook's first parameter is a player? Wiki is your friend[/QUOTE] Hmm okay... The first parameter is a name, but how can I convert a name to a player? I have already googled, but all solutions doesn't work... I'm very new in lua.
Use a different hook, like [URL="http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn"]PlayerInitialSpawn[/URL].
Ah, it works fine now. Thank you :)
Sorry, you need to Log In to post a reply to this thread.