AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Auto Ready Plugin (https://forums.alliedmods.net/showthread.php?t=318348)

Alber9091 08-25-2019 18:15

Auto Ready Plugin
 
Hello, I need a plugin for My Auto-Mix Server.

Which after 10 secs of Joining the server & after sv_restart.
Uses say .ready command on player. (Like this may be? client_cmd(id, "say .ready").

Alber9091 08-26-2019 03:18

Re: Auto Ready Plugin
 
Code:
set_task (10.0, autoready, id) Public_autoready(id) client_cmd (id, "say .ready")

Some what like this? But on "Joining server" & pcvar string "sv_restart"

LearninG 08-26-2019 06:58

Re: Auto Ready Plugin
 
let me know if any bug occurs.

PHP Code:

#include <amxmodx>

#define TASK_ID          654244

#define TASK_TIME        10.0

public plugin_init()
{
    
register_plugin("Auto Ready Command" "0.01" "LearninG")
    
register_event("TextMsg""Event_TextMsg_Restarting""a""2=#Game_will_restart_in")
}

public 
client_putinserver(id)
{
    
set_task(TASK_TIME "client_start_command" ,id)
}

public 
Event_TextMsg_Restarting(id)
{
    
set_task(TASK_TIME "client_start_command2" TASK_ID)
}

public 
client_start_command(id)
{
    
client_cmd(id "say .ready")
}

public 
client_start_command2()
{
    
client_cmd("say .ready")



thEsp 08-26-2019 07:07

Re: Auto Ready Plugin
 
@learning
1. There is no reason to declare specific task indexes when you aren't using them.
2. Function "client_start_command2" will send "say .ready" command to server, not a specific user.
3. Use loops instead ^.
4. Don't pass variables to tasks when you don't need them, pass only when you do.

LearninG 08-26-2019 07:39

Re: Auto Ready Plugin
 
Quote:

Originally Posted by thEsp (Post 2664776)
@learning
1. There is no reason to declare specific task indexes when you aren't using them.
2. Function "client_start_command2" will send "say .ready" command to server, not a specific user.
3. Use loops instead ^.
4. Don't pass variables to tasks when you don't need them, pass only when you do.

I get it now , but i have 1 problem :
1- how to delay the command "client_cmd(i , "say .ready")" in "Event_TextMsg_Restarting" function ?
PHP Code:

#include <amxmodx> 

#define TASK_TIME        10.0 

new g_MaxPlayers

public plugin_init() 

    
register_plugin("Auto Ready Command" "0.01" "LearninG"
    
register_event("TextMsg""Event_TextMsg_Restarting""a""2=#Game_will_restart_in"
    
g_MaxPlayers get_maxplayers()


public 
client_putinserver(id

    
set_task(TASK_TIME "client_start_command"


public 
Event_TextMsg_Restarting(id
{
    for (new 
1i<= g_MaxPlayersi++)
    {
        
client_cmd("say .ready")
    }


public 
client_start_command(id

    
client_cmd(id "say .ready"



thEsp 08-26-2019 08:11

Re: Auto Ready Plugin
 
Set a task, and do the loop in the task. Either check if player is connected or loop throughout connected players (get_playersnum native).

LearninG 08-26-2019 09:41

Re: Auto Ready Plugin
 
This should not have any issues
PHP Code:

#include <amxmodx>

#define TASK_ID          6514515

#define TASK_TIME        10.0  

new g_MaxPlayers 

public plugin_init()  
{  
    
register_plugin("Auto Ready Command" "0.01" "LearninG")  
    
register_event("TextMsg""Event_TextMsg_Restarting""a""2=#Game_will_restart_in"
    
g_MaxPlayers get_maxplayers() 
}  

public 
client_putinserver(id)  
{  
    
set_task(TASK_TIME "client_start_command" id TASK_ID)  
}  

public 
Event_TextMsg_Restarting()  
{
    
set_task(TASK_TIME "client_start_command2"


public 
client_start_command(TASK)  
{
    new 
id TASK TASK_ID
    client_cmd
(id "say .ready")  


public 
client_start_command2() 

    for (new 
1i<= g_MaxPlayersi++) 
    { 
        if (
is_user_connected(i)) 
        { 
            
client_cmd("say .ready"
        } 
    } 



thEsp 08-26-2019 10:09

Re: Auto Ready Plugin
 
It has an issue. You passed no value at "client_start_command", so "id" will be 0.

LearninG 08-26-2019 11:34

Re: Auto Ready Plugin
 
Quote:

Originally Posted by thEsp (Post 2664816)
It has an issue. You passed no value at "client_start_command", so "id" will be 0.

Updated code , now ?

Alber9091 08-26-2019 15:25

Re: Auto Ready Plugin
 
Hy, Thanks !! Since, I don't know scripting, hence was not interrupting you, so, that theEsp may guide you to fix code, till yet, I'm using very 1st code.


All times are GMT -4. The time now is 00:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.