Ulysses
General => Developers Corner => Topic started by: Darksoul 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!.
-
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.
-
Shared.lua for a entity..
Example:
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!.
-
You'd need to use a hook for the point system anyways...
-
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.