Ulysses

General => Developers Corner => Topic started by: Samg381 on February 24, 2014, 05:22:31 PM

Title: How to restrict ENTITIES and WEAPONS?
Post by: Samg381 on February 24, 2014, 05:22:31 PM
For about a year now this question has yet to be answered. I've tried asking experts, lua coders, friends, almost everybody who could have expertise.
All the answers and codes that I have received have not worked. Not a single one.

The question is:
How do I restrict Weapons, and Entities on a server based upon a ULX rank with lua code?
(I do not want to use "URS" or any other addon whatsoever)

Whenever I try a new code, either I get errors, or the code has absolutely no effect whatsoever.
Some of these are for entities and some are for weapons. Nevertheless, they all don't work.

Here are all the codes that have failed:

Code: [Select]
function ENT:SpawnFunction(ply, tr)    if ply:IsUserGroup("user") then
        ply:ChatPrint("You must be a donator to use this item!")
    return
end


Code: [Select]
if not ply:IsUserGroup("donator") thenply:ChatPrint("You must be a donator to use this item!")
     return
end


Code: [Select]
function checkAdmin(ply)
     if not ply:IsUserGroup("donator") then
ply:ChatPrint("You must be a donator to use this item!")
    end
end

Code: [Select]
function DenySWEPs(ply, class)
    if not ply:IsUserGroup("donator") then
        ply:ChatPrint("You must be a donator to use this item!")
        return false
    end
end
hook.Add("PlayerSpawnSWEP", "DenySWEPs", DenySWEPs)

Code: [Select]
function checkAdmin(ply)
     if not ply:IsUserGroup("donator") then
    ply:ChatPrint("You must be a donator to use this item!")
    end
end



I am looking for somebody who would be kind enough to assist me in making a code that works.
All codes that I posted above are free game, but individually they are about as useful as a '--'.
I don't care how it is written, or how complex the code is. I need to get this working period.
As an added bonus, if you could help explain what you did and how the code works I'd be very appreciative.
I am a novice coder and I need to learn about this stuff in order to expand my knowledge.

Sorry for the rant.
Thanks in advance!
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 24, 2014, 06:24:12 PM
i am the same way im new but everyone says try something simpler but i dont thing you can get much simpler than a 20 line code and they keep saying you need to learn before i can do that but i cant learn without trying i dont work that way lol but i failed to help you i am sorry i tryed a few things but i guess you need someone smarter than me :/ sorry i couldnt help
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Eccid on February 24, 2014, 09:09:41 PM
..(I do not want to use "URS" or any other addon whatsoever)..

Why? It's what you're looking for, exactly, and is already written/free to use. Are you looking for someone to help you make something to sell or something? It seems strange that you refuse to use the one system that works (and seem to think that these experts can't figure it out, considering it exists).

i am the same way im new but everyone says try something simpler but i dont thing you can get much simpler than a 20 line code and they keep saying you need to learn before i can do that but i cant learn without trying i dont work that way lol but i failed to help you i am sorry i tryed a few things but i guess you need someone smarter than me :/ sorry i couldnt help

Who cares if it's 20 lines of code or 200, as long as it works?
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Neku on February 24, 2014, 10:44:19 PM
I don't understand why you wouldn't use URS.

And I can see you want to understand how to do it as well.
Just download URS and crack up the Lua file open.

Open up notepad or whatever else you're using to code, and start typing every line of code by hand.

You'll need to understand the basics first, though.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Samg381 on February 25, 2014, 03:59:48 AM
I do not want to use URS for a variety of reasons, predominantly the inability to change the message that appears when an entity has been blocked.
I'm not going to change the URS blocked message because I use it for other entities.

I would like to lua code. Not URS. If I wanted to URS I would have already done so. There is nothing you can say to make me think otherwise.
I'm looking for a lua code that is compatible with Garry's Mod 13 that will block entities and weapons via ULX ranks.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Megiddo on February 25, 2014, 06:22:57 AM
As stated above, if you don't want to use URS, at least look and see how it restricts so you understand why your approach isn't working.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 25, 2014, 12:35:52 PM
hey if you REALLY really wanted to it is possible to change it you just have to have a little bit of lua knowlege and know what goes where and what does what :P
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Samg381 on February 25, 2014, 12:44:21 PM
hey if you REALLY really wanted to it is possible to change it you just have to have a little bit of lua knowlege and know what goes where and what does what :P


That's why I'm asking someone to help.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lynx on February 25, 2014, 01:05:32 PM
As multiple people have stated so far, get URS. You don't have to use it, but if you want to learn then learn by example. Look through the code in URS, see what it uses to make deny happen. Then adapt that to your own wants and needs.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 25, 2014, 02:06:34 PM

That's why I'm asking someone to help.
sorry i meant you could change the urs user msg but if that is the only reason cant you get past that i mean it is working and you dont have to do anything :) but if you dont want it then thats whatever i mean but you can probably get some knowlege from google :P or lua tuts like if you watch the gamemode lua tuts it takes awhile but when you make it its kinda basic but you know alot of lua :)
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Cobalt on February 25, 2014, 02:21:41 PM
I do not want to use URS for a variety of reasons, predominantly the inability to change the message that appears when an entity has been blocked.
I'm not going to change the URS blocked message because I use it for other entities.

