• usermessage won't arrive.
    3 replies, posted
items.lua // included by cl_init and [lua] function Items:GiveItem( itemName, number, ply ) if( Items.Server[itemName] != nil ) then umsg.Start("GiveItem", ply) umsg.String( itemName ) umsg.Short( number ) umsg.End() end end function Items:RemoveItem( itemName, number, ply ) if( Items.Server[itemName] != nil) then umsg.Start("RemoveItem", ply) umsg.String( itemName ) umsg.Short( number ) umsg.End() end end function test( ply ) Items:GiveItem("Wood piece",1,ply) end concommand.Add("GiveItem",test) [/lua] cl_init.lua [lua] function RemoveItem( um ) local item = um.ReadString() local number = um.ReadShort() if ( Inventory[item] != nil ) then if( Inventory[item] - number <= 0 ) then inventory[item] = nil else inventory[item] = inventory[item] - number end end end usermessage.Hook("RemoveItem", RemoveItem) function GiveItem( um ) local item = um.ReadString() local number = um.ReadShort() if ( Inventory[item] != nil ) then Inventory[item] = inventory[item] + number else Inventory[item] = number end end usermessage.Hook("GiveItem", GiveItem) concommand.Add("PrintInventory",function( ply ) PrintTable(Inventory) end ) concommand.Add("ShowInventory",ShowInventory); [/lua] I use the command GiveItem, and then PrintInventory, but it shows up empty then I added a Msg to the GiveItem clientside function and it didn't get called.
Does it gives you any Lua errors when you try to run the GiveItem concommand?
No
[QUOTE=quincy18;21143958]No[/QUOTE] It won't arrive if you don't send the lua to the client, AddCSLuaFile("yourfile") in server-side file, and include it.
Sorry, you need to Log In to post a reply to this thread.