Ulysses

General => Developers Corner => Topic started by: Neku on April 10, 2014, 09:19:19 PM

Title: Grabbing binds
Post by: Neku on April 10, 2014, 09:19:19 PM
Does anyone know how to get a target's binds? It would help me in identifying who is lying about unbinding certain commands.
Title: Re: Grabbing binds
Post by: LuaTenshi on April 11, 2014, 10:54:59 AM
You probably want to check out the input library for garrysmod located here... http://wiki.garrysmod.com/page/Category:input (http://wiki.garrysmod.com/page/Category:input)

Specifically this: http://wiki.garrysmod.com/page/input/LookupBinding (http://wiki.garrysmod.com/page/input/LookupBinding)

---

Also because the above is client side only you would need to use the "net" library. http://wiki.garrysmod.com/page/Category:net (http://wiki.garrysmod.com/page/Category:net)



A good example of how to use the net Library...

Server to Client.

SERVER:
Code: [Select]
util.AddNetworkString("sMsgStandard")
local str = "Hello"
net.Start("sMsgStandard")
net.WriteString(str)
net.Send(ply) -- ply, is the player entity your targeting.

CLIENT:
Code: [Select]
net.Receive("sMsgStandard", function()
local str = net.ReadString()
LocalPlayer():ChatPrint(str)
end)



Client to Server.

CLIENT:
Code: [Select]
local str = "Hello"
net.Start("HelloServer")
net.WriteString(str)
net.SendToServer()

SERVER:
Code: [Select]
util.AddNetworkString("HelloServer")
net.Receive("HelloServer", function(_, ply)
local str = net.ReadString()
print(ply,str) -- Will return the entity of the player who sent the message, as well as the message it self.
end)
Title: Re: Grabbing binds
Post by: Neku on April 16, 2014, 07:37:19 PM
Unpooled Message (http://wiki.garrysmod.com/page/Calling_net.Start_with_unpooled_message_name)

Er, could you help me with this?

I used
Code: [Select]
util.AddNetworkString( "Debug2" )
But it isn't working. The client side of the script seems to give me an unpooled message error.
Title: Re: Grabbing binds
Post by: MrPresident on April 16, 2014, 09:17:43 PM
util.AddNetworkString( string )
placed in a serverside lua file has to match whatever string is being used in

net.Start( string )
Title: Re: Grabbing binds
Post by: Neku on April 16, 2014, 10:28:32 PM
util.AddNetworkString( string )
placed in a serverside lua file has to match whatever string is being used in

net.Start( string )

In this case, it's net.Receive( string ).
Should it still be the same?
Title: Re: Grabbing binds
Post by: MrPresident on April 17, 2014, 05:01:11 AM
Yeah. The unpooled message error just means you're trying to do a net message that doesn't exist.

All net messages have to be declared serverside with the AddNetworkString before they can be used.
Title: Re: Grabbing binds
Post by: Neku on April 17, 2014, 10:24:38 PM
Hm, it doesn't seem to be registering.

I used util.AddNetworkString( "Debug2" ), then called net.Receive( "Debug2" ), but it still seems to be failing.
Title: Re: Grabbing binds
Post by: Cobalt on April 18, 2014, 10:18:31 AM
Hm, it doesn't seem to be registering.

I used util.AddNetworkString( "Debug2" ), then called net.Receive( "Debug2" ), but it still seems to be failing.
We can't help you unless you paste your code here.