General > Developers Corner

Custom command not always working?

(1/3) > >>

bender180:
I made a command that allows and admin to  move a player that is afk to the spectator team in trouble in terrorist town but its not always working, i will use the command on one player and the player will switch to spectator but then ill use it on a different player and it does nothing but echo in chat. Does anyone know why the command is acting this way?

Heres the code:

--- Code: --------------------------------- Spectator ------------------------------
function ulx.afk( calling_ply, target_plys )

for _,v in pairs(target_plys) do

         timer.Simple(0.3, function()
                              v:ConCommand("ttt_spectator_mode 1")
                              v:ConCommand("ttt_cl_idlepopup")
                           end)
end
ulx.fancyLogAdmin( calling_ply, "#A has forced #T into spectator mode", target_plys )
end
local fspec = ulx.command( "TTT", "ulx afk", ulx.afk, "!afk" )
fspec:addParam{ type=ULib.cmds.PlayersArg }
fspec:defaultAccess( ULib.ACCESS_SUPERADMIN )
fspec:help( "Forces the target(s) to spectator mode." )
--- End code ---

nathan736:
WHY DO U HAS TIMER ? IT IS NOT CLEVER xD/needed

bender180:
i honestly took the code for moving someone to afk out of the ttt gamemode code and it had the timer so i kept it all I did was switch it from a client side to a server side style, ill try it with out the timer.

nathan736:
i think the logic flow for that command is what's broken  remove the timer  just do it... because re seting v after the timer is started could be causeing silent errors also spectator commands are not really needed for ttt just lower the afk spec setting   (heh im guilty of this)
Ps: that is if your actualy trying to send them to spec for afk.

bender180:
removing the timer worked and yes thats what the goal of the command is, to move them to the spectator team for afk

Navigation

[0] Message Index

[#] Next page

Go to full version