CATEGORY_NAME = "Jailbreak"
//Ban Guard
/*
[ERROR] addons/ulx/lua/ulx/modules/sh/jailbreak2.lua:13: attempt to index local 'target' (a nil value)
1. call - addons/ulx/lua/ulx/modules/sh/jailbreak2.lua:13
2. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
3. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
4. unknown - lua/includes/modules/concommand.lua:69
*/
function ulx.guardban( calling_ply, target )
local gban = tonumber(target:GetPData("gbanstate")) or 0
if ulx.getExclusive(calling_ply, target) then
ULib.tsayError( calling_ply, ulx.getExclusive( target, calling_ply ), true )
elseif gban == 1 then
ULib.tsayError( calling_ply, "Your target is already banned from the guard team!", true)
elseif gban == 0 then
forcechangeteam(calling_ply, target)
target:SetPData("gbanstate", 1)
GAMEMODE:Notify("You have been banned from the guard team", target)
end
end
local guardban = ulx.command( CATEGORY_NAME, "ulx guardban", ulx.guardban, "!guardban" )
guardban:defaultAccess( ULib.ACCESS_ADMIN )
guardban:help("Bans the targeted player from being on the guard team.")
//Unban Guard
/*
[ERROR] addons/ulx/lua/ulx/modules/sh/jailbreak2.lua:39: attempt to index local 'target' (a nil value)
1. call - addons/ulx/lua/ulx/modules/sh/jailbreak2.lua:39
2. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
3. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
4. unknown - lua/includes/modules/concommand.lua:69
*/
function ulx.unguardban( calling_ply, target )
local gban = tonumber(target:GetPData("gbanstate")) or 0
if ulx.getExclusive(calling_ply, target) then
ULib.tsayError( calling_ply, ulx.getExclusive( target, calling_ply ), true )
elseif gban == 0 then
ULib.tsayError( calling_ply, "Your target is not banned from the guard team!", true)
elseif gban == 1 then
target:RemovePData("gbanstate")
GAMEMODE:Notify("You have been unbanned from the guard team", target)
ulx.fancyLogAdmin( calling_ply, "#A has banned #T from the guard team.", target)
end
end
local unguardban = ulx.command( CATEGORY_NAME, "ulx unguardban", ulx.unguardban, "!unguardban" )
unguardban:defaultAccess( ULib.ACCESS_ADMIN )
unguardban:help( "Unbans the selected target from the guard team." )
// PrintGuardBan
/*
[ERROR] addons/ulx/lua/ulx/modules/sh/jailbreak2.lua:65: attempt to index local 'target' (a nil value)
1. call - addons/ulx/lua/ulx/modules/sh/jailbreak2.lua:65
2. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
3. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
4. unknown - lua/includes/modules/concommand.lua:69
*/
function ulx.printguardban( calling_ply, target )
local gban = tonumber(target:GetPData("gbanstate")) or 0
if gban == 0 then
calling_ply:ChatPrint( target:Nick() .. " is not banned" )
elseif gban == 1 then
calling_ply:ChatPrint( target:Nick() .. " is banned." )
end
end
local printguardban = ulx.command( CATEGORY_NAME, "ulx printguardban", ulx.printguardban, "!printguardban" )
printguardban:defaultAccess( ULib.ACCESS_ADMIN )
printguardban:help( "Prints whether the target is banned from the guard team." )
// Change Team
function forcechangeteam( calling_ply, target_ply )
if ulx.getExclusive( target_ply, calling_ply ) then
ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true );
else
if (target_ply:Team() == TEAM_PRISONER) then
result = TEAM_GUARD;
elseif (target_ply:Team() == TEAM_PRISONER_DEAD) then
result = TEAM_GUARD_DEAD;
elseif (target_ply:Team() == TEAM_GUARD) then
result = TEAM_PRISONER;
elseif (target_ply:Team() == TEAM_GUARD_DEAD) then
result = TEAM_PRISONER_DEAD;
end
if (result) then
if (result == TEAM_GUARD or result == TEAM_PRISONER) then
target_ply.jb_ForceAlive = true;
end
target_ply:SetTeam(result);
target_ply:Spawn();
GAMEMODE:Notify(calling_ply:Name().." has force-swapped "..target_ply:Name()..".");
else
GAMEMODE:Notify("Couldn't find a team for "..target_ply:Name()..".", target_ply);
end
end
end