• TTT Slaynr Not working
    1 replies, posted
Whenever someone tries to use the slaynr method, all that is returned is "User will not be slain next round". No lua errors are thrown on console, and this problem arose when one of my staff supposedly slayed for a large number of rounds. [CODE] --[[ ulx.slaynr( calling_ply, target_plys, num_slay, should_slaynr ) calling_ply : PlayerObject : The player who used the command target_plys : PlayerObject : The player(s) who will have the effects of the command applied to them. num_slay : number : Numer of rounds to add or remove the the target(s) slay total. should_slaynr : boolean : Hidden, differentiates between ulx.slaynr and, ulx.rslaynr. The slaynr command slays <target(s)> next round. ]] function ulx.slaynr( calling_ply, target_plys, num_slay, should_slaynr, nr_reason, isvote ) if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else local affected_plys = {} if isvote then v = target_plys if ulx.getExclusive( v, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true ) elseif num_slay == 0 then local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0 if slays_left == 0 then ulx.fancyLogAdmin( calling_ply, "#T will not be slain next round.", target_plys ) elseif slays_left == 1 then ulx.fancyLogAdmin( calling_ply, "#T will be slain next round.", target_plys ) elseif slays_left > 1 then ulx.fancyLogAdmin( calling_ply, "#T will be slain for the next ".. tostring(slays_left) .." rounds." , target_plys ) end elseif num_slay < 0 then ULib.tsayError( calling_ply, "<times> must be a positive interger.", true ) else current_slay = tonumber(v:GetPData("slaynr_slays")) or 0 new_slay =current_slay + num_slay if new_slay > 0 then v:SetPData("slaynr_slays", new_slay) else v:RemovePData("slaynr_slays") end table.insert( affected_plys, v ) end local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0 local slays_removed = (current_slay - slays_left) or 0 if slays_removed > 0 and slays_left ==0 then chat_message = ("#A removed ".. slays_removed .." round(s) of slaying from #T. They/you will not be slain next round.") elseif slays_removed==0 then chat_message = ("#T will not be slain next round.") elseif slays_removed > 0 then chat_message = ("#A removed ".. slays_removed .." round(s) of slaying from #T.") elseif slays_left == 1 then chat_message = ("#A will slay #T next round for "..nr_reason) elseif slays_left > 1 then chat_message = ("#A will slay #T for the next ".. tostring(slays_left) .." rounds for "..nr_reason) end ulx.fancyLogAdmin( calling_ply, chat_message, affected_plys ) else for i=1, #target_plys do v = target_plys[ i ] if ulx.getExclusive( v, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true ) elseif num_slay == 0 then local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0 if slays_left == 0 then ulx.fancyLogAdmin( calling_ply, "#T will not be slain next round.", target_plys ) elseif slays_left == 1 then ulx.fancyLogAdmin( calling_ply, "#T will be slain next round.", target_plys ) elseif slays_left > 1 then ulx.fancyLogAdmin( calling_ply, "#T will be slain for the next ".. tostring(slays_left) .." rounds." , target_plys ) end elseif num_slay < 0 then ULib.tsayError( calling_ply, "<times> must be a positive interger.", true ) else current_slay = tonumber(v:GetPData("slaynr_slays")) or 0 if not should_slaynr then new_slay =current_slay + num_slay else new_slay =current_slay - num_slay end if new_slay > 0 then v:SetPData("slaynr_slays", new_slay) else v:RemovePData("slaynr_slays") end table.insert( affected_plys, v ) end local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0 local slays_removed = (current_slay - slays_left) or 0 if slays_removed > 0 and slays_left ==0 then chat_message = ("#A removed ".. slays_removed .." round(s) of slaying from #T. They/you will not be slain next round.") elseif slays_removed==0 then chat_message = ("#T will not be slain next round.") elseif slays_removed > 0 then chat_message = ("#A removed ".. slays_removed .." round(s) of slaying from #T.") elseif slays_left == 1 then chat_message = ("#A will slay #T next round for "..nr_reason) elseif slays_left > 1 then chat_message = ("#A will slay #T for the next ".. tostring(slays_left) .." rounds for "..nr_reason) end end ulx.fancyLogAdmin( calling_ply, chat_message, affected_plys ) end end end local slaynr = ulx.command( CATEGORY_NAME, "ulx slaynr", ulx.slaynr, "!slaynr" ) slaynr:addParam{ type=ULib.cmds.PlayersArg } slaynr:addParam{ type=ULib.cmds.NumArg, default=1, hint="times, 0 to view", ULib.cmds.optional, ULib.cmds.round } slaynr:addParam{ type=ULib.cmds.BoolArg, invisible=true } slaynr:addParam{ type=ULib.cmds.StringArg, hint="reason" } slaynr:addParam{ type=ULib.cmds.BoolArg, invisible=true } slaynr:defaultAccess( ULib.ACCESS_ADMIN ) slaynr:help( "Slays target(s) for a number of rounds" ) slaynr:setOpposite( "ulx rslaynr", {_, _, _, true}, "!rslaynr" ) -------------------------------------------Helper functions--------------------------------------------- hook.Add("TTTBeginRound", "SlayPlayersNextRound", function() local affected_plys = {} for _,v in pairs(player.GetAll()) do local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0 if v:Alive() and slays_left > 0 then local slays_left=slays_left -1 if slays_left == 0 then v:RemovePData("slaynr_slays") else v:SetPData("slaynr_slays", slays_left) end v:Kill() table.insert( affected_plys, v ) end end local slay_message = "" for i=1, #affected_plys do slay_message = ( slay_message .. affected_plys[i]:Nick()) if i > 1 then slay_message = ( slay_message .. ", " ) end end local slay_message_context if #affected_plys == 1 then slay_message_context ="was" else slay_message_context ="were" end if #affected_plys ~= 0 then ULib.tsay(_, slay_message .. " ".. slay_message_context .." slain.") end end) hook.Add("PlayerSpawn", "Inform" ,function(ply) local slays_left = tonumber(ply:GetPData("slaynr_slays")) or 0 local chat_message ="" if slays_left == 1 then chat_message = (chat_message .. "You will be slain this round.") end if slays_left > 1 then chat_message = (chat_message .. " and ".. (slays_left - 1) .." round(s) after the current round.") end ply:ChatPrint(chat_message) end) -----------------------------------------------End------------------------------------------------- --[[ ulx.slay( calling_ply, target_plys ) calling_ply : PlayerObject : The player who used the command target_plys : PlayerObject : The player(s) who will have the effects of the command applied to them. The ulx.vslaynr command returns the number of slays for the <target(s)> ]] function ulx.vslaynr( calling_ply, target_plys ) if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else for i=1, #target_plys do v = target_plys[ i ] local slays_left = tonumber(v:GetPData("slaynr_slays")) or 0 if slays_left == 0 then ulx.fancyLogAdmin( calling_ply,"#T will not be slain next round.", target_plys ) elseif slays_left == 1 then ulx.fancyLogAdmin( calling_ply,"#T will be slain next round.", target_plys ) elseif slays_left > 1 then ulx.fancyLogAdmin( calling_ply,"#T will be slain for the next ".. tostring(slays_left) .." rounds." , target_plys ) end end end end local vslaynr = ulx.command( CATEGORY_NAME, "ulx vslaynr", ulx.vslaynr, "!vslaynr" ) vslaynr:addParam{ typ
I don't know where you got this from. try this: [url]http://forums.ulyssesmod.net/index.php?topic=6279.0[/url]
Sorry, you need to Log In to post a reply to this thread.