• Transferring CUserCmd from server to client
    0 replies, posted
Hello. I'm having issues with the title. I don't believe net messages take anything but booleans, tables, ints, strings, and entities; and CUserCmd is not any of these. I tried setting Player.cmd = Player:GetCurrentCommand() in a shared file, but it still only worked for the client, and I was not able to retrieve it from other players. I need to do this though, because I'm trying to make a HUD that displays what keys a player is using. My current code(again, this is in a shared file): hook.Add("StartCommand", "may_keys_startcommand", function(ply, cmd) ply.may_cmd = cmd end) if CLIENT then CreateClientConVar("cl_showkeys", 0, true, false) hook.Add("HUDPaint", "may_keys_hudpaint", function() if !tobool(GetConVarNumber("cl_showkeys")) then return end local may_keys_target = LocalPlayer() if LocalPlayer():GetObserverTarget() and IsValid(LocalPlayer():GetObserverTarget()) and LocalPlayer():GetObserverTarget():Alive() and (LocalPlayer():GetObserverTarget():IsPlayer() or LocalPlayer():GetObserverTarget():IsBot()) then may_keys_target = LocalPlayer():GetObserverTarget() end surface.SetFont("Default") surface.SetTextColor(255, 255, 255, 255) surface.SetDrawColor(Color(0, 0, 0, 225)) surface.DrawRect(ScrW() - 114 - 6, ScrH() - 150 - 6, 114, 150) surface.SetDrawColor(Color(0, 255, 0, 255)) surface.DrawOutlinedRect(ScrW() - 114 - 6, ScrH() - 150 - 6, 114, 150) surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6, 30, 30) if may_keys_target.may_cmd:KeyDown(IN_FORWARD) then surface.DrawRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 30 + 6 + 10, (ScrH() - 150 - 6) + 6 + 8) surface.DrawText("W") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6, (ScrH() - 150 - 6) + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:KeyDown(IN_MOVELEFT) then surface.DrawRect((ScrW() - 114 - 6) + 6, (ScrH() - 150 - 6) + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 10, (ScrH() - 150 - 6) + 6 + 30 + 6 + 8) surface.DrawText("A") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:KeyDown(IN_JUMP) then surface.DrawRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 30 + 6 + 12, (ScrH() - 150 - 6) + 6 + 30 + 6 + 8) surface.DrawText("J") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6 + 30 + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:KeyDown(IN_MOVERIGHT) then surface.DrawRect((ScrW() - 114 - 6) + 6 + 30 + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 30 + 6 + 30 + 6 + 12, (ScrH() - 150 - 6) + 6 + 30 + 6 + 8) surface.DrawText("D") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:GetMouseX() < 0 then surface.DrawRect((ScrW() - 114 - 6) + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 12, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6 + 8) surface.DrawText("L") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:KeyDown(IN_BACK) then surface.DrawRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 30 + 6 + 12, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6 + 8) surface.DrawText("S") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6 + 30 + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:GetMouseX() > 0 then surface.DrawRect((ScrW() - 114 - 6) + 6 + 30 + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 30 + 6 + 30 + 6 + 12, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6 + 8) surface.DrawText("R") surface.DrawOutlinedRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6 + 30 + 6, 30, 30) if may_keys_target.may_cmd:KeyDown(IN_DUCK) then surface.DrawRect((ScrW() - 114 - 6) + 6 + 30 + 6, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6 + 30 + 6, 30, 30) end surface.SetTextPos((ScrW() - 114 - 6) + 6 + 30 + 6 + 12, (ScrH() - 150 - 6) + 6 + 30 + 6 + 30 + 6 + 30 + 6 + 8) surface.DrawText("C") end) end Any help would be very much appreciated. Thanks.
Sorry, you need to Log In to post a reply to this thread.