+ Reply to Thread
Page 5 of 6 FirstFirst ... 3456 LastLast
Results 41 to 50 of 52

Thread: E2 - Input Support

  1. #41
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: E2 - Input Support - Fixed

    Ok, so i think i fixed input support, cuz it was broken. I think the problem was with the client. It doesn't read the inputsupport.lua file. Nothing works by simply doing:

    Code:
    if (CLIENT) then
        <do stuff>
    elseif (SERVER) then
        <do stuff>
    end
    The server side will work fine, and it does in input support. But the client side won't listen for keys and usermessages and run console commands like it needs to.

    If I'm wrong on the above stated, sorry but I'm a noob to gmod lua coding so forgive me.

    I didn't actually modify how it all works so props to the creator. Here is the fixed code:

    Server side (inputsupport.lua):

    Code:
    /******************************************************************************\
      Input support v1.2
    \******************************************************************************/
    AddCSLuaFile( "cl_inputsupport.lua" )
    local IsListeningForKey,cIsTriggeringForKey,IsTriggeringForKey,KeyTable,Times2 = {}, {}, {}, {}, {}
    
    if SERVER then
    
    concommand.Add( "e2keystate", function( player, command, args )
    	IsListeningForKey[player] = IsListeningForKey[player] or {}
    	args[1],args[2] = tonumber(args[1]), tonumber(args[2])
    	IsListeningForKey[player][args[1]] = args[2]
    	if cIsTriggeringForKey[player] and cIsTriggeringForKey[player][args[1]] then
    		for k,_ in pairs(cIsTriggeringForKey[player][args[1]])do
    			if k and k:IsValid() then
    	            			k:Execute()
    			else
    				cIsTriggeringForKey[player][args[1]][k] = nil
    			end
    		end
    	end
    end)
    
    for i=1,26 do
    	if i<10 then
    		KeyTable["..(i).."] = i+1
    	end
    	if i<11 then
    		KeyTable["pad"..i-1] = i+36
    	end
    	if i<13 then
    		KeyTable["f"..(i)] = i+91
    	end
    	KeyTable[string.char(i+96)] = i+10
    end
    KeyTable["pad/"] = 47
    KeyTable["pad*"] = 48
    KeyTable["pad-"] = 49
    KeyTable["pad+"] = 50
    KeyTable["padenter"] = 51
    KeyTable["pad."] = 52
    KeyTable["["] = 53
    KeyTable["]"] = 54
    KeyTable[";"] = 55
    KeyTable["'"] = 56
    KeyTable["`"] = 57
    KeyTable[","] = 58
    KeyTable["."] = 59
    KeyTable["/"] = 60
    KeyTable["\\"] = 61
    KeyTable["-"] = 62
    KeyTable["="] = 63
    KeyTable.enter = 64
    KeyTable[" "] = 65
    KeyTable.backspace = 66
    KeyTable.tab = 67
    KeyTable.capslock = 68
    KeyTable.numlock = 69
    KeyTable.escape = 70
    KeyTable.scrolllock = 71
    KeyTable.insert = 72
    KeyTable.delete = 73
    KeyTable.home = 74
    KeyTable["end"] = 75
    KeyTable.pageup = 76
    KeyTable.pagedown = 77
    KeyTable["break"] = 78
    KeyTable.lshift = 79
    KeyTable.rshift = 80
    KeyTable.lalt = 81
    KeyTable.ralt = 82
    KeyTable.lcontrol = 83
    KeyTable.rcontrol = 84
    KeyTable.lwin = 85
    KeyTable.rwin = 86
    KeyTable.app = 87
    KeyTable.up = 88
    KeyTable.left = 89
    KeyTable.down = 90
    KeyTable.right = 91
    KeyTable["capslocktoggle"] = 104
    KeyTable["numlocktoggle"] = 105
    KeyTable["scrolllocktoggle"] = 106
    KeyTable["xup"] = 107
    KeyTable["xdown"] = 108
    KeyTable["xleft"] = 109
    KeyTable["xright"] = 110
    KeyTable["xstart"] = 111
    KeyTable["xback"] = 112
    KeyTable["xstick1"] = 113
    KeyTable["xstick2"] = 114
    KeyTable["xa"] = 115
    KeyTable["xb"] = 116
    KeyTable["xx"] = 117
    KeyTable["xy"] = 118
    KeyTable["xblack"] = 119
    KeyTable["xwhite"] = 120
    KeyTable["xltrigger"] = 121
    KeyTable["xrtrigger"] = 122
    KeyTable["xstick1up"] = 123
    KeyTable["xstick1down"] = 124
    KeyTable["xstick1left"] = 125
    KeyTable["xstick1right"] = 126
    KeyTable["xstick2up"] = 127
    KeyTable["xstick2down"] = 128
    KeyTable["xstick2left"] = 129
    KeyTable["xstick2right"] = 130
    
    Times2["attack"] = 1
    Times2["jump"] = 2
    Times2["duck"] = 4
    Times2["forward"] = 8
    Times2["back"] = 16
    Times2["use"] = 32
    Times2["cancel"] = 64
    Times2["left"] = 128
    Times2["right"] = 256
    Times2["moveleft"] = 512
    Times2["moveright"] = 1024
    Times2["attack2"] = 2048
    Times2["run"] = 4096
    Times2["reload"] = 8192
    Times2["alt1"] = 16384
    Times2["alt2"] = 32768
    Times2["score"] = 65536
    Times2["speed"] = 131072
    Times2["walk"] = 262144
    Times2["zoom"] = 524288
    Times2["weapon1"] = 1048576
    Times2["weapon2"] = 2097152
    Times2["bullrush"] = 4194304
    
    local function KeyChangeHook(ply, key)
    	if IsTriggeringForKey[ply] and IsTriggeringForKey[ply][key] then
    		for k,_ in pairs(IsTriggeringForKey[ply][key])do
    			if k and k:IsValid() then
    				k:Execute()
    			else
    				IsTriggeringForKey[ply][key][k] = nil
    			end
    		end
    	end
    end
    hook.Add( "KeyPress", "KeyPressedHook", KeyChangeHook)
    hook.Add( "KeyRelease", "KeyReleasedHook", KeyChangeHook)
    
    end
    
    registerFunction("keyDown", "s", "n", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	rv1 = string.lower(rv1)
    	if self.player:KeyDown(Times2[rv1]) then
    		return 1
    	end
    	return 0
    end)
    
    registerFunction("triggerForKey", "s", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	IsTriggeringForKey[self.player] = IsTriggeringForKey[self.player] or {}
    	rv1 = string.lower(rv1)
    	rv1 = string.Explode(",",rv1)
    	for _,v in pairs(rv1) do
    		v = Times2[v]
    		if v then
    			IsTriggeringForKey[self.player][v] = IsTriggeringForKey[self.player][v] or {}
    			if !IsTriggeringForKey[self.player][v][self.entity] then
    				IsTriggeringForKey[self.player][v][self.entity] = true
    			end
    		end
    	end
    end)
    
    registerFunction("triggerForKeyStop", "s", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	IsTriggeringForKey[self.player] = IsTriggeringForKey[self.player] or {}
    	rv1 = string.lower(rv1)
    	rv1 = string.Explode(",",rv1)
    	for _,v in pairs(rv1) do
    		v = Times2[v]
    		if v and IsTriggeringForKey[self.player][v] and IsTriggeringForKey[self.player][v][self.entity] then
    			IsTriggeringForKey[self.player][v][self.entity] = nil
    		end
    	end
    end)
    
    registerFunction("cListenForKey", "s", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	IsListeningForKey[self.player] = IsListeningForKey[self.player] or {}
    	rv1 = string.lower(rv1)
    	rv1 = string.Explode(",",rv1)
    	local started = false
    	for _,v in pairs(rv1) do
    		v = KeyTable[v]
    		if v and !IsListeningForKey[self.player][v] then
    			if !started then umsg.Start("e2keystartlistening", self.player) started=true end
    			umsg.Short(v)
    			IsListeningForKey[self.player][v] = 0
    		end
    	end
    	if started then umsg.End() end
    end)
    
    registerFunction("cListenForKeyStop", "s", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	IsListeningForKey[self.player] = IsListeningForKey[self.player] or {}
    	rv1 = string.lower(rv1)
    	rv1 = string.Explode(",",rv1)
    	local started = false
    	for _,v in pairs(rv1) do
    		v = KeyTable[v]
    		if v and IsListeningForKey[self.player][v] then
    			if !started then umsg.Start("e2keystartlistening", self.player) started=true end
    			umsg.Short(-v)
    			IsListeningForKey[self.player][v] = nil
    		end
    	end
    	if started then umsg.End() end
    end)
    
    registerFunction("cTriggerForKey", "s", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	cIsTriggeringForKey[self.player] = cIsTriggeringForKey[self.player] or {}
    	rv1 = string.lower(rv1)
    	rv1 = string.Explode(",",rv1)
    	for _,v in pairs(rv1) do
    		v = KeyTable[v]
    		if v then
    			cIsTriggeringForKey[self.player][v] = cIsTriggeringForKey[self.player][v] or {}
    			cIsTriggeringForKey[self.player][v][self.entity] = true
    		end
    	end
    end)
    
    registerFunction("cTriggerForKeyStop", "s", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	if !cIsTriggeringForKey[self.player] then return end
    	rv1 = string.lower(rv1)
    	rv1 = string.Explode(",",rv1)
    	for _,v in pairs(rv1) do
    		v = KeyTable[v]
    		if v and cIsTriggeringForKey[self.player][v] and cIsTriggeringForKey[self.player][v][self.entity] then
    			cIsTriggeringForKey[self.player][v][self.entity] = nil
    		end
    	end
    end)
    
    registerFunction("cKeyDown", "s", "n", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	rv1 = string.lower(rv1)
    	if !KeyTable[rv1] then return end
    	rv1 = KeyTable[rv1]
    	if IsListeningForKey[self.player] and IsListeningForKey[self.player][rv1] then
    		return IsListeningForKey[self.player][rv1]
    	end
    	return 0
    end)
    
    registerFunction("cIgnoreChat", "n", "", function(self,args)
        local op1 = args[2]
        local rv1 = op1[1](self,op1)
    	rv1 = rv1~=0
    	IsListeningForKey[self.player] = IsListeningForKey[self.player] or {}
    	if IsListeningForKey[self.player] and IsListeningForKey[self.player].chat!=rv1 then
    		if rv1 then rv1=132 else rv1=131 end
    		umsg.Start("e2keystartlistening", self.player)
    			umsg.Short(rv1)
    		umsg.End()
    		IsListeningForKey[self.player].chat = rv1
    	end
    end)
    Client side (cl_inputsupport.lua):

    Code:
    local IsListeningForKey,cIsTriggeringForKey,IsTriggeringForKey,KeyTable,Times2 = {}, {}, {}, {}, {}
    
    if CLIENT then
    cIsTriggeringForKey,IsTriggeringForKey,KeyTable,Times2 = nil, nil, nil, nil
    IsListeningForKey.chat = {true}
    
    usermessage.Hook("e2keystartlistening", function( um )
    	local key = 0
    	repeat
    		key = um:ReadShort()
    		if key>130 then
    			key = key-131
    			IsListeningForKey.chat[1] = key~=0
    			return
    		elseif key>0 then
    			IsListeningForKey[key] = 0
    		else
    			IsListeningForKey[-key] = nil
    		end
    	until key==0
    end)
    
    hook.Add("CalcView", "e2keythink", function()
    	if (WIRE_CLIENT_INSTALLED) then
    		if IsListeningForKey.chat[1] and IsListeningForKey.chat[2] then return end
    		local list = ""
    		for k,v in pairs(IsListeningForKey) do
    			if k!="chat" then
    				if(input.IsKeyDown(k) && v!=1) then
    					// The key has been pressed
    					IsListeningForKey[k]=1
    					RunConsoleCommand("e2keystate",k,1)
    				elseif(!input.IsKeyDown(k) && v!=0) then
    					// The key has been released
    					IsListeningForKey[k]=0
    					RunConsoleCommand("e2keystate",k,0)
    				end
    			end
    		end
    	end
    end)
    
    hook.Add("StartChat", "e2chatcheckinitiated", function()
    	IsListeningForKey.chat[2] = true
    	if IsListeningForKey.chat[1] then
    		local list = ""
    		for k,v in pairs(IsListeningForKey) do
    			if k!="chat" and v==1 then
    				RunConsoleCommand("e2keystate",k,0)
    			end
    		end
    	end
    	return false
    end)
    
    hook.Add("FinishChat", "e2chatcheckfinished", function()
    	IsListeningForKey.chat[2] = false
    	return
    end)
    
    end
    Last edited by phreak314; 01-30-2010 at 11:02 PM.

  2. #42
    Bug Buster TomyLobo's Avatar
    Join Date
    Feb 2009
    Posts
    2,796

    Default Re: E2 - Input Support

    remove this:
    AddCSLuaFile( "cl_inputsupport.lua" )
    E2 will do that for you (and it will also tell the client-side to include it)
    "It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." - Bjarne Stroustrup

    L&#237;fi&#240; l&#230;&#240;ist l&#250;mskt &#225;fram

  3. #43
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: E2 - Input Support

    Quote Originally Posted by TomyLobo View Post
    remove this:
    AddCSLuaFile( "cl_inputsupport.lua" )
    E2 will do that for you (and it will also tell the client-side to include it)
    Not to disagree, but in my testing it didn't work until I added that line. I was testing this for a while, always wondering why the client never responded to usermessages. Once I added this line, everything started to work.

  4. #44
    Bug Buster TomyLobo's Avatar
    Join Date
    Feb 2009
    Posts
    2,796

    Default Re: E2 - Input Support

    did you put that file into core/custom?
    did you try removing the line when everything worked perfectly?
    "It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." - Bjarne Stroustrup

    L&#237;fi&#240; l&#230;&#240;ist l&#250;mskt &#225;fram

  5. #45
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: E2 - Input Support

    I'll have to try again and let you know. I was putting in the custom folder.

  6. #46
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: E2 - Input Support

    A weird problem i see now is pressing the number keys (not numpad). They are always in a keydown state, never released. Not a huge deal cuz the other keys seem to work fine. Anyone have a clue as to why the number keys above the letters would behave this way?

  7. #47
    Lifetime Supporter dracotonisamond's Avatar
    Join Date
    Jun 2009
    Location
    127.0.0.1
    Posts
    376

    Default Re: E2 - Input Support

    O.o can someone verify this for me? i just got banned from my own server, by the server for rcon hacking. lol i r haxx0r D:
    code dump.
    Code:
    Warning: Unhandled usermessage 'e2keystartlistening'
    Bad RCON password
    Bad RCON password
    Bad RCON password
    Bad RCON password
    Warning: Unhandled usermessage 'ups_ownerinfo'
    Warning: Unhandled usermessage 'ups_ownerinfo'
    Error: Material "models/weapons/v_bat/v_wooden_bat" : proxy "weapon_invis" not found!
    Error: Material "models/weapons/v_bat/v_wooden_bat" : proxy "ModelGlowColor" not found!
    Error: Material "models/weapons/v_baseball/baseball_sheet" : proxy "weapon_invis" not found!
    Error: Material "models/weapons/v_baseball/baseball_sheet" : proxy "ModelGlowColor" not found!
    Bad RCON password
    Bad RCON password
    Bad RCON password
    Bad RCON password
    Banning 76.174.38.100 for rcon hacking attempts
    repopulating clients
    Dropped SPiRALFACToR from server (Added to banned list)
    Disconnect: Added to banned list.
    Disconnect: Added to banned list.
    
    Banned by server
    
    Banned by server
    
    Banned by server
    
    ] connect s-factor.game-host.org
    Connecting to s-factor.game-host.org...
    Banned by server
    
    Retrying s-factor.game-host.org...
    Banned by server
    haha, anyone else have this happen?

    Quote Originally Posted by JatGoodwin in wiremod IRC
    <JatGoodwin> ITSBTH, the point of rainmeter is to impress the lamers with your leet computer
    <JatGoodwin> software equivalent of putting lights in your computer

  8. #48
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: E2 - Input Support

    Ummm.... really bad guess that the usermessage is signing itself as a RCON message?

  9. #49
    Wire Sofaking Wizard of Ass's Avatar
    Join Date
    May 2009
    Location
    Germany Bremerhaven
    Posts
    1,044

    Default Re: E2 - Input Support

    Usermessage = SERVER -> CLIENT
    RCON = CLIENT -> SERVER
    Your probatly downloaded a sent/script/whatever thats randomly sending rcon stuff to the server your playing on.
    seriously getting serious

  10. #50
    Lifetime Supporter dracotonisamond's Avatar
    Join Date
    Jun 2009
    Location
    127.0.0.1
    Posts
    376

    Default Re: E2 - Input Support

    lol, thats MY server xD. needless to say I've removed the addon until someone confirms it still works. i haven't been bannz0rd since. it actually happened to another one of my players an hour later, thats when i removed it. so its not my client, its something that has to do with this.

    EDIT: just remembered i was typing in the chat box when i got banned.

    Quote Originally Posted by JatGoodwin in wiremod IRC
    <JatGoodwin> ITSBTH, the point of rainmeter is to impress the lamers with your leet computer
    <JatGoodwin> software equivalent of putting lights in your computer

+ Reply to Thread
Page 5 of 6 FirstFirst ... 3456 LastLast

Similar Threads

  1. G15 support
    By Hunter234564 in forum Ideas & Suggestions
    Replies: 10
    Last Post: 03-22-2009, 08:54 AM
  2. Life Support
    By willthemage in forum Installation and Malfunctions Support
    Replies: 8
    Last Post: 08-20-2008, 02:06 PM
  3. Replies: 16
    Last Post: 02-26-2008, 07:29 AM
  4. Extended LS2 Support
    By WhiskeyFur in forum Ideas & Suggestions
    Replies: 5
    Last Post: 12-20-2007, 05:29 PM
  5. Packet Support for Everything
    By Razara in forum Ideas & Suggestions
    Replies: 3
    Last Post: 07-26-2007, 05:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots