• playercolor of playermodel get reseted after jump
    2 replies, posted
hi everybody so i've got a weirg bug in my gamemode context : when player spawn the first time, he gets a menu with a team choice after selected someone i apply playercolor (for changing playermodel's color) serverside and clientside ( i think the two both are useless..) the playercolor change well but if i jump or i get in air, at the moment of the player hit the ground, the color is reseted and never back to the team color code : [CODE] team.SetUp( 1, "team1", Color(30,80,0) ) team.SetUp( 2, "2", Color(10,100,220) ) team.SetUp( 3, "3", Color(0,230,255) ) team.SetUp( 4, "4", Color(255,0,0) ) team.SetUp( 5, "5", Color(255,255,0) ) team.SetUp( 6, "6", Color(100,100,100) ) if SERVER then util.AddNetworkString( "ChooseTeam" ) util.AddNetworkString( "teamChoosed" ) function GM:PlayerInitialSpawn( ply ) net.Start( "ChooseTeam" ) net.Send(ply) end net.Receive( "teamChoosed", function(ln, pl) pl:SetTeam(net.ReadInt(8)) local color = team.GetColor(net.ReadInt(8)) pl:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) ) end) end if CLIENT then net.Receive( "ChooseTeam", function(ln, pl) TeamSelectionPanel = vgui.Create( "DFrame" ) // ... // Create panel and buttons bla bla bla //... buttonTeam1.DoClick = function() net.Start( "teamChoosed" ) net.WriteInt(1,8) net.SendToServer() local tmc = team.GetColor(1) ply:SetPlayerColor( Vector( tmc.r/255, tmc.g/255, tmc.b/255 ) ) RunConsoleCommand("cl_playercolor", tostring(Vector( tmc.r/255, tmc.g/255, tmc.b/255 )) ) TeamSelectionPanel:Close() end end) end [/CODE] i think i miss a hook or something like this ... so whats wrong ...?
[QUOTE=BALIST0N;51046966][CODE] net.Receive( "teamChoosed", function(ln, pl) pl:SetTeam(net.ReadInt(8)) local color = team.GetColor(net.ReadInt(8)) pl:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) ) end) [/CODE] [/QUOTE] This bit is wrong, you're calling ReadInt twice but you're doing WriteInt once. Cache result of ReadInt into a local variable and pass it to SetTeam and to team.GetColor.
[QUOTE=mijyuoon;51047045]This bit is wrong, you're calling ReadInt twice but you're doing WriteInt once. Cache result of ReadInt into a local variable.[/QUOTE] wow ... its work : [CODE] net.Receive( "teamChoosed", function(ln, pl) local teamnumber = net.ReadInt(8) pl:SetTeam(teamnumber) local color = team.GetColor(teamnumber) pl:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) ) end)[/CODE] Thank you ! :) :v:
Sorry, you need to Log In to post a reply to this thread.