• I have ran into a problem with adding more than one new role to ttt
    0 replies, posted
ok so i have added a new role to ttt but i cant add another and its to do with the Shared.lua player roles. so in the Shared.lua the player roles are variables like this. -- Player roles ROLE_INNOCENT = 0 ROLE_TRAITOR = 1 ROLE_DETECTIVE = 2 ROLE_NONE = ROLE_INNOCENT So i added a 4th role that was Survivalist and it worked. ROLE_SURVIVALIST = 3 but the problem is you cant go higher than 3 because if you set ROLE_JESTER = 4 The gamemode will class it as a innocent 5 = traitor 6 = detective 7 = survivalist etc does any one know away around this? there is most likely code some where that is doing this [editline]9th July 2017[/editline] i have found what is causing the problem now time to try and make a way to make it work with more than 4 roles [code] local function ReceiveRoleList() local role = net.ReadUInt(2) local num_ids = net.ReadUInt(8) for i=1, num_ids do local eidx = net.ReadUInt(7) + 1 -- we - 1 worldspawn=0 local ply = player.GetByID(eidx) if IsValid(ply) and ply.SetRole then ply:SetRole(role) if ply:IsTraitor() then ply.traitor_gvoice = false -- assume traitorchat by default end end end end net.Receive("TTT_RoleList", ReceiveRoleList) [/code] and there is this [code] function SendRoleReset(ply_or_rf) local plys = player.GetAll() net.Start("TTT_RoleList") net.WriteUInt(ROLE_INNOCENT, 2) net.WriteUInt(#plys, 8) for k, v in pairs(plys) do net.WriteUInt(v:EntIndex() - 1, 7) end if ply_or_rf then net.Send(ply_or_rf) else net.Broadcast() end end [/code] [editline]9th July 2017[/editline] well i fixed the problem on my own so what i did was on cl_init.lua [code] --- usermessages local function ReceiveRole() local client = LocalPlayer() local role = net.ReadUInt(3) -- after a mapswitch, server might have sent us this before we are even done -- loading our code if not client.SetRole then return end client:SetRole(role) Msg("You are: ") if client:IsTraitor() then MsgN("TRAITOR") elseif client:IsDetective() then MsgN("DETECTIVE") elseif client:IsSurvivalist() then MsgN("SURVIVALIST") elseif client:IsJester() then MsgN("JESTER") else MsgN("INNOCENT") end end net.Receive("TTT_Role", ReceiveRole) local function ReceiveRoleList() local role = net.ReadUInt(3) local num_ids = net.ReadUInt(8) for i=1, num_ids do local eidx = net.ReadUInt(7) + 1 -- we - 1 worldspawn=0 local ply = player.GetByID(eidx) if IsValid(ply) and ply.SetRole then ply:SetRole(role) if ply:IsTraitor() then ply.traitor_gvoice = false -- assume traitorchat by default end end end end net.Receive("TTT_RoleList", ReceiveRoleList) [/code] and on traitor_state.lua [code] local function SendRoleListMessage(role, role_ids, ply_or_rf) net.Start("TTT_RoleList") net.WriteUInt(role, 3) -- list contents local num_ids = #role_ids net.WriteUInt(num_ids, 8) for i=1, num_ids do net.WriteUInt(role_ids[i] - 1, 7) end if ply_or_rf then net.Send(ply_or_rf) else net.Broadcast() end end function SendRoleReset(ply_or_rf) local plys = player.GetAll() net.Start("TTT_RoleList") net.WriteUInt(ROLE_INNOCENT, 3) net.WriteUInt(#plys, 8) for k, v in pairs(plys) do net.WriteUInt(v:EntIndex() - 1, 7) end if ply_or_rf then net.Send(ply_or_rf) else net.Broadcast() end end [/code] and it works
Sorry, you need to Log In to post a reply to this thread.