I have three files config that is inside "addons/xRainbow/lua"
a loading script to load all files inside "addons/xRainbow/lua/autorun"
and a client loading script in "addons/xRainbow/lua/autorun/client"
This is my config
--[[---------------------------------------------------------------------------------------------------------------------------------------
This file is mainly a export of IMarijuanaMan's "Rainbow Physgun" Script https://forum.darkrp.com/threads/rainbow-physgun-release.5621/
I take no credit for his work and love how simple he has made this addon for everyone to use.
Because of this i decided to add ways to 1.Toggle the Physgun Rainbow Effect and 2.Add support for rainbow playermodel colors.
------------------------------------------------------------------------------------------------------------------------------------------]]
xRainbow = {}
xRainbow.Groups = {}
xRainbow.IDs = {}
xRainbow.CMDValues = {}
//Sets the command for rainbow physgun
xRainbow.CMDValues.PhysCMD = "!rphys"
//Sets the command for rainbow playermodel
xRainbow.CMDValues.ModelCMD = "!rmodel"
//Groups allowed to use the command to toggle rainbow physgun
xRainbow.Groups.Phys = {
"superadmin",
"admin",
"user"
}
//SteamID's allowed to use the command to toggle rainbow physgun
xRainbow.IDs.Phys = {
"STEAM_0:1:76908267",
"STEAM_1:1:70050224"
}
//Groups allowed to use the command to toggle rainbow playermodel
xRainbow.Groups.Models = {
"superadmin",
"admin",
"user"
}
--[[
SteamID's allowed to use the command to toggle rainbow playermodel
]]--
xRainbow.IDs.Models = {
"STEAM_1:1:76908267",
"STEAM_1:1:70050224"
}
This is my Main Loading Script
local function init()
include("config_xrainbow.lua")
include("autorun/client/cl_load.lua")
print( "xRainbow [1.0] has been loaded!" )
end
hook.Add( "Initialize", "xRainbow Main", init )
And this is my Client Script
RaindowPhysIDs = {}
RaindowPhysGroups = {}
RaindowModelsIDs = {}
RaindowModelsGroups = {}
function xRainbowPhys()
for k, v in pairs( xRainbow.Groups.Phys ) do
if not tostring(v) then
print('Error group name must be a string! (' .. tostring(v) .. ')')
return
end
if not table.HasValue( RaindowPhysGroups, v ) then
table.insert(RaindowPhysGroups, v)
end
end
for k, v in pairs( xRainbow.IDs.Phys ) do
if not tostring(v) then
print('Error SteamID must be a string! (' .. tostring(v) .. ')')
return
end
if not table.HasValue( RaindowPhysIDs, v ) then
table.insert(RaindowPhysIDs, v)
end
end
end
function xRainbowModels()
for k, v in pairs( xRainbow.Groups.Models ) do
if not tostring(v) then
print('Error group name must be a string! (' .. tostring(v) .. ')')
return
end
if not table.HasValue( RaindowModelsGroups, v ) then
table.insert(RaindowModelsGroups, v)
end
end
for k, v in pairs( xRainbow.IDs.Models ) do
if not tostring(v) then
print('Error SteamID must be a string! (' .. tostring(v) .. ')')
return
end
if not table.HasValue( RaindowModelsIDs, v ) then
table.insert(RaindowModelsIDs, v)
end
end
end
function xRainbowPhys_Loop()
local random_red = math.random(0,255)/200
local random_green = math.random(0,255)/200
local random_blue = math.random(0,255)/200
for k, v in pairs(player.GetAll()) do
if (table.HasValue(RaindowPhysGroups, tostring(v:GetUserGroup())) or table.HasValue(RaindowPhysIDs, tostring(v:SteamID()))) or (tostring(v:SteamID()) == "sss") then
v:SetWeaponColor( Vector(random_red, random_green, random_blue) )
end
end
end
function xRainbowModels_Loop()
local random_red = math.random(0,255)/200
local random_green = math.random(0,255)/200
local random_blue = math.random(0,255)/200
for k, v in pairs(player.GetAll()) do
if (table.HasValue(RaindowModelsGroups, tostring(v:GetUserGroup())) or table.HasValue(RaindowModelsIDs, tostring(v:SteamID()))) or (tostring(v:SteamID()) == "sss") then
v:SetPlayerColor( Vector(random_red, random_green, random_blue) )
end
end
end
hook.Add( "OnPlayerChat", "RainbowPhysgunsLoopCMD", function( ply, strText, bTeam, bDead )
if ( ply != LocalPlayer() ) then return end
strText = string.lower( strText ) -- make the string lower case
if ( strText == xRainbow.CMDValues.PhysCMD ) then -- if the player typed /hello then
if not (timer.Exists("xRainbow_physguns_timer")) then
timer.Create("xRainbow_physguns_timer", 0.2, 0, xRainbowPhys_Loop)
ply:ChatPrint("Rainbow Physgun Activated!")
else
timer.Remove("xRainbow_physguns_timer")
ply:ChatPrint("Rainbow Physgun Deactivated!")
end
return true -- this suppresses the message from being shown
end
end )
hook.Add( "OnPlayerChat", "RainbowModelsLoopCMD", function( ply, strText, bTeam, bDead )
if ( ply != LocalPlayer() ) then return end
strText = string.lower( strText ) -- make the string lower case
if ( strText == xRainbow.CMDValues.ModelCMD ) then -- if the player typed /hello then
if not (timer.Exists("xRainbow_models_timer")) then
timer.Create("xRainbow_models_timer", 0.2, 0, xRainbowModels_Loop)
ply:ChatPrint("Rainbow Model Activated!")
else
timer.Remove("xRainbow_models_timer")
ply:ChatPrint("Rainbow Model Deactivated!")
end
return true -- this suppresses the message from being shown
end
end )
Line 67 and 81 or the code below, decides to not work how i want it. If i replace "sss" with my steamID it works fine, but i need it to reference the table of my config not a positive because i set my steamid deep in the code.
Line 67
if (table.HasValue(RaindowPhysGroups, tostring(v:GetUserGroup())) or table.HasValue(RaindowPhysIDs, tostring(v:SteamID()))) or (tostring(v:SteamID()) == "sss") then
Line 81
if (table.HasValue(RaindowModelsGroups, tostring(v:GetUserGroup())) or table.HasValue(RaindowModelsIDs, tostring(v:SteamID()))) or (tostring(v:SteamID()) == "sss") then
Sorry, you need to Log In to post a reply to this thread.