Raised This Month: $121 Target: $400
 30% 

[Any] Delay Command (testing appreciated!)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Plugin ID:
6193
Plugin Version:
18.0725.0
Plugin Category:
Admin Commands
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Provides a method to schedule command usage for a later time.
    Old 07-14-2018 , 04:10   [Any] Delay Command (testing appreciated!)
    Reply With Quote #1

    [Any] Delay Command
    v. 18.0725.0

    This plugin allows admins to schedule commands to be run in the future. It takes heavy inspiration from this this plugin: https://forums.alliedmods.net/showthread.php?t=134288


    Commands:
    • sm_delaycmd [time in seconds] [command to run], deafult access ADMFLAG_GENERIC. This command allows those with access to schedule command usage for a later time. For example, running the command sm_delaycmd 300 sm_kick @all "time's up!" would kick all players after 5 minutes with the reason "time's up!" If a player disconnects while he has pending commands, those commands will be cancelled.

    • sm_delaycmd_list [target], default access ADMFLAG_GENERIC. This command allows the user to view a list of all pending commands queued by the target player(s), printed to the console. Players who do not have access to sm_delaycmd_viewothers (defaults to ADMFLAG_GENERIC) will be unable to specify a target; the target is assumed to be themselves. Players with access to sm_delaycmd_rcon will be able to view the server console's pending commands via either the @all targeting filter, or by using sm_delaycmd_rcon with no arguments, and selecting CONSOLE from the menu that should appear.

    • sm_delaycmd_cancel [handle], default access ADMFLAG_GENERIC. Players can use this command, in conjunction with a handle code given to them by sm_delaycmd_list, to cancel a pending command. Players with access to sm_delaycmd_cancelothers (defaults to ADMFLAG_GENERIC) can specify command handles queued by other players. Players without access to this override can only cancel their own pending commands. Further, players with access to sm_delaycmd_rcon can specify commands pending to be run by the server console.

    • sm_delaycmd_rcon [time in seconds] [command to run], default access ADMFLAG_RCON. This command is similar to sm_delaycmd, except the command will be run by the server console. These commands will not be cancelled if the player leaves the server.



    CVARS, shown with default values:
    • sm_delaycmd_update 2 - Controls Updater compatibility
      • 0 : Completely disables Updater integration
      • 1 : Updater will notify you in Updater.log if an update becomes available.
      • 2 : Updater will automatically download any updates. They will be installed on the next server start or map change.
      • 3 : Updater will automatically download and immediately install any updates.

    Changelog:
    Spoiler



    Future plans:
    Spoiler



    DOWNLOADS:
    If you like what you see here, please consider donating~
    __________________

    Last edited by ddhoward; 07-25-2018 at 05:09.
    ddhoward is offline
    Facksy
    Senior Member
    Join Date: Apr 2017
    Location: here
    Old 07-14-2018 , 06:20   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #2

    Code:
    md 5 seconds ago to execute "sm_slap @all" (Handle: 72417886)
    [DelayCmd] Running "sm_slap @all", queued 5 seconds ago.
    L 07/14/2018 - 11:17:28: [SM] Exception reported: Client index 0 is invalid
    L 07/14/2018 - 11:17:28: [SM] Blaming: delaycmd.smx
    L 07/14/2018 - 11:17:28: [SM] Call stack trace:
    L 07/14/2018 - 11:17:28: [SM]   [0] FakeClientCommandEx
    L 07/14/2018 - 11:17:28: [SM]   [1] Line 104, E:\Steam\sourcemod\delayCmd.sp::Ti
    mer_DelayCmd
    when i run sm_delaycmd 5 sm_slap @all
    You should add there IsValidClient()
    Otherwise it works well :p

    EDIT: also this error when someone disconnect, it crash the server

    Code:
    L 07/14/2018 - 11:29:54: [SM] Exception reported: Invalid Handle 0 (error: 4)
    L 07/14/2018 - 11:30:00: [SM] Blaming: delaycmd.smx
    L 07/14/2018 - 11:30:16: [SM] Call stack trace:
    L 07/14/2018 - 11:30:17: [SM]   [0] ArrayList.Length.get
    L 07/14/2018 - 11:30:17: [SM]   [1] Line 41, E:\Steam\sourcemod\delayCmd.sp::OnC
    lientDisconnect
    L 07/14/2018 - 11:30:17: [SM] Exception reported: Script execution timed out
    __________________
    HereMy Steam

    Last edited by Facksy; 07-14-2018 at 06:35.
    Facksy is offline
    eyal282
    Veteran Member
    Join Date: Aug 2011
    Old 07-14-2018 , 06:34   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #3

    Quote:
    Originally Posted by Facksy View Post
    Code:
    md 5 seconds ago to execute "sm_slap @all" (Handle: 72417886)
    [DelayCmd] Running "sm_slap @all", queued 5 seconds ago.
    L 07/14/2018 - 11:17:28: [SM] Exception reported: Client index 0 is invalid
    L 07/14/2018 - 11:17:28: [SM] Blaming: delaycmd.smx
    L 07/14/2018 - 11:17:28: [SM] Call stack trace:
    L 07/14/2018 - 11:17:28: [SM]   [0] FakeClientCommandEx
    L 07/14/2018 - 11:17:28: [SM]   [1] Line 104, E:\Steam\sourcemod\delayCmd.sp::Ti
    mer_DelayCmd
    when i run sm_delaycmd 5 sm_slap @all
    You should add there IsValidClient()
    Otherwise it works well :p
    Do you happen to be client number 0, a.k.a ( I think! ) in a listen server? Because listen servers are known to have trouble.
    __________________
    Accepting private work. Contact me if you're interested.
    If you like my work, feel free to donate in appreciation with PayPal or CSGO Skins.
    eyal282 is offline
    Facksy
    Senior Member
    Join Date: Apr 2017
    Location: here
    Old 07-14-2018 , 06:36   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #4

    No no, im supposed to be the client 1
    __________________
    HereMy Steam
    Facksy is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 07-15-2018 , 00:32   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #5

    [QUOTE=Facksy;2603459]
    Code:
    md 5 seconds ago to execute "sm_slap @all" (Handle: 72417886)
    [DelayCmd] Running "sm_slap @all", queued 5 seconds ago.
    L 07/14/2018 - 11:17:28: [SM] Exception reported: Client index 0 is invalid
    L 07/14/2018 - 11:17:28: [SM] Blaming: delaycmd.smx
    L 07/14/2018 - 11:17:28: [SM] Call stack trace:
    L 07/14/2018 - 11:17:28: [SM]   [0] FakeClientCommandEx
    L 07/14/2018 - 11:17:28: [SM]   [1] Line 104, E:\Steam\sourcemod\delayCmd.sp::Ti
    mer_DelayCmd
    I'm honestly at a loss as to how this could happen. In any case, I've put in a little check to prevent this, but it shouldn't be happening at all.

    Quote:
    You should add there IsValidClient()
    Code:
    error 017: undefined symbol "IsValidClient"

    Quote:
    EDIT: also this error when someone disconnect, it crash the server

    Code:
    L 07/14/2018 - 11:29:54: [SM] Exception reported: Invalid Handle 0 (error: 4)
    L 07/14/2018 - 11:30:00: [SM] Blaming: delaycmd.smx
    L 07/14/2018 - 11:30:16: [SM] Call stack trace:
    L 07/14/2018 - 11:30:17: [SM]   [0] ArrayList.Length.get
    L 07/14/2018 - 11:30:17: [SM]   [1] Line 41, E:\Steam\sourcemod\delayCmd.sp::OnC
    lientDisconnect
    L 07/14/2018 - 11:30:17: [SM] Exception reported: Script execution timed out
    Fixed, thanks! Although, the last line is part of a different error which would have been printed on the lines AFTER it. Are you sure that last line has to do with my plugin?

    Plugin updated to version 18.0714.1.
    __________________

    Last edited by ddhoward; 07-15-2018 at 00:34.
    ddhoward is offline
    Facksy
    Senior Member
    Join Date: Apr 2017
    Location: here
    Old 07-16-2018 , 11:22   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #6

    No, this error was not due to your plugin ^^, also this is my IsValidClient:
    Code:
    stock bool:IsValidClient(client)
    { 
    	if (client <= 0 || client > MaxClients || !IsClientConnected(client) || IsFakeClient(client) || !IsClientInGame(client))
    	{
    		return false; 
    	}
    	return true; 
    }
    __________________
    HereMy Steam
    Facksy is offline
    Papero
    Veteran Member
    Join Date: Aug 2016
    Location: Rimini, Italy
    Old 07-16-2018 , 11:44   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #7

    I've made a thing like this too, I've never published it on am though.
    https://github.com/Hexer10/HexFuture...g/HexFuture.sp
    __________________

    Last edited by Papero; 07-16-2018 at 11:44.
    Papero is offline
    Send a message via Skype™ to Papero
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 07-16-2018 , 11:51   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #8

    [QUOTE=ddhoward;2603711]
    Quote:
    Originally Posted by Facksy View Post
    Code:
    md 5 seconds ago to execute "sm_slap @all" (Handle: 72417886)
    [DelayCmd] Running "sm_slap @all", queued 5 seconds ago.
    L 07/14/2018 - 11:17:28: [SM] Exception reported: Client index 0 is invalid
    L 07/14/2018 - 11:17:28: [SM] Blaming: delaycmd.smx
    L 07/14/2018 - 11:17:28: [SM] Call stack trace:
    L 07/14/2018 - 11:17:28: [SM]   [0] FakeClientCommandEx
    L 07/14/2018 - 11:17:28: [SM]   [1] Line 104, E:\Steam\sourcemod\delayCmd.sp::Ti
    mer_DelayCmd
    I'm honestly at a loss as to how this could happen. In any case, I've put in a little check to prevent this, but it shouldn't be happening at all.
    Same reason we say to either send client serial or userId when passing to a timer, because a client can disconnect.
    GetClientOfUserId returns 0 it there is no client under that userid. ( https://sm.alliedmods.net/new-api/cl...ClientOfUserId )
    So if the delay is long enough a player could do the command as they are disconnecting.
    __________________
    Mitchell is offline
    ddhoward
    Veteran Member
    Join Date: May 2012
    Location: California
    Old 07-16-2018 , 18:51   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #9

    Quote:
    Originally Posted by Mitchell View Post

    Same reason we say to either send client serial or userId when passing to a timer, because a client can disconnect.
    GetClientOfUserId returns 0 it there is no client under that userid. ( https://sm.alliedmods.net/new-api/cl...ClientOfUserId )
    So if the delay is long enough a player could do the command as they are disconnecting.
    But how would this cause the problem in this particular plugin? A client disconnecting causes all his pending commands to be cancelled, by passing the handles of all his timers through CloseHandle().

    You're telling me things I already know. :/
    __________________

    Last edited by ddhoward; 07-16-2018 at 18:55.
    ddhoward is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 07-17-2018 , 10:26   Re: [Any] Delay Command (testing appreciated!)
    Reply With Quote #10

    Quote:
    Originally Posted by ddhoward View Post
    But how would this cause the problem in this particular plugin? A client disconnecting causes all his pending commands to be cancelled, by passing the handles of all his timers through CloseHandle().

    You're telling me things I already know. :/
    then why are you using CloseHandle() (old syntax) instead of delete and also I think you need to use KillTimer() not just close the handle.
    https://sm.alliedmods.net/new-api/timers/KillTimer
    It also has an auto close for the data handle, just briefly looking it may close those datapacks you're also not closing but storing in the ArrayList (this is just how it appears, i'm not familiar with looping through the indices of an ArrayList).
    __________________

    Last edited by Mitchell; 07-17-2018 at 10:28.
    Mitchell is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 16:09.


    Powered by vBulletin®
    Copyright ©2000 - 2018, vBulletin Solutions, Inc.
    Theme made by Freecode