Ulysses
General => Developers Corner => Topic started by: bender180 on January 25, 2013, 08:52:47 PM
-
Basically what i want to do is make it so you have to be in a certain group to become a job in darkrp.
I've tried using the method falco posted on the google code page for the project Ive tried editing the player.lua for darkrp nothing is working.
Is there anyone who knows how i can do this?
-
http://forums.ulyssesmod.net/index.php/topic,5532.msg25265.html#msg25265
-
http://forums.ulyssesmod.net/index.php/topic,5532.msg25265.html#msg25265
Ive tried that method it doesnt seem to work.
-
I can't believe I am able to help on here but go to: "gamemodes\darkrp\gamemode\server" and edit the file, "player.lua"
Hit ctrl + F and Search for "meta:ChangeTeam"
Once there, Do something like this:
if t == TEAM_ADMIN then
if self:IsUserGroup("testgrouphere") then
GAMEMODE:Notify( self, 1, 4, "You are not the proper group for this job!")
return false
end
end
Or if you want it to be admin AND a certain group:
if t == TEAM_ADMIN then
if !self:IsAdmin() or !self:IsUserGroup("testgrouphere") then
GAMEMODE:Notify( self, 1, 4, "You are not the proper group for this job!")
return false
end
end
So final code should look like this:
function meta:ChangeTeam(t, force)
if t == TEAM_ADMIN then
if !self:IsAdmin() or self:IsUserGroup("sergant") then
umsg.Start("Problem", self)
umsg.End()
return false
end
end
(SS: http://puu.sh/1SYQa ) *My setup is more advanced, It responds back with a colorful Error =D*
-
if i did this:
if t == TEAM_BUS then
if !self:IsUserGroup("vip") or self:CheckGroup("superadmin") then
GAMEMODE:Notify( self, 1, 4, "You must be a VIP to play as this job! Donate to become VIP!")
umsg.Start("Problem", self)
umsg.End()
return false
end
end
Would it still work? I want it to be a vip only job but then i want it so all the groups superadmin and up get it.
-
never mind the last message got the effect i wanted using:
if t == TEAM_BUS then
if !self:IsSuperAdmin() or self:IsUserGroup("vip") then
GAMEMODE:Notify( self, 1, 4, "You must be a VIP to play as this job! Donate to become VIP!")
return false
end
end
Well the superadmin and up part is working but vip is receiving the "You must be a VIP to play as this job! Donate to become VIP!"
Heres what my code looks like https://dl.dropbox.com/u/2418443/Capture.JPG
-
the ulx group NEEDS to be EXACTLY like the name you made when you made the group, and the TEAM_W/E Needs to be the exact name in the shared.lua.
Other than that, It looks fine
Edit: Wait, nvm, I re-read the code, I see the issue:
This:
if !self:IsSuperAdmin() or self:IsUserGroup("vip") then
needs to be this:
if !self:IsSuperAdmin() or !self:IsUserGroup("vip") then
you didn't add the ! before self:IsUsergroup("VIP")
That ! means if NOT self:IsSuperAdmin(), Its easier to type ! than if not. xD
-
You are welcome BTW......
-
You are welcome BTW......
Wow how did i forget to says thanks, sorry for the length of time that has passed but thaks for the help.
-
hi, that's not working for me. Nobody can be the job :/
Edit: Never mind, fixed
if t == TEAM_SWORD then
if !self:IsAdmin() and !self:IsUserGroup("donator") then
GAMEMODE:Notify( self, 1, 4, "You must be a donator to play as this job! Donate to get it!")
return false
end
end
After !self:IsAdmin(), it should be an and, not an or
-
pazda, the way you express it, your player wanting to be that job must be an admin and a donator.
It's difficult to be two groups at once, unless you're in a Ulib group where donator inherits admin (I _think_ that would work)
-
! in lua means not, so it's saying if you're not an admin and if you're not a donator then do that
If it weren't for the !s, you'd be right. It's been working fine on my server.
-
If you took the time to have a look yourself, you would have found the article on the DarkRP wiki (http://darkrp.com) regarding custom jobs and that includes code to make it usergroup dependent
-
The page doesn't exist anymore.
-
You can also do so that, only 1 ULX rank or FAdmin rank and or admins can use the job.
Use this code:
customCheck = function(ply) return ply:CheckGroup("donator") or ply:IsAdmin() end,
If you're using FAdmin replace
ply:CheckGroup("donator")
with
ply:GetNWString("usergroup") == "donator" or ply:IsAdmin
Job Example:
TEAM_DONATORJOB = DarkRP.createJob("Swat", -- Name
color = Color(238, 99, 99, 255), -- Team color
model = "models/player/mossman.mdl", -- Player model
description = [[As a cook, it is your responsibility to feed the other members of your city.
You can spawn a microwave and sell the food you make: /Buymicrowave]], -- Job description
weapons = {}, -- Additional weapons
command = "Swat", -- Command to become the job
max = 2, -- Maximum amount of said job
salary = 45, -- Salary
admin = 0, -- Requires Admin? 1 for yes, 0 for no.
vote = false, -- Do they need to vote? true for yes, false for no.
hasLicense = false, -- Has a license
customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" or ply:IsAdmin() end, -- The extra check function. Enter nil or nothing to not have a restriction