Ulysses

General => Developers Corner => Topic started by: RecoX on July 05, 2008, 11:53:19 AM

Title: ULXToolRestricter
Post by: RecoX on July 05, 2008, 11:53:19 AM
WARNING!: If you have ASpam installed You must update it to latest !

New Name: ULX Anti-Stool
Version: 1.1.2
Author: Reco / With Help from Jay209015
Purpose:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This Module will stop normal users from using a certen tool EG; Anti-NoClip Stool will be restirected to Allowed list and admins
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

How To Install:
-----------------------------------------------------------
Simply drop the lua file in your lua/autorun-
-----------------------------------------------------------

How to add users:

Open up garrysmod/data/antistool_palyers.txt and add the steam ids that you want.

Download--------------------
http://one.xthost.info/AnstiStool/Anti-Stool%20Version%201.1.zip]http://one.xthost.info/AnstiStool/Anti-Stool%20Version%201.1.zip]http://one.xthost.info/AnstiStool/Anti-Stool%20Version%201.1.zip (http://one.xthost.info/AnstiStool/Anti-Stool%20Version%201.1.zip)
-------------------------------


Title: Re: ULXToolRestricter
Post by: RecoX on July 05, 2008, 11:56:43 AM
This is just the verry basic code im  hoping with a few more tuts to make it so you can add restricted tools in a cfg or txt file
Title: Re: ULXToolRestricter
Post by: benbrooks on July 06, 2008, 06:24:20 AM
Looks simple but effective, nice work :)
Title: Re: ULXToolRestricter
Post by: RecoX on July 06, 2008, 07:55:14 AM
Thanks Also im ahving proplems in my servers all pepole can pick echover up
Title: Re: ULXToolRestricter
Post by: Megiddo on July 06, 2008, 09:24:31 AM
Welcome to the forums RecoX! Sit back, relax, and let the crazy do its work. :)
Title: Re: ULXToolRestricter
Post by: Chironex on July 06, 2008, 10:12:30 AM
Do something more newb-friendly, something like that:
Code: [Select]
-- Here they write all tools they want to restrict:
local Restricted_Tools =
{
    "#Anti-NoClip",
    "Gcombat",
    "Cannon",
    "linktool"
}

--and then in your function, you just check if the toolmode is one of that list:
if Restricted_Tools[toolmode] then
Title: Re: ULXToolRestricter
Post by: RecoX on July 06, 2008, 10:52:55 AM
Thanks Medigeo (hopfly spelt right didn't look) And ill try to make something more newb friendly
Title: Re: ULXToolRestricter
Post by: RecoX on July 06, 2008, 11:07:28 AM
Ive Added the Nweb Freindly stool adder and im also working on allowed players via steam ids is it ply:SteamID() ?
Title: Re: ULXToolRestricter
Post by: jay209015 on July 06, 2008, 03:13:22 PM
The hook needs to be after the function

Code: [Select]
hook.Add( "CanTool", "GetTool", gettool)
This will only work for the first table entry:

Code: [Select]
if ply:SteamID() == Allowed_players then return true
Try something like:

Code: [Select]
table.HasValue(Allowed_players, ply:SteamID()) then return true
And where's the function "UseTool" that you are calling with this hook?

Code: [Select]
hook.Add( "CanTool", "UseTool", UseTool );
Title: Re: ULXToolRestricter
Post by: RecoX on July 07, 2008, 07:20:50 AM
Well getting that it wont checkif your amdin when you slect a tool maybe ill try if you use a tool thats restricted without being an admin
Title: Re: ULXToolRestricter
Post by: RecoX on July 07, 2008, 11:26:28 AM
Ive added Ant-Stool:Anti-Sent Stops a non admin from spawning a sent and has an exclusion list like the others
Title: Re: ULXToolRestricter
Post by: Chief_runningwater on July 07, 2008, 01:32:43 PM
How would I add this to my server, I'm a little confused on how to set this up....
Title: Re: ULXToolRestricter
Post by: RecoX on July 07, 2008, 11:50:20 PM
Well currently you can't as its not checking proply :)
But the way you set it is real simple

Add your steam ids you want it not to affect
and put in lua/autorun
Title: Re: ULXToolRestricter
Post by: Chief_runningwater on July 08, 2008, 11:00:40 AM
Well currently you can't as its not checking proply :)
But the way you set it is real simple

Add your steam ids you want it not to affect
and put in lua/autorun
Thanks that helped a lot now all I need to do is wait till you release it  ;D
Title: Re: ULXToolRestricter
Post by: spbogie on July 08, 2008, 02:14:05 PM
local Restricted_Tools =
-- Add your restrected tools here
{
    "#Anti-NoClip",
   "adv_duplicator",
    "Gcombat",
    "Anti-NoClip",
    "linktool",
   "stacker",
}
--Add your steam id's that this should not affect
local Allowed_players =
{
    "STEAM:1:0:5447", -- Don't forget to remove this  Lay out exactly like that so "STEAM:1:0:88888",    "
}
hook.Add( "CanTool", "GetTool", gettool)
 function gettool(ply, tr, toolmode)
   if Restricted_Tools[toolmode] then
   if pl:IsAdmin() then return true
   if ply:SteamID() == Allowed_players then return true
   if pl:SuperAdmin() then return true
   if return false then  
   ply:PrintMessage(HUD_PRINTTALK, "ULXAnti-Stool: Sorry But your not an Admin, Or In the Excluded Player List")
   end
   end
 end
 hook.Add( "CanTool", "UseTool", UseTool );
Title: Re: ULXToolRestricter
Post by: Chironex on July 09, 2008, 02:00:50 AM
There is more problems, such as using sometimes 'ply', and sometimes 'pl'...and the 'end's being at a wrong place

Try that (i can't test..):
Code: [Select]
-- Add your restrected tools here
local Restricted_Tools =
{
    "#Anti-NoClip",
    "adv_duplicator",
    "Gcombat",
    "Anti-NoClip",
    "linktool",
    "stacker",
}


--Add your steam id's that this should not affect
local Allowed_players =
{
    "STEAM:1:0:5447",
}


function gettool(ply, tr, toolmode)

    if Restricted_Tools[toolmode] then
        if not ply:IsAdmin() and not Allowed_players[ply:SteamID()] then
            ply:PrintMessage(HUD_PRINTTALK, "ULXAnti-Stool: Sorry but you are not allowed to use this STool !! Complain to the admins :)")
            return false
        end
   end

end

hook.Add( "CanTool", "GetTool", gettool)

-- what is that? need the function UseTool : hook.Add( "CanTool", "UseTool", UseTool );

Also you may need to add commands for admins to add/remove steamids and stools dynamically (and so need some file manipulations to save/read tables - not hard).

Once you get it working perfectly, you can release it as a module :) (because actually, it's more a not working snippet :))
Title: Re: ULXToolRestricter
Post by: RecoX on July 10, 2008, 10:59:18 AM
Aggred, This is one of my 1st projects for ulx im tired of having to think if i install this minges will abuse it
Title: Re: ULXToolRestricter
Post by: RecoX on July 10, 2008, 12:10:00 PM
Well it dosn't seem to bother checking what tool is open theres no errors nothing