General > Developers Corner
Grabbing binds
Neku:
Does anyone know how to get a target's binds? It would help me in identifying who is lying about unbinding certain commands.
LuaTenshi:
You probably want to check out the input library for garrysmod located here... http://wiki.garrysmod.com/page/Category:input
Specifically this: 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
A good example of how to use the net Library...
Server to Client.
SERVER:
--- Code: ---util.AddNetworkString("sMsgStandard")
local str = "Hello"
net.Start("sMsgStandard")
net.WriteString(str)
net.Send(ply) -- ply, is the player entity your targeting.
--- End code ---
CLIENT:
--- Code: ---net.Receive("sMsgStandard", function()
local str = net.ReadString()
LocalPlayer():ChatPrint(str)
end)
--- End code ---
Client to Server.
CLIENT:
--- Code: ---local str = "Hello"
net.Start("HelloServer")
net.WriteString(str)
net.SendToServer()
--- End code ---
SERVER:
--- Code: ---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)
--- End code ---
Neku:
Unpooled Message
Er, could you help me with this?
I used
--- Code: ---util.AddNetworkString( "Debug2" )
--- End code ---
But it isn't working. The client side of the script seems to give me an unpooled message error.
MrPresident:
util.AddNetworkString( string )
placed in a serverside lua file has to match whatever string is being used in
net.Start( string )
Neku:
--- Quote from: 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 )
--- End quote ---
In this case, it's net.Receive( string ).
Should it still be the same?
Navigation
[0] Message Index
[#] Next page
Go to full version