I have been working on a BASIC client side menu for my staff (I'm not good at lua), and I am having trouble on having My Rainbow Physics Gun and Rainbow playermodel showing up for other players,
Here's What's Happening:
If the player with the "owner" rank has the "Enable Rainbow Playermodel" or "Enable Rainbow Physics Gun" checked, only the PLAYER can see it. Not everyone.
Don't worry about the bhop, as that is working 100% fine.
Here's the code for the entire menu, (not much put into it yet)
[CODE]local tdb = {}
local function AddConvar(Name, Value)
CreateClientConVar(Name, Value)
end
tdb.cvars = {
{ Name = "tdb_bhop", Value = 0 },
{ Name = "tdb_glowmodel", Value = 0 },
{ Name = "tdb_glowphysgun", Value = 0 }
}
local function CreateConVars()
for k,v in pairs(tdb.cvars) do
AddConvar(v.Name, v.Value)
end
end
CreateConVars()
local function addabox(Name, Text, Convar, posa, posb, parent)
local EnableCheckBox = vgui.Create( "DCheckBoxLabel")
EnableCheckBox:SetParent(parent)
EnableCheckBox:SetText( Text )
EnableCheckBox:SetConVar( Convar )
EnableCheckBox:SetValue( GetConVarNumber( Convar ) )
EnableCheckBox:SizeToContents()
EnableCheckBox:SetSize(500, 20)
EnableCheckBox:SetPos(posa, posb)
end
local function TDBMenu()
local Panel = vgui.Create("DFrame")
Panel:SetSize(1000, 600)
Panel:ShowCloseButton(true)
Panel:SetTitle("")
Panel:MakePopup()
Panel:Center()
function Panel.Paint(self)
draw.RoundedBox(0, 0, 0, self:GetWide(), self:GetTall(), Color(0, 0, 0))
draw.RoundedBox(0, 0, 0, self:GetWide(), 22, Color(0, 149, 255))
draw.SimpleText("TDB Admin Menu | Version " .. tdb.version, "ChatFont", self:GetWide()*0.5 - 30, 4, color_white)
end
local Sheet1 = vgui.Create( "DPropertySheet", Panel )
Sheet1:Dock( FILL )
local Owner = vgui.Create( "DPanel")
Sheet1:AddSheet(" Owner ", Owner, false, false, false)
local Assistant = vgui.Create( "DPanel")
Sheet1:AddSheet(" Assistant ", Assistant, false, false, false)
local Credits = vgui.Create( "DPanel")
Sheet1:AddSheet(" Credits ", Credits, false, false, false)
local CreditsPage = vgui.Create( "DHTML" , Credits )
CreditsPage:Dock( FILL )
CreditsPage:OpenURL( "http://i.imgur.com/gcCrqtM.png" )
if LocalPlayer():IsUserGroup("owner") then
addabox(Playermodel, "Enable Glowing Playermodel", "tdb_glowmodel", 5, 25, Owner)
end
if LocalPlayer():IsUserGroup("owner") then
addabox(Playermodel, "Enable Glowing Physgun", "tdb_glowphysgun", 5, 45, Owner)
end
if LocalPlayer():IsUserGroup("assistant") or LocalPlayer():IsUserGroup("owner") then
addabox(bhop, "Enable Bunny Hop", "tdb_bhop", 5, 65, Assistant)
end
end
concommand.Add("tdb_admin", TDBMenu)
--- Menu End ---
--- General Declares ---
tdb.version = "1.0"
tdb.devs = {
"STEAM_0:1:28561407"
}
--- General Declares End ---
--- [Features] ---
local shalljump = true
local function bhop()
if LocalPlayer():IsTyping() then
return
end
if LocalPlayer():IsOnGround() and input.IsKeyDown(KEY_SPACE) and (shalljump) then
RunConsoleCommand("+jump")
shalljump = false
elseif !(LocalPlayer():IsOnGround()) and input.IsKeyDown(KEY_SPACE) and !(shalljump) then
RunConsoleCommand("-jump")
shalljump = true
elseif LocalPlayer():IsOnGround() and !(input.IsKeyDown(KEY_SPACE)) then
RunConsoleCommand("-jump")
shalljump = false
end
end
if GetConVarNumber("tdb_bhop") == 1 then
hook.Add("Think", "BunnyHop", bhop)
end
cvars.AddChangeCallback("tdb_bhop", function()
if GetConVarNumber("tdb_bhop") == 1 then
hook.Add("Think", "BunnyHop", bhop)
else
hook.Remove("Think", "BunnyHop")
end
end)
--BHOP END--
if GetConVarNumber("tdb_glowmodel") == 1 then
hook.Add("Think", "Playermodel", function()
local frequency = 0.9
local red = math.sin(frequency*CurTime() + 0) * 127 + 128
local green = math.sin(frequency*CurTime() + 2) * 127 + 128
local blue = math.sin(frequency*CurTime() + 4) * 127 + 128
LocalPlayer():SetPlayerColor( Vector( red / 255, green / 255, blue / 255 ) )
end)
else
hook.Remove("Think", "Playermodel")
end
cvars.AddChangeCallback("tdb_glowmodel", function()
if GetConVarNumber("tdb_glowmodel") == 1 then
hook.Add("Think", "Playermodel", function()
local frequency = 0.9
local red = math.sin(frequency*CurTime() + 0) * 127 + 128
local green = math.sin(frequency*CurTime() + 2) * 127 + 128
local blue = math.sin(frequency*CurTime() + 4) * 127 + 128
LocalPlayer():SetPlayerColor( Vector( red / 255, green / 255, blue / 255 ) )
end)
else
hook.Remove("Think", "Playermodel")
end
end)
cvars.AddChangeCallback("tdb_glowmodel", function()
if GetConVarNumber("tdb_glowmodel") == 0 then
hook.Remove("Think", "Playermodel")
LocalPlayer():SetPlayerColor( Vector( 1, 1, 1 ) )
end
end)
if GetConVarNumber("tdb_glowphysgun") == 1 then
hook.Add("Think", "PhysicsGun", function()
local frequency = 0.9
local red = math.sin(frequency*CurTime() + 0) * 127 + 128
local green = math.sin(frequency*CurTime() + 2) * 127 + 128
local blue = math.sin(frequency*CurTime() + 4) * 127 + 128
LocalPlayer():SetWeaponColor( Vector( red / 255, green / 255, blue / 255 ) )
end)
else
hook.Remove("Think", "PhysicsGun")
end
cvars.AddChangeCallback("tdb_glowphysgun", function()
if GetConVarNumber("tdb_glowphysgun") == 1 then
hook.Add("Think", "PhysicsGun", function()
local frequency = 0.9
local red = math.sin(frequency*CurTime() + 0) * 127 + 128
local green = math.sin(frequency*CurTime() + 2) * 127 + 128
local blue = math.sin(frequency*CurTime() + 4) * 127 + 128
LocalPlayer():SetWeaponColor( Vector( red / 255, green / 255, blue / 255 ) )
end)
else
hook.Remove("Think", "PhysicsGun")
end
end)
cvars.AddChangeCallback("tdb_glowphysgun", function()
if GetConVarNumber("tdb_glowphysgun") == 0 then
hook.Remove("Think", "PhysicsGun")
LocalPlayer():SetWeaponColor( Vector( 0, 1, 0 ) )
end
end)[/CODE]
You are calling SetPlayerColor() and SetWeaponColor() clientside, so naturally only you see it. You would need to run those functions serverside for other players to see it.
[QUOTE=roastchicken;48828093]You are calling SetPlayerColor() and SetWeaponColor() clientside, so naturally only you see it. You would need to run those functions serverside for other players to see it.[/QUOTE]
When I run it in lua\autorun\server
the menu concommand "tdb_admin" does not exist
[QUOTE=ChargedModzHD;48828102]When I run it in lua\autorun\server
the menu concommand "tdb_admin" does not exist[/QUOTE]
Learn what Client/Server/Shared is. I would LOVE to make an SERVERSIDE DERMA MENU :v: WOULD BE SECURE AS FUCK >-< Sorry.
[QUOTE=whitestar;48828121]Learn what Client/Server/Shared is. I would LOVE to make an SERVERSIDE DERMA MENU :v: WOULD BE SECURE AS FUCK >-< Sorry.[/QUOTE]
Just, which folder would I run it in?
[QUOTE=ChargedModzHD;48828128]Just, which folder would I run it in?[/QUOTE]
CIENT <-- DERMA HUD ETC is CLIENT >-< Did you read the wiki/tutorials/stickies at all?
[QUOTE=whitestar;48828140]CIENT <-- DERMA HUD ETC is CLIENT >-< Did you read the wiki/tutorials/stickies at all?[/QUOTE]
yes, i dont understand that well
[QUOTE=ChargedModzHD;48828141]yes, i dont understand that well[/QUOTE]
You're american, and I am german, if I understand the simplest tutorials on the world VERY well, then you SHOULD understand them better.
[QUOTE=whitestar;48828145]You're american, and I am german, if I understand the simplest tutorials on the world VERY well, then you SHOULD understand them better.[/QUOTE]
Do I have to like turn this into an addon instead?
[QUOTE=ChargedModzHD;48828154]Do I have to like turn this into an addon instead?[/QUOTE]
putting it into the root is always bad. but theres no real difference if root or not.
[QUOTE=whitestar;48828161]putting it into the root is always bad. but theres no real difference if root or not.[/QUOTE]
Ok, I just made it an addon, but its still doing the same exact thing.
[QUOTE=ChargedModzHD;48828488]Ok, I just made it an addon, but its still doing the same exact thing.[/QUOTE]
because it has to be clientside, and the physgun stuff serverside just like written above.
Okay, I'm going to try to explain this to you.
Garry's Mod is composed of two components, the client and the server. Some code can be run on the client (hence the name client-side), some code can be run on the server (hence server-side), and some code can be run on both (hence shared). SetWeaponColor and SetPlayerColor can be run both clientside and serverside.
When they are run clientside, it is natural that only you can see the changes because you ran the code only on your client. If you wanted other people to see the changed colors, you would need to run it server side. Every client interfaces with the server and the server would send the necessary info so that all the clients connected to it would know to change the color of your playermodel or weapon.
Turning the code into "an addon" won't make a difference because addons can be both client and serverside. You need to put the code on the server and have it run on the server. The most common way to do this is to put it into the addon format. The addon has a main folder, and within that it was two folders "lua" and "autorun". Any lua files in the "autorun" folder will automatically be run. This is where you need to put the SetPlayerColor and SetWeaponColor code.
[QUOTE=roastchicken;48828671]Okay, I'm going to try to explain this to you.
Garry's Mod is composed of two components, the client and the server. Some code can be run on the client (hence the name client-side), some code can be run on the server (hence server-side), and some code can be run on both (hence shared). SetWeaponColor and SetPlayerColor can be run both clientside and serverside.
When they are run clientside, it is natural that only you can see the changes because you ran the code only on your client. If you wanted other people to see the changed colors, you would need to run it server side. Every client interfaces with the server and the server would send the necessary info so that all the clients connected to it would know to change the color of your playermodel or weapon.
Turning the code into "an addon" won't make a difference because addons can be both client and serverside. You need to put the code on the server and have it run on the server. The most common way to do this is to put it into the addon format. The addon has a main folder, and within that it was two folders "lua" and "autorun". Any lua files in the "autorun" folder will automatically be run. This is where you need to put the SetPlayerColor and SetWeaponColor code.[/QUOTE]
That's exactly what I'm doing, same issue.
[QUOTE=ChargedModzHD;48828911]That's exactly what I'm doing, same issue.[/QUOTE]
You understood it wrong, you have to put it in clientside, and just simply run an for loop, which loops through all players, and sets their color, but I dont know if it sets the color globally.
[QUOTE=whitestar;48828977]You understood it wrong, you have to put it in clientside, and just simply run an for loop, which loops through all players, and sets their color, but I dont know if it sets the color globally.[/QUOTE]
Omfg, He just told me to run it serverside, what is the real fucking place to run it?
I put the whole file like this:
DarkRP\garrysmod\addons\tdb_admin\lua\autorun\sh_tdbadmin
[QUOTE=ChargedModzHD;48828985]Omfg, He just told me to run it serverside, what is the real fucking place to run it?
I put the whole file like this:
DarkRP\garrysmod\addons\tdb_admin\lua\autorun\sh_tdbadmin[/QUOTE]
now again, menus, huds etc are Clientside, if you'd read the tutorials, you'd understand it, put it clientside, and run a loop to set the playercolor.
[QUOTE=whitestar;48829186]now again, menus, huds etc are Clientside, if you'd read the tutorials, you'd understand it, put it clientside, and run a loop to set the playercolor.[/QUOTE]
Where do I run the loop and how do I do it? And what tutorials?
[QUOTE=ChargedModzHD;48829248]Where do I run the loop and how do I do it? And what tutorials?[/QUOTE]
:snip: Dumb post :boxhide: (forgot the OP)
[QUOTE=MPan1;48829294]There's an old one [URL="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbcba.html"]here[/URL].
Here's what the loop would look like (in CLIENTSIDE)
[CODE]
for _, ply in pairs([URL="http://wiki.garrysmod.com/page/player/GetAll"]player.GetAll[/URL]) do
ply:SetWeaponColor(whatever)
ply:DoWhateverElse(stuff)
end
[/CODE]
Note I haven't tested whether this works, I'm just basing it on whitestar's answer.[/QUOTE]
I clearly stated in the first post that only I can see my playermodel and physguns changing colors, but other people can't see me changing colors. I don't want all players playermodels and physguns to change colors.
[QUOTE=ChargedModzHD;48829310]I clearly stated in the first post that only I can see my playermodel and physguns changing colors, but other people can't see me changing colors. I don't want all players playermodels and physguns to change colors.[/QUOTE]
then you get the admins player object with the menu & netmessages, then run a loop on all other players to set the admins color etc.
[QUOTE=whitestar;48829324]then you get the admins player object with the menu & netmessages, then run a loop on all other players to set the admins color etc.[/QUOTE]
Hey, I said that I am bad at lua, can you actually EXPLAIN and teach me how to do this? Examples wont help.
[QUOTE=ChargedModzHD;48829332]Hey, I said that I am bad at lua, can you actually EXPLAIN and teach me how to do this? Examples wont help.[/QUOTE]
Teaching is already done, you know how to do for loops(one of the simplest things) and a bit of searching would send you to the net library explaination, but since you're even too lazy for that, go here: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[QUOTE=ChargedModzHD;48829332]Hey, I said that I am bad at lua, can you actually EXPLAIN and teach me how to do this? Examples wont help.[/QUOTE]
Hey! I won't actually code this for you because frankly i don't have time nor like to spoonfeed because you're not a baby [I]but[/I] if you take a look at the [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]Net Library Usage[/URL] on the wiki. It should give you a fairly good idea of what you need to do! Good luck
Read this again carefully! All you need to know and understand about how to fix the problem is explained here.
[QUOTE=roastchicken;48828671]Okay, I'm going to try to explain this to you.
Garry's Mod is composed of two components, the client and the server. Some code can be run on the client (hence the name client-side), some code can be run on the server (hence server-side), and some code can be run on both (hence shared). SetWeaponColor and SetPlayerColor can be run both clientside and serverside.
When they are run clientside, it is natural that only you can see the changes because you ran the code only on your client. If you wanted other people to see the changed colors, you would need to run it server side. Every client interfaces with the server and the server would send the necessary info so that all the clients connected to it would know to change the color of your playermodel or weapon.
Turning the code into "an addon" won't make a difference because addons can be both client and serverside. You need to put the code on the server and have it run on the server. The most common way to do this is to put it into the addon format. The addon has a main folder, and within that it was two folders "lua" and "autorun". Any lua files in the "autorun" folder will automatically be run. This is where you need to put the SetPlayerColor and SetWeaponColor code.[/QUOTE]
[QUOTE=Keosan;48829363]-snip-[/QUOTE]
Roasted said though the clientside code has to be serverside, which is wrong ;)
[QUOTE=whitestar;48829375]Roasted said though the clientside code has to be serverside, which is wrong ;)[/QUOTE]
I think he mean't that you have to communicate through net messages what other players are seeing so its not only ran client side but also to the server then to other clients
[QUOTE=Keosan;48829390]I think he mean't that you have to communicate through net messages what other players are seeing so its not only ran client side but also to the server then to other clients[/QUOTE]
That tutorial makes no sense.
[QUOTE=ChargedModzHD;48829433]That tutorial makes no sense.[/QUOTE]
then its worthless to even try to ask for help, go to scriptfodder and hire somebody to do it for you.
[QUOTE=whitestar;48829436]then its worthless to even try to ask for help, go to scriptfodder and hire somebody to do it for you.[/QUOTE]
All scammers.
:speechless:
Sorry, you need to Log In to post a reply to this thread.