• Setting VIP fuctions for DarkRP jobs
    10 replies, posted
Hi, I am custom coding Jackool's Liquid RP, a remake of DarkRP. It runs off DarkRP with many added files. Jackool has added the following function that adds players to VIP, and I'm having trouble usuing that VIP function to restrict certain jobs to VIP only. Here is the fuction jackool uses: [code] local meta=FindMetaTable("Player") function meta:IsVIP() -- VIP system is small only for release. Edit as you desire return (table.HasValue(LDRP.AllVIPs,self:SteamID())) or self:IsAdmin() end [/code] All my attempts simply result in the job breaking and disapearring from the job list. Thanks everyone!
Here's on ething I tried. I placed the following into player.lua. It ended up breaking the file, and therefore the whole gamemode. The starred/commented out section is where I edited. [code] function meta:ChangeTeam(t, force) if RPArrestedPlayers[self:SteamID()] and not force then if not self:Alive() then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "")) return else Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "")) return end end self:SetDarkRPVar("helpBoss",false) self:SetDarkRPVar("helpCop",false) self:SetDarkRPVar("helpMayor",false) if t ~= TEAM_CITIZEN and not self:ChangeAllowed(t) and not force then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "banned/demoted")) return end if self.LastJob and 10 - (CurTime() - self.LastJob) >= 0 and not force then Notify(self, 1, 4, string.format(LANGUAGE.have_to_wait, math.ceil(10 - (CurTime() - self.LastJob)), "/job")) return end if self.IsBeingDemoted then self:TeamBan() vote.DestroyVotesWithEnt(self) Notify(self, 1, 4, "You tried to escape demotion. You failed, and have been demoted.") end if self:Team() == t then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "")) return end local TEAM = RPExtraTeams[t] if not TEAM then return end if not self.DarkRPVars["Priv"..TEAM.command] and not force then if type(TEAM.NeedToChangeFrom) == "number" and self:Team() ~= TEAM.NeedToChangeFrom then Notify(self, 1,4, string.format(LANGUAGE.need_to_be_before, team.GetName(TEAM.NeedToChangeFrom), TEAM.name)) return elseif type(TEAM.NeedToChangeFrom) == "table" and not table.HasValue(TEAM.NeedToChangeFrom, self:Team()) then local teamnames = "" for a,b in pairs(TEAM.NeedToChangeFrom) do teamnames = teamnames.." or "..team.GetName(b) end Notify(self, 1,4, string.format(string.sub(teamnames, 5), team.GetName(TEAM.NeedToChangeFrom), TEAM.name)) return end if GetConVarNumber("max"..TEAM.command.."s") and GetConVarNumber("max"..TEAM.command.."s") ~= 0 and team.NumPlayers(t) >= GetConVarNumber("max"..TEAM.command.."s")then Notify(self, 1, 4, string.format(LANGUAGE.team_limit_reached, TEAM.name)) return end end if self:Team() == TEAM_MAYOR and tobool(GetConVarNumber("DarkRP_LockDown")) then UnLockdown(self) end self:UpdateJob(TEAM.name) DB.StoreSalary(self, TEAM.salary) NotifyAll(0, 4, string.format(LANGUAGE.job_has_become, self:Nick(), TEAM.name)) if self.DarkRPVars.HasGunlicense then self:SetDarkRPVar("HasGunlicense", false) end if TEAM.Haslicense and GetConVarNumber("license") ~= 0 then self:SetDarkRPVar("HasGunlicense", true) end self.LastJob = CurTime() /* -- I ADDED STUFF HERE::::::::::::::::::::::::::::::::::::::::::::::::: if t == TEAM_HITMAN and !meta:IsVIP() then Notify(self, 1, 4, string.format("This job is donator only!")) return end if t == TEAM_VIPGANG and !meta:IsVIP()) then Notify(self, 1, 4, string.format("This job is donator only!")) return end if t == TEAM_VIPBOSS and !meta:IsVIP() then Notify(self, 1, 4, string.format("This job is donator only!")) return end -- I STOPPED EDITING HERE :::::::::::::::::::::::::::::::::::::::::::::::::::: */ if t == TEAM_POLICE then self:SetDarkRPVar("helpCop", true) elseif t == TEAM_MOB then self:SetDarkRPVar("helpBoss", true) elseif t == TEAM_MAYOR then self:SetDarkRPVar("helpMayor", true) end [/code]
Oh, I also tried adding the first function as an "extra check" at the end of each job that requires VIP only. It resulted in each job breaking and not showing up on the f4 menu.
Still stumped everyone! No idea how to do this still. I'd like to add that VIP's are saved in a .txt files in the data folder, since Jackool, the creator or LiquidDRP, didnt optimize with sql
[QUOTE=Phishcook;36268357]Still stumped everyone! No idea how to do this still. I'd like to add that VIP's are saved in a .txt files in the data folder, since Jackool, the creator or LiquidDRP, didnt optimize with sql[/QUOTE] Nearly 200 veiws with 0 comments? Come one now I know I didn't stump the FP communty :P
Another bump for a clueless coder, Please help me out guys/gals!
Why the fuck are you calling string.format? You don't need it. Get rid of it, especially since you aren't even calling it correctly, which may be why its fucking up... Also, no one is replying because you are not giving us errors, line numbers, etc. Give us something to work off of before you just say "Here, fix my code". [code] if t == TEAM_HITMAN and !meta:IsVIP() then Notify(self, 1, 4, "This job is donator only!)) return end if t == TEAM_VIPGANG and !meta:IsVIP()) then Notify(self, 1, 4, ("This job is donator only!") return end if t == TEAM_VIPBOSS and !meta:IsVIP() then Notify(self, 1, 4, "This job is donator only!") return end [/code] [editline]12th June 2012[/editline] Also, it would be more efficient to modify it so all your VIP lines are in 1 if statement with OR's since you are doing the same shit each time.
-snip- I can't read for shit.
[QUOTE=SeveredSkull;36303336]Why the fuck are you calling string.format? You don't need it. Get rid of it, especially since you aren't even calling it correctly, which may be why its fucking up... Also, no one is replying because you are not giving us errors, line numbers, etc. Give us something to work off of before you just say "Here, fix my code". [code] if t == TEAM_HITMAN and !meta:IsVIP() then Notify(self, 1, 4, "This job is donator only!)) return end if t == TEAM_VIPGANG and !meta:IsVIP()) then Notify(self, 1, 4, ("This job is donator only!") return end if t == TEAM_VIPBOSS and !meta:IsVIP() then Notify(self, 1, 4, "This job is donator only!") return end [/code] [editline]12th June 2012[/editline] Also, it would be more efficient to modify it so all your VIP lines are in 1 if statement with OR's since you are doing the same shit each time.[/QUOTE] [lua] if ( t == TEAM_HITMAN or t == TEAM_VIPGANG or t == TEAM_VIPBOSS ) and not self:IsVIP() then Notify(self, 1, 4, "This job is donator only!)) return end [/lua]
[code] function meta:ChangeTeam(t, force) if RPArrestedPlayers[self:SteamID()] and not force then if not self:Alive() then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "")) return else Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "")) return end end self:SetDarkRPVar("helpBoss",false) self:SetDarkRPVar("helpCop",false) self:SetDarkRPVar("helpMayor",false) if t ~= TEAM_CITIZEN and not self:ChangeAllowed(t) and not force then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "banned/demoted")) return end if self.LastJob and 10 - (CurTime() - self.LastJob) >= 0 and not force then Notify(self, 1, 4, string.format(LANGUAGE.have_to_wait, math.ceil(10 - (CurTime() - self.LastJob)), "/job")) return end if self.IsBeingDemoted then self:TeamBan() vote.DestroyVotesWithEnt(self) Notify(self, 1, 4, "You tried to escape demotion. You failed, and have been demoted.") end if self:Team() == t then Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "")) return end local TEAM = RPExtraTeams[t] if not TEAM then return end if not self.DarkRPVars["Priv"..TEAM.command] and not force then if type(TEAM.NeedToChangeFrom) == "number" and self:Team() ~= TEAM.NeedToChangeFrom then Notify(self, 1,4, string.format(LANGUAGE.need_to_be_before, team.GetName(TEAM.NeedToChangeFrom), TEAM.name)) return elseif type(TEAM.NeedToChangeFrom) == "table" and not table.HasValue(TEAM.NeedToChangeFrom, self:Team()) then local teamnames = "" for a,b in pairs(TEAM.NeedToChangeFrom) do teamnames = teamnames.." or "..team.GetName(b) end Notify(self, 1,4, string.format(string.sub(teamnames, 5), team.GetName(TEAM.NeedToChangeFrom), TEAM.name)) return end if GetConVarNumber("max"..TEAM.command.."s") and GetConVarNumber("max"..TEAM.command.."s") ~= 0 and team.NumPlayers(t) >= GetConVarNumber("max"..TEAM.command.."s")then Notify(self, 1, 4, string.format(LANGUAGE.team_limit_reached, TEAM.name)) return end end if ( t == TEAM_HITMAN or t == TEAM_VIPGANG or t == TEAM_VIPBOSS ) and not self:IsVIP() then Notify(self, 1, 4, "This job is donator only!)) return end if self:Team() == TEAM_MAYOR and tobool(GetConVarNumber("DarkRP_LockDown")) then UnLockdown(self) end self:UpdateJob(TEAM.name) DB.StoreSalary(self, TEAM.salary) NotifyAll(0, 4, string.format(LANGUAGE.job_has_become, self:Nick(), TEAM.name)) if self.DarkRPVars.HasGunlicense then self:SetDarkRPVar("HasGunlicense", false) end if TEAM.Haslicense and GetConVarNumber("license") ~= 0 then self:SetDarkRPVar("HasGunlicense", true) end self.LastJob = CurTime() if t == TEAM_POLICE then self:SetDarkRPVar("helpCop", true) elseif t == TEAM_MOB then self:SetDarkRPVar("helpBoss", true) elseif t == TEAM_MAYOR then self:SetDarkRPVar("helpMayor", true) end [/code]
[QUOTE=SeveredSkull;36303336] Also, it would be more efficient to modify it so all your VIP lines are in 1 if statement with OR's since you are doing the same shit each time.[/QUOTE] [QUOTE=Derek_SM;36333540][lua] if ( t == TEAM_HITMAN or t == TEAM_VIPGANG or t == TEAM_VIPBOSS ) and not self:IsVIP() then Notify(self, 1, 4, "This job is donator only!)) return end [/lua][/QUOTE] Thanks. I'm having an issue with my browser where I cant edit posts or it puts everything on a single line.
Sorry, you need to Log In to post a reply to this thread.