I would like to lua code. Not URS. If I wanted to URS I would have already done so. There is nothing you can say to make me think otherwise.
I'm looking for a lua code that is compatible with Garry's Mod 13 that will block entities and weapons via ULX ranks.
Hey there's this cool addon called URS, don't know if you have heard of it but you might want to check it out. It's exactly what you need and you can even change the message that appears when you try to spawn an entity.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Eccid on February 25, 2014, 04:49:42 PM
Hey there's this cool addon called URS, don't know if you have heard of it but you might want to check it out. It's exactly what you need and you can even change the message that appears when you try to spawn an entity.

This guy knows what's up.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: JamminR on February 25, 2014, 07:12:35 PM
Just to be clear Samg, most of us aren't asking you to USE URS.
We're suggesting you review the code in URS to see how it ticks.

Overall, it uses the same hooks and checks for ULib groups any other code would.

Best way to learn...by example.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Neku on February 25, 2014, 07:15:28 PM
tl;dr Download URS. Do not use. Look at code.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 25, 2014, 07:21:40 PM
Just to be clear Samg, most of us aren't asking you to USE URS.
We're suggesting you review the code in URS to see how it ticks.

Overall, it uses the same hooks and checks for ULib groups any other code would.

Best way to learn...by example.
And by doing it yourself(meaning you cant learn by watching you can only learn by doin) :P
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: MrPresident on February 26, 2014, 02:08:39 AM
I learned LUA by looking at example code to see how it worked. Now I'm the greatest LUA coder on the planet. It is known.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Eccid on February 26, 2014, 12:17:03 PM
I learned LUA by looking at example code to see how it worked. Now I'm the greatest LUA coder on the planet. It is known.

You can't argue with that, because it's true.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 26, 2014, 01:30:30 PM
yeah i learned (the little i know lol) in a few days by making a code from an example that i used and modified it
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Samg381 on February 26, 2014, 01:42:34 PM
I really want to learn bad. I would have so many applications for it but I've never learned much by looking at others codes.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 26, 2014, 01:57:48 PM
OK uh well go to youtube and find a good series OK? and then just pretty much do what they do then you'll learn the basics fast and if there is something you forget then just look on google there are a lot of archives and stuff but yeah just look up lua tut or something on youtube and it doesn't necessarily have to be an addon. Hope this helps!
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: JamminR on February 26, 2014, 02:02:52 PM
Quote
on the planet. It is known.
Virtual Planets in your self-made gamemodes don't count!

Sam,
This Swep Hook you posted for SWEPS should work, as long as it's running on the server.
Code: [Select]
function DenySWEPs(ply, class)
    if not ply:IsUserGroup("donator") then
        ply:ChatPrint("You must be a donator to use this item!")
        return false
    end
end
hook.Add("PlayerSpawnSWEP", "DenySWEPs", DenySWEPs)
What do you not understand about it?
What doesn't work about it?
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Samg381 on February 27, 2014, 02:28:19 PM
Well, I placed it in the code and it had no effect whatsoever. Not sure what the issue is.

However, I have found a workaround and I am no longer in need of a quick solution.
Although a universal Entity/Swep User restrict code would be handy, I might just forget it.
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: lampman13 on February 28, 2014, 04:59:58 PM
can you tell me your work around please?
Title: Re: How to restrict ENTITIES and WEAPONS?
Post by: Samg381 on March 04, 2014, 02:07:15 PM
Sure.
I opened the URS configuration "urs_server.lua", and made a custom code on line 8.
It pretty much makes any user who spawns a donator+ weapon get a "You need to buy donator" message,
and everyone who is already a donator get the message "This entity is restricted for your group".