[QUOTE=buu342;46777036]Trying to get a DColorMixer to change the playermodel's color but it doesn't seem to want to do it. It GETS the color without issues but it won't SET it.
[lua]
local Mixer = vgui.Create( "DColorMixer", TabTwo )
Mixer:SetPos(10,20)
Mixer:SetSize( 267,186 )
Mixer:SetPalette( true )
Mixer:SetAlphaBar( true )
Mixer:SetWangs( true )
local clr = LocalPlayer():GetPlayerColor()
local rrr = clr.x * 255
local ggg = clr.y * 255
local bbb = clr.z * 255
Mixer:SetColor( Color(rrr,ggg,bbb,255) )
function Mixer:ValueChanged(col)
local rr = col.r / 255
local gg = col.g / 255
local bb = col.b / 255
LocalPlayer():SetPlayerColor(Vector(rr,gg,bb))
end
[/lua][/QUOTE]
Use net to set player color on the server.
[lua]
Serverside:
util.AddNetworkString("ChangePlayerColor")
net.Receive("ChangePlayerColor", function(len, client)
if IsValid(client) and net.ReadTable() then
client:SetPlayerColor(unpack(net.ReadTable()))
end
end)
Clientside:
function Mixer:ValueChanged(col)
local tbl = {col.r, col.g, col.b}
net.Start("ChangePlayerColor")
net.WriteTable(tbl)
net.SendToServer()
end[/lua]
Why were you dividing by 255 and using Vectors? :pwn:
[QUOTE=Author.;46777358]Why were you dividing by 255 and using Vectors? :pwn:[/QUOTE]
SetPlayerColor takes in a vector between 0-1. At least that's what the wiki said and that was the reason to my insanity.
Gonna see if using net works and i'll take a look at your example. Thank you both of you.
[editline]I ENJOY DEVOURING COCKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/editline]
Well, I got it working in a way. It sets the player's color to black though...
menu.lua
[lua]
local Mixer = vgui.Create( "DColorMixer", TabTwo )
Mixer:SetPos(10,20)
Mixer:SetSize( 267,186 )
Mixer:SetPalette( true )
Mixer:SetAlphaBar( true )
Mixer:SetWangs( true )
local clr = LocalPlayer():GetPlayerColor()
local rrr = clr.x * 255
local ggg = clr.y * 255
local bbb = clr.z * 255
Mixer:SetColor( Color(rrr,ggg,bbb,255) )
function Mixer:ValueChanged(clr)
local rrr = clr.r / 255
local ggg = clr.g / 255
local bbb = clr.b / 255
net.Start("ChangePlayerColor")
net.WriteVector(Vector(rr,gg,bb))
net.SendToServer()
end
[/lua]
int.lua
[lua]
util.AddNetworkString("ChangePlayerColor")
net.Receive("ChangePlayerColor", function(len, client)
if IsValid(client) and net.ReadVector() then
client:SetPlayerColor(net.ReadVector())
end
end)
[/lua]
-snip- lmao
[QUOTE=man with hat;46767300]I tried that and it didn't work out, but I saw eifacev21.h and replaced eiface.h with that. VEngineServerV21 is there but it isn't defined as a class, but a namespace. The only thing in the namespace is IVEngineServer and that version of it does not have GetIServer(). There is IVEngineServer021 in eiface.h and I've tried that as well but it crashes just like IVEngineServer.
To summarize:
• IVEngineServer and IVEngineServer021 in eiface.h crash when called.
• VEngineServerV21::IVEngineServer in eifacev21.h does not have GetIServer().
I can use other functions just fine. It seems to be only GetIServer().[/QUOTE]
Still having trouble with this. If anyone can help me with this, I will give you a twizzler.
How do I delete a team? Robotboy's Stranded gamemode uses teams as a party system but it doesn't remove them when they are empty and I'm trying to fix that. I already have an empty check but I just realized I have no idea how to actually delete a team and there's no function to do so on the wiki.
Reposting problem
[QUOTE=ROFLBURGER;46775126]Ok I need help with textures/andor lua
[lua]cam.Start3D(EyePos(),EyeAngles() + Angle(0,0,0) )
render.SetMaterial( mat )
render.DrawSphere( self.detail3:GetPos(), self.EffectRadius, 32, 32, Color(255,255,255,55) )
render.DrawSphere( self.detail3:GetPos(), -self.EffectRadius, 32, 32, Color(255,255,255,55) )
cam.End3D()[/lua]
I have this in my draw function, the mat is called elsewhere.
The result of this is unwanted...
... This picture is fine , the sphere draws like it should ...
[t]http://i.imgur.com/TWJ2Hri.jpg[/t]
... but this picture draws like it shouldn't. I'm wondering if there is something I could do to make the texture behind it not override like that.
[t]http://i.imgur.com/I4p5ptv.jpg[/t][/QUOTE]
Additional info:
That whole weird rendering is a result of me using self:SetRenderBounds() to make it forces the prop to draw when you're looking away from it but just enough so the sphere actually draws.
I'm using the ENT:Draw() hook for it. I'm wondering if there are any ways of fixing this or any alternatives to what I'm using for coding.
[code]local function AllowPickup( ply, wep )
local PWep = ply:GetWeapon( wep:GetClass() )
if !PWep || !PWep.Magazines then return true end
local FullyLoaded = true
for k, v in ipairs( PWep.Magazines ) do
if v <= 0 then FullyLoaded = false end
print( "Checking "..k.." has "..v )
end
if FullyLoaded then print( "True" ) else print( "False" ) end
if FullyLoaded then
return false
else
return true
end
hook.Add( "PlayerCanPickupWeapon", "CanPickMeUp", AllowPickup )
end[/code]
"Checking # has #" is not printing to the console, so it's not running the for loop to check the index values. What's going wrong here, and how could I fix this?
[editline]23rd December 2014[/editline]
"true" is spamming the console, too
I hate the lua tag, it breaks when I go to edit.
[editline]23rd December 2014[/editline]
[code]function SWEP:Initialize()
...
for i = 1, ReserveMagsToAdd do
self.Magazines[ "clip"..i ] = 0
end
end[/code]
How does one upload media to the Wiki again?
[QUOTE=Exho;46781941]How does one upload media to the Wiki again?[/QUOTE]
[URL="wiki.garrysmod.com/page/Special:Upload"]wiki.garrysmod.com/page/Special:Upload[/URL]
The hidden special pages ooo eeee ooo
Why won't my for loop call?
Yeah, I said this is the last place I go to look for help, everything else comes first, and I've debugged countless times, tweaking the code many of those times. The for loop is never called. I ended up writing this, knowing it would not do what I wanted, only for debugging.
[code]local function AllowPickup( ply, wep )
local PWep = ply:GetWeapon( wep:GetClass() )
if !PWep || !PWep.Magazines then return true end
local FullyLoaded
for k, v in ipairs( PWep.Magazines ) do
if v <= 0 then FullyLoaded = false end
print( "Checking "..k.." has "..v )
return
end
if FullyLoaded != ( true or false ) then print( "Nada Pickup" ) print(" ") return true end
if FullyLoaded then
print( "True" )
return false
else
print( "False" )
return true
end
end
hook.Add( "PlayerCanPickupWeapon", "CanPickMeUp", AllowPickup )[/code]
[quote=The Console]Random Clip Works
Loaded: 20
Nada Pickup
Random Clip Works
Loaded: 22
Nada Pickup
Random Clip Works
Loaded: 16
Nada Pickup
Random Clip Works
Loaded: 19
Nada Pickup
[/quote]
[editline]23rd December 2014[/editline]
Random clip has nothing to do with SWEP.Magazines = {} as I haven't worked in a way to set that as a table value.
I want the damage a player does to depend on their hunger level; should I use ScalePlayerDamage or EntityTakeDamage instead?
[QUOTE=NiandraLades;46782879]I want the damage a player does to depend on their hunger level; should I use ScalePlayerDamage or EntityTakeDamage instead?[/QUOTE]
Does, or takes? I mean, unless it's melee or throwing weapons, I don't completely understand.
-<snip>-
So, if you want to change the damage a player takes from everything, use ScalePlayerDamage. If you want to change the damage that one weapon does, EntityTakeDamage is better, if you can't change the damage elsewhere.
Basically, the damage individual players do to others should depend on their health
I mean hunger not health, but it's still a number so same stuff
Please do read again. I edited
[editline]23rd December 2014[/editline]
You could hook ScalePlayerDamage and check the health, energy, or whatever, of the attacker. At least, I think you can, I've had trouble with hooks lately. If you did that, though, you could scale the damage DEALT there, rather than EntityTakeDamage.
Ok hold on, I knew very little about the functions / hooks in question... face palm. Both functions control when a player is taking damage, rather than dealing it. If you want to change the amount of damage they take, I recommend ScalePlayerDamage.
[editline]23rd December 2014[/editline]
In fact, I would go so far as to say ScalePlayerDamage is better since it's intended to be used on players, while EntityTakeDamage is less direct.
How do i get rid of this
[t]http://i.imgur.com/UXkVXbF.png[/t]
[QUOTE=rebel1324;46783872]How do i get rid of this
[t]http://i.imgur.com/UXkVXbF.png[/t][/QUOTE]
Try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetDrawLanguageIDAtLeft]Panel:SetDrawLanguageIDAtLeft[/url] and set it to false, the name is misleading.
[code]
// By default, we draw the language shortname on the right hand side of the control
void SetDrawLanguageIDAtLeft( bool state );
[/code]
Valve is as confused as ever.
[QUOTE=zeaga;46780857]How do I delete a team? Robotboy's Stranded gamemode uses teams as a party system but it doesn't remove them when they are empty and I'm trying to fix that. I already have an empty check but I just realized I have no idea how to actually delete a team and there's no function to do so on the wiki.[/QUOTE]
I am fairly sure that setting an entry in team.GetAllTeams() to nil will delete the corresponding team.
[QUOTE=WalkingZombie;46781335][code]local function AllowPickup( ply, wep )
local PWep = ply:GetWeapon( wep:GetClass() )
if !PWep || !PWep.Magazines then return true end
local FullyLoaded = true
for k, v in ipairs( PWep.Magazines ) do
if v <= 0 then FullyLoaded = false end
print( "Checking "..k.." has "..v )
end
if FullyLoaded then print( "True" ) else print( "False" ) end
if FullyLoaded then
return false
else
return true
end
hook.Add( "PlayerCanPickupWeapon", "CanPickMeUp", AllowPickup )
end[/code]
"Checking # has #" is not printing to the console, so it's not running the for loop to check the index values. What's going wrong here, and how could I fix this?
[editline]23rd December 2014[/editline]
"true" is spamming the console, too
I hate the lua tag, it breaks when I go to edit.
[editline]23rd December 2014[/editline]
[code]function SWEP:Initialize()
...
for i = 1, ReserveMagsToAdd do
self.Magazines[ "clip"..i ] = 0
end
end[/code][/QUOTE]
ipairs only works for integer keyed tables.. try pairs
How should I properly initialize an entities PhysicsObject on the server and client. Calling on just the server works fine, but becomes wonky when I call it on both.
[sp]Also any ideas I can get an entity to behave like prop_physics? I.E. Making sound when it hits the ground.[/sp]
does anyone have issues with util.PrecacheModel() ?
it seems that if I use it to cache more than, say, 70 vehicle models the server crashes whenever someone joins
I'm calling it both SV and CL
[editline]24th December 2014[/editline]
any less than that and the server will crash on like the 10th player joined
[QUOTE=WalkingZombie;46782552]-snip-[/QUOTE]
If your loop isn't calling, your table is likely empty
[QUOTE=Exho;46785937]If your loop isn't calling, your table is likely empty[/QUOTE]
I check for that before the print calls, though.
if !PWep || !type( PWep ) == TYPE_ENTITY || [B]!PWep.Magazines[/B] then return true end
[editline]24th December 2014[/editline]
But I can double check, I guess that only checks to make sure it exists...
[editline]24th December 2014[/editline]
You're right. It shouldn't be empty though, unless this doesn't work:
[code]SWEP.Primary.DefaultReserveMags = 7
SWEP.Special = {}
SWEP.Special.MaximumMagazineCount = 8
function SWEP:Initialize()
local ReserveMagsToAdd = math.min( self.Special.MaximumMagazineCount - 1, self.Primary.DefaultReserveMags )
for i = 1, ReserveMagsToAdd do
self.Magazines[ "clip"..i ] = 0
end
end[/code]
[code]local function AllowPickup( ply, wep )
local PWep = ply:GetWeapon( wep:GetClass() )
if !PWep || !type( PWep ) == TYPE_ENTITY || !PWep.Magazines then return true end
print( "Mag Table Number: "..#PWep.Magazines )
local FullyLoaded
for k, v in ipairs( PWep.Magazines ) do
if v <= 0 then FullyLoaded = false end
print( "Checking "..k.." has "..v )
return
end
if FullyLoaded != ( true or false ) then print( "Nada Pickup" ) print(" ") return true end
if FullyLoaded then
print( "True" )
return false
else
print( "False" )
return true
end
end[/code]
That should really be enough code to fix any problem, there's nothing else that references it yet
{} is still a table that exists, it doesn't mean it's not empty
^ Read on... Initialize
[editline]24th December 2014[/editline]
Lol, had to edit, didn't put in the function when I copy pasted
[editline]24th December 2014[/editline]
Yeah, that doesn't seem to be adding ANY values... Debugged in the respective function:
[code] local ReserveMagsToAdd = math.min( PWep.Special.MaximumMagazineCount - 1, PWep.Primary.DefaultReserveMags )
if #PWep.Magazines == 0 then
for i = 1, ReserveMagsToAdd do
PWep.Magazines[ "clip"..i ] = 0
end
end
print( "Working? "..#PWep.Magazines )[/code]
[editline]24th December 2014[/editline]
No... wtf
[quote=The Console]Random Clip Works
Loaded: 21
clip1
clip2
clip3
clip4
clip5
clip6
clip7
Working? 0
Nada Pickup
[/quote]
revision:
[code] if #PWep.Magazines == 0 then
for i = 1, ReserveMagsToAdd do
PWep.Magazines[ "clip"..i ] = 0
print( "clip"..i )
end
end[/code]
[editline]24th December 2014[/editline]
OK Scrap it all, I got it working through another method...
[code]local function AllowPickup( ply, wep )
local PWep = ply:GetWeapon( wep:GetClass() )
if !PWep || !type( PWep ) == TYPE_ENTITY || !PWep.Magazines then return true end
local ReserveMagsToAdd = math.min( PWep.Special.MaximumMagazineCount - 1, PWep.Primary.DefaultReserveMags )
local FullyLoaded
local FirstUnloadedClip = nil
for i = 1, ReserveMagsToAdd do
v = PWep.Magazines [ "clip"..i ]
if v <= 0 then FullyLoaded = false FirstUnloadedClip = i end
print( "Checking "..i.." has "..v )
end
if FullyLoaded then
print( "True" )
return false
else
print( "False" )
PWep.Magazines[ "clip"..FirstUnloadedClip ] = wep:Clip1()
return true
end
end[/code]
[editline]24th December 2014[/editline]
[quote=The Console]Random Clip Works
Loaded: 26
Checking 1 has 0
Checking 2 has 0
Checking 3 has 0
Checking 4 has 0
Checking 5 has 27
Checking 6 has 28
Checking 7 has 19
False
[/quote]
[code]
type( PWep ) == TYPE_ENTITY
[/code]
This won't work. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/type]Global.type[/url] returns a string, while the [url=http://wiki.garrysmod.com/page/Enums/TYPE]type enums[/url] are numbers.
[QUOTE=WalkingZombie;46786879]snip[/QUOTE]
Already told you what your problem was.
You're using ipairs instead of pairs; your table is not integer keyed.
/facepalm
Does anyone have a copy of the skeleton gamemode from garrysmod.org? I'm trying to find an entity file I found in one of those skeletons a while back but I can't find a copy of it anywhere.
If I'm looking to create a multiplayer game between 2 players using my phone addon, would it be bad to frequently use the net library to send data to and from the server/clients? Thats how I imagine it would work but it seems wrong :/
That is the best and correct way to do it. Just make sure to have a message limit like steam chat.
Sorry, you need to Log In to post a reply to this thread.