Flag System on DarkRP

Can somebody tell my why the person using this steam id is still restricted from using the team (whats wront with the script)

[lua]local TablePermission = {
TEAM_SWAT = {“STEAM_0:0:16596001”},
TEAM_SWATSQL = {}
}

local function APermission(ply, t)
for k,v in pairs(TablePermission) do
if t == v then
for _,vTeam in pairs(v) do
if ply.SteamID() == vTeam then
return true
end
end
else
return false
end
end
end
/---------------------------------------------------------
Teams/jobs
---------------------------------------------------------
/
function meta:ChangeTeam(t, force)
if RPArrestedPlayers[self:SteamID()] then
if not self:Alive() then
Notify(self, 1, 4, “You can not change your job whilst being dead in jail.”)
return
else
Notify(self, 1, 4, “You are in Jail. Get a new job when you have been released.”)
return
end
end

self:SetNWBool("helpBoss",false)
self:SetNWBool("helpCop",false)
self:SetNWBool("helpMayor",false)

 if t == TEAM_SWAT and not APermission(self, t) then 

Notify(self, 1, 4, “Access to this team is restricted”)
return
end
[/lua]


if t == v then

should be


if t == k then

on line 8.

It still doesnt work maybe theres something else no working?


if ply.SteamID() == vTeam then

on line 10 should be


if ply:SteamID() == vTeam then

Still does not work :S

Change this


local TablePermission = {
TEAM_SWAT = {"STEAM_0:0:16596001"},
TEAM_SWATSQL = {}
} 

to


local TablePermission = {
[TEAM_SWAT] = {"STEAM_0:0:16596001"},
[TEAM_SWATSQL] = {}
} 

appearantly i made a lot of mistakes i will tell you if it works soon

It would have been alot easier if you gave us the errors this code produced from the console (if any).

theres no error code in the console it just tells me the team is restricted even if i have the good steam ID

also heres what it looks like now

[lua]local TablePermission = {
[TEAM_SWAT] = {“STEAM_0:0:16596001”},
]TEAM_SWATSQL] = {}
} – TABLE : Table des SteamIDs autorisées par équipe

local function APermission(ply, t) – FONCTION : Fonction qui vérifie si un joueur est autorisé
for k,v in pairs(TablePermission) do – BOUCLE : Pour chaque entrée dans la table TablePermission
if t == k then – CONDITION : Si l’équipe désirée est la même que la valeur,
for _,vTeam in pairs(v) do – BOUCLE : Pour chaque entrée dans la table TablePermission.v
if ply:SteamID() == vTeam then – CONDITION : Si le steamID du joueur est la même que la valeur,
return true – Retourner la valeur Vrai
end – Fin de la condition
end-- Fin de la boucle
else – Sinon
return false – Retourner Faux
end – Fin de la condition
end – Fin de la boucle
end – Fin de la fonction
/---------------------------------------------------------
Teams/jobs
---------------------------------------------------------
/
function meta:ChangeTeam(t, force)
if RPArrestedPlayers[self:SteamID()] then
if not self:Alive() then
Notify(self, 1, 4, “You can not change your job whilst being dead in jail.”)
return
else
Notify(self, 1, 4, “You are in Jail. Get a new job when you have been released.”)
return
end
end

self:SetNWBool("helpBoss",false)
self:SetNWBool("helpCop",false)
self:SetNWBool("helpMayor",false)

 if t == TEAM_SWAT and not APermission(self, t) then -- Remplace TEAM_MONEQUIPE par le nom de ton équipe perso. CONDITION : Si le joueur essais de changer pour l'équipe TEAM_MONEQUIPE et s'il n'a PAS la permission alors

Notify(self, 1, 4, “Access to this team is restricted”) – L’avertir
return – Terminer l’éxécution de la fonction
end – Fin de la condition[/lua]

and a new error code that apeared when i added around teams

darkrp/gamemode/player.lua:170: unexpected symbol near ‘]’

On line 3 you have ‘]’ instead of ‘[’.

ok thanks you the thing works now also a simple thing can you tell me what is the player model for gign and sas cuz my player models are Tminge lol

I have no idea :v:

[editline]06:28PM[/editline]

Found them:


models/player/ct_gign.mdl


models/player/ct_sas.mdl

using this i get Tminge

[lua]TEAM_SWAT = AddExtraTeam(“SWAT”, Color(20, 200, 100, 255), “models/player/ct_gign.mdl”, [[ Members of the SWAT are not there to patrol.
They assault building on order of the police chief only.
They search for drugs.
They deal with dangerous criminals.]], {“arrest_stick”,“weapon_m42”, “unarrest_stick”, “weapon_deagle2”, “stunstick”, “door_ram”, “weaponchecker”, “item_ammo_pistol”}, “SWAT”, 3, 75, 0, false, true, TEAM_POLICE)[/lua]

I have never messed around mith player models, so i have no clue how they work and how to change them in Lua. Sorry.

You can do SetModel() but that will mess up animations.