• Print

Author Topic: Call halo.add in ulx?  (Read 6419 times)

0 Members and 1 Guest are viewing this topic.

Offline Aharon Tager

  • Newbie
  • *
  • Posts: 37
  • Karma: 0
    • Barely Legal Gaming
Call halo.add in ulx?
« on: March 28, 2015, 06:31:02 pm »
Hey guys,
I've been working on this command for a little over a week, and I can't figure out how to fix this.
The purpose for the command was for calling out traitors who are delaying and making them glow like a wallhack to end the round faster.
I have a couple other ideas that I plan on developing and then releasing a command pack for TTT.

local CATEGORY_NAME = "Illuminati"
 
function ulx.illuminati( calling_ply, target_plys)
 
        for i=1, #target_plys do
                local v = target_plys[ i ]
 
                if v:IsRole(ROLE_TRAITOR) then
                local health = v:Health()
                v:SetHealth(health-5)
            //halo.Add({v}, Color(255, 0, 0), 0, 0, 2, true, true) This is where the error is

                ulx.fancyLogAdmin( calling_ply, "#A has prayed to the illuminati confirming #T as a Traitor!", target_plys )
 
                end
        end
end
local illuminati = ulx.command( CATEGORY_NAME, "ulx illuminati", ulx.illuminati, "!illuminati", true)
illuminati:addParam{ type=ULib.cmds.PlayersArg }
illuminati:defaultAccess( ULib.ACCESS_ADMIN )
illuminati:help( "Use on delaying traitors." )

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Call halo.add in ulx?
« Reply #1 on: March 28, 2015, 09:49:11 pm »
halo is a clientside function only.  The code you are running is serverside.  You also have to put it in a hook like so (Example from sandbox)....

http://wiki.garrysmod.com/page/GM/PreDrawHalos
Code: Lua
  1. hook.Add( "PreDrawHalos", "AddPhysgunHalos", function()
  2.  
  3.         if ( !PhysgunHalos || table.Count( PhysgunHalos ) == 0 ) then return end
  4.  
  5.  
  6.         for k, v in pairs( PhysgunHalos ) do
  7.  
  8.                 if ( !IsValid( k ) ) then continue end
  9.  
  10.                 local size = math.random( 1, 2 )
  11.                 local colr = k:GetWeaponColor() + VectorRand() * 0.3
  12.                  
  13.                 halo.Add( PhysgunHalos, Color( colr.x * 255, colr.y * 255, colr.z * 255 ), size, size, 1, true, false )
  14.                
  15.         end
  16.        
  17.         PhysgunHalos = {}
  18.  
  19. end )
« Last Edit: March 28, 2015, 09:52:11 pm by Aaron113 »

Offline Aharon Tager

  • Newbie
  • *
  • Posts: 37
  • Karma: 0
    • Barely Legal Gaming
Re: Call halo.add in ulx?
« Reply #2 on: March 29, 2015, 04:39:20 am »
Anyone know how to put that in a ulx command? I'll play Round with it myself a bit when I get home.
Thanks Aaron

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Call halo.add in ulx?
« Reply #3 on: March 29, 2015, 07:44:30 am »
To send it to he client, you would probably want to use the Net library.  In that same file outside of any functions do a "if CLIENT then" (this will only run clientside.  You would have to put the code for drawing and receiving in there. 

Offline Aharon Tager

  • Newbie
  • *
  • Posts: 37
  • Karma: 0
    • Barely Legal Gaming
Re: Call halo.add in ulx?
« Reply #4 on: March 30, 2015, 06:23:14 am »
How would I only call that if client when the command is run?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Call halo.add in ulx?
« Reply #5 on: March 30, 2015, 10:23:53 am »
You would have to use the net library (mentioned above) to send the list of entities to the client.  Then you can just check on the client if any entities exist in a table, or something along the lines of that, and draw the halos if it exists.  You would either have to use net.WriteEntity or net.WriteTable, whichever you prefer.

So in the client you would have to receive the net message and add the players to a clientside table that you would check in the halo hook.  In the server, you would send all clients the entities probably within the command itself.  Keep in mind that at some point you would have to disabled the halo effect for the player.

I'm trying to avoid doing the work for you, as you will never learn anything if you don't do it yourself.

EDIT:  Try and if you still can't figure it out, I can give you a quick example.
« Last Edit: March 30, 2015, 10:25:53 am by Aaron113 »

Offline Aharon Tager

  • Newbie
  • *
  • Posts: 37
  • Karma: 0
    • Barely Legal Gaming
Re: Call halo.add in ulx?
« Reply #6 on: March 30, 2015, 03:32:13 pm »
Thanks so much, I really appreciate you not just giving me a finished code I just never tried to do client and server stuff in the same script besides for including files for weapons

Offline Aharon Tager

  • Newbie
  • *
  • Posts: 37
  • Karma: 0
    • Barely Legal Gaming
Re: Call halo.add in ulx?
« Reply #7 on: April 01, 2015, 11:37:30 am »
Can you add me on steam and help out a little, I'm finding it hard to use the net libraries and make it work

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Call halo.add in ulx?
« Reply #8 on: April 01, 2015, 01:39:27 pm »

  • Print