SourceSDK usermessages in Lua!
usermessages.LookupUserMessage("name") --Lookup message id by name
usermessages.GetUserMessages() --Return a table with registered usermessages
usermessages.GetUserMessageName(idx) --Return usermessage name by id
usermessages.GetTotal() --Return total number of usermessages
Container that's contain players and other stuff
rf = recipientfilter.Create() --Returns new userdata
rf:MakeReliable() --Don't forget to do it before you use it
rf:AddRecipient(Entity(1)) --Add player to filter
rf:Free() --When you done (usermessages.MessageEnd()) don't forget to free it!
bf = usermessages.UserMessageBegin(rf,usermessage_id) --Begin usermessage with our filter, returns bf_write userdata
bf_write metamethods:
WriteByte
WriteChar
WriteShort
WriteWord
WriteLong
WriteFloat
WriteAngle
WriteAngles
WriteCoord
WriteVec3Coord
WriteVec3Normal
WriteString
WriteEntity
WriteEHandle
WriteBool
WriteUBitLong
WriteSBitLong
WriteBits
Also for defination look in nekobuf.cpp
When you done, YOU MUST END THIS! (or u get engine error and server crash)
usermessages.MessageEnd()
When you're using usermessages, be carefully! Any error in code stop script and MessageEnd wasn't called, this can crash your server
for LuaCmd also SendLua
rf = recipientfilter.Create()
rf:MakeReliable()
rf:AddRecipient(Entity(1))
bf = usermessages.UserMessageBegin(rf,usermessages.LookupUserMessage("LuaCmd"))
bf:WriteString("print(\"Hello World!\")")
usermessages.MessageEnd()
rf:Free()