• Problems Changing Slots
    2 replies, posted
Hello, I am having trouble with something regarding the gamemode I am working on. [code] function weapon_set(ply,cmd,args) if (args[2] == nil) then if (ply:HasWeapon(args[1])) then ply:Give(args[1]) umsg.Start("Change_Slot",ply) umsg.String(args[1]) umsg.Char(tonumber(args[3])) umsg.End() end else if (ply:HasWeapon(args[1])) then ply:StripWeapon(args[2]) ply:Give(args[1]) umsg.Start("Change_Slot",ply) umsg.String(args[1]) umsg.Char(tonumber(args[3])) umsg.End() else return end end end concommand.Add("weapon_set",weapon_set) [/code] [code] function assign_weapon_slot(SlotMsg) for b,n in pairs(LocalPlayer():GetWeapons()) do if ( n:GetClass() == SlotMsg:ReadString() ) then n.Slot = SlotMsg:ReadChar() n.slot = SlotMsg:ReadChar() end end end usermessage.Hook("Change_Slot",assign_weapon_slot) [/code] Problem is, when it calls the usermessage, which doesn't give an error, it doesn't reassign the slot.
What is your main goal here? Are you trying to make it so you only have one primary secondary etc?
You cannot convert a char into its ASCII value by using G.tonumber, instead use string.byte.
Sorry, you need to Log In to post a reply to this thread.