• Question about luas?
    6 replies, posted
-solved dis-
The PreDrawHalos hook doesn't pass a player argument. Also that's not the way ply:SteamID() works. You will have to loop through the players and if one of their steamid's match the one specified, then add a halo. Something like this should work.-snip-
[code] TEST [lua/includes/modules/a_star_pathfinding.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/ai_schedule_slv.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/ai_task_slv.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/nodegraph.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/a_star_pathfinding.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/ai_schedule_slv.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/ai_task_slv.lua][lua/includes/modules/halo.lua] TEST [lua/includes/modules/nodegraph.lua][lua/includes/modules/halo.lua] [ERROR] lua/includes/modules/halo.lua:66: bad argument #1 to 'pairs' (table expected, got userdata) 1. pairs - [C]:-1 2. Render - lua/includes/modules/halo.lua:66 3. fn - lua/includes/modules/halo.lua:168 4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/code] lol errored the fucked out
Sorry. I didn't read the documentation for halo.Add(). The first argument is a table, not an entity; I modified the code to reflect that.[code] local ids = {} //table containing all the steamids of people who should get halos ids["STEAM_0:1:40852869"] = true hook.Add("PreDrawHalos", "AddHalosToPeople", function() local halos = {} for k, v in pairs(player.GetAll()) do if (ids[v:SteamID()]) then //check for matching steamids to see if we should add a halo or not table.insert(halos, v) //insert the entity to draw the halo end end halo.Add(halos, Color(255, 0, 0), 5, 5, 2) end) [/code]
the halos go around the player right ?
Do you mean different colors? If so you could do something like this I suppose. [code] local ids = {} //table containing all the steamids of people who should get halos ids["STEAM_0:1:40852869"] = Color(255, 0, 0) hook.Add("PreDrawHalos", "AddHalosToPeople", function() for k, v in pairs(player.GetAll()) do if (ids[v:SteamID()]) then //check for matching steamids to see if we should add a halo or not; would still be true halo.Add({v}, ids[v:SteamID()], 5, 5, 2); //put the entity in a table and directly access the color the id is set to. end end end) [/code]
contact me on steam? id log4042
Sorry, you need to Log In to post a reply to this thread.