Hello, I installed pac3 on my server, and I wanted to restrict it so that only vips and up would be able to use it.
I put this code in garrysmod/lua/autorun/server and named it pac3restriction.lua:
[lua] hook.Add("PrePACConfigApply", "vips only", function(ply, outfit_data)
if not ply:Isvip() then
return false, "You need to donate!"
end
end)
[/lua]
For some reason it still let's users use it, am I putting it in the wrong file or something? Any help would be appreciated.
Show us your "Isvip" function.
I don't know how to do that, but the ulx rank is called "vip"
[QUOTE=Tetris God;47458501]I don't know how to do that, but the ulx rank is called "vip"[/QUOTE]
[lua]Player:IsUserGroup("vip")[/lua]
So would the correct code be this?
[lua]
hook.Add("PrePACConfigApply", "vips only", function(ply, outfit_data)
if not Player:IsUserGroup("vip") then
return false, "You need to donate!"
end
end)
[/lua]
[QUOTE=Tetris God;47458757]So would the correct code be this?
[lua]
hook.Add("PrePACConfigApply", "vips only", function(ply, outfit_data)
if not Player:IsUserGroup("vip") then
return false, "You need to donate!"
end
end)
[/lua][/QUOTE]
Yes but you should use CheckUserGroup if you have ranks above VIP that should also get permission.
And Player should be ply
So the absolute final code would be:
[lua]
hook.Add("PrePACConfigApply", "vip and up only", function(ply, outfit_data)
if not ply:CheckUserGroup("vip") then
return false, "You need to donate!"
end
end)
[/lua]
Update: It still doesn't work, users are able to use PAC3.
[QUOTE=Tetris God;47458834]So the absolute final code would be:
[lua]
hook.Add("PrePACConfigApply", "vip and up only", function(ply, outfit_data)
if not ply:CheckUserGroup("vip") then
return false, "You need to donate!"
end
end)
[/lua]
Update: It still doesn't work, users are able to use PAC3.[/QUOTE]
wh1t3rabbit was along the right lines.
I believe the function is CheckGroup, not CheckUserGroup.
[url]http://ulyssesmod.net/docs/files/lua/ulib/shared/sh_ucl-lua.html#Player:CheckGroup[/url]
[editline]6th April 2015[/editline]
For your purposes however, I imagine IsUserGroup should be fine too
This is laughable and probably illegal. Why would anyone donate to use pac when they can go to any other server and use it?
[QUOTE=thegrb93;47469087]This is laughable and probably illegal. Why would anyone donate to use pac when they can go to any other server and use it?[/QUOTE]
Wouldn't say it's illegal - the guy is providing a service, for people to play on if they choose to. They have the option to have more in-game privileges if they choose to pay. Still a bit of a dick move though.
That being said, you gotta do what you gotta do to make money. Server costs and all.
I'd make it for users too, but people always find a way to minge with it. I've seen people set their model to giant 50 foot robots.. So I've resorted to this. Can't trust people anymore.
[QUOTE=thegrb93;47469087]This is laughable and probably illegal. Why would anyone donate to use pac when they can go to any other server and use it?[/QUOTE]
It's documented on the Github with this example so. It's mainly for DarkRP servers, not your typical Sandbox.
[QUOTE=r0uge;47469410]Wouldn't say it's illegal - the guy is providing a service, for people to play on if they choose to. They have the option to have more in-game privileges if they choose to pay. Still a bit of a dick move though.
That being said, you gotta do what you gotta do to make money. Server costs and all.[/QUOTE]
[url]http://www.irs.gov/taxtopics/tc420.html[/url]
As long as you file your Form 1099-B
Not everyone comes from America you know so these rules are not always going to apply.
Well, I read that thing you posted,
and in my opinion, I believe that,
[URL="http://redostri.ch/share/Tax_Topics_-_Topic_420_Bartering_Income_-_Google_C_2015-04-07_11-38-32.png"]oh uh sorry idk I got distracted[/URL]
I have:
[lua]
hook.Add("PrePACConfigApply", "vip and up only", function(ply, outfit_data)
if not ply:IsUserGroup("vip") then
return false, "You need to donate!"
end
end)
[/lua]
and it's still not working! I don't get it, this should be perfect right?
It works for vip's but nobody else above vip.
Then add the groups above VIP then?
[I][/I][QUOTE=Tetris God;47502070]It works for vip's but nobody else above vip.[/QUOTE]
If the groups inherit from vip then you can use CheckGroup instead of IsUserGroup. If they don't inherit from vip then you need to do multiple checks separated by or.
This is an Old post but how would one add multiple user groups?
Try this man,
local allowedgroups = {
"vip",
"vip+",
"mod",
"admin",
"superadmin",
"owner",
"coowner",
"member",
"respected",
"comesoften"
}
hook.Add("PrePACConfigApply", "DonatorRestrict", function(ply, outfit_data)
if (!table.HasValue(allowedgroups, ply:GetUserGroup())) then
return false, "Join the group !steam or play 1 hr"
end
end)
Sorry, you need to Log In to post a reply to this thread.