ULX

Author Topic: Hook for swep and question about entities  (Read 3226 times)

0 Members and 1 Guest are viewing this topic.

Offline Darksoul

  • Newbie
  • *
  • Posts: 33
  • Karma: -1
Hook for swep and question about entities
« on: May 24, 2009, 11:28:15 PM »
What hook do I use to deny a player usage to say ignite, and how would I go about doing that?.

function canignite(swep, ply)
        if ply:IsAdmin then return true else return false end
end
hook.Add(PlayerCanUseSWEP, canignite)

that wont work of course.. just an example.

Also, for entities how would I go about restricting them to someone if they have x amount of "points". I have the system already, I just don't want to use a hook. I would like to add a option to the entity in shared.lua like CanAdminSpawn.

Thanks!.

« Last Edit: May 24, 2009, 11:30:51 PM by Darksoul »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Hook for swep and question about entities
« Reply #1 on: May 25, 2009, 07:21:08 AM »
Re: Ignite - http://wiki.garrysmod.com/?title=Gamemode.CanTool

Re: Points prevention - I know of no way other than using hooks. (I'm not saying it can't be done, I just wouldn't know how)
Which shared.lua are you referring to. Perhaps I or someone could look and tell more of what you're wishing to do without hooks.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Darksoul

  • Newbie
  • *
  • Posts: 33
  • Karma: -1
Re: Hook for swep and question about entities
« Reply #2 on: May 25, 2009, 10:11:14 AM »
Shared.lua for a entity..

Example:

Code: [Select]
ENT.Type = "anim"
ENT.Base = "wtib_tiberiumbase"
ENT.PrintName = "Blue Tiberium"
ENT.Author = "kevkev/Warrior xXx"
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Spawnable = false
ENT.AdminSpawnable = true
ENT.Category = "Tiberium"
ENT.IsTiberium = true
ENT.CanBeHarvested = true
ENT.NoPhysicsPickup = true

ENT.TiberiumDraimOnReproduction = 2000
ENT.MinReprodutionTibRequired = 2300
ENT.RemoveOnNoTiberium = true
ENT.IgnoreExpBurDamage = false
ENT.ReproductionRate = 10
ENT.MinTiberiumGain = 10
ENT.MaxTiberiumGain = 30
ENT.ShouldReproduce = true
ENT.ReproduceDelay = 70
ENT.MaxTiberium = 5000
ENT.TiberiumAdd = true
ENT.DynLight = false
ENT.Class = "wtib_bluetiberium"
ENT.Gas = true
ENT.r = 0
ENT.g = 0
ENT.b = 255

ENT.Spawnable      = false
ENT.AdminSpawnable   = true

Basically I would like to add a option to the entity so it would be like..


ENT.Spawnable = false
ENT.Rank > 20
ENT.AdminSpawnable = true

The rank would be the required number to spawn, and anything above that would allow it to spawn.

Ugh, whatever. What hook would I need to use for this?.

Thanks for the CanTool hook!.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Hook for swep and question about entities
« Reply #3 on: May 25, 2009, 02:12:30 PM »
You'd need to use a hook for the point system anyways...
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Hook for swep and question about entities
« Reply #4 on: May 25, 2009, 02:55:26 PM »
Megiddo's right. Always vague though :P
That list of stuff is a table for ENT.
Each ENT.<blah> is a variable related to ENT.
So, you can't just use ENT.Rank > 20
You'd have to use ENT.Rank = 20 in your setup.
Then, in your hooks related to ENT, you'd do a "if player.Rank >= ENT.Rank then <go ahead> else <nope!> end" comparison.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming