AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Waiting for input without using set_task or a while/for loop (https://forums.alliedmods.net/showthread.php?t=6530)

Infra 10-05-2004 14:01

Waiting for input without using set_task or a while/for loop
 
Is there a way to "pause" the plugin while it waits for input?

I can't hook the input because the input happens in the middle of the plugin execution.


Code:
        new enter_tags         client_print(id,print_chat,"* [AMX MATCH] No Terrorist clantag found :/")                 enter_tags = get_cvar_num("amx_match_entertags")         if(enter_tags == 1)         {             copy (message_Tag, 191, "")                         client_cmd(id, "messagemode clanTag")                         // Need to pause here, to wait for input....             if(!equal(message_Tag, ""))             {                 enter_clantag(1)                                 client_print(id,print_chat,"* [AMX MATCH] %s has been added as the T clan tag", message_Tag)                }             else             {                 client_print(id,print_chat,"* [AMX MATCH] No T clan tag entered")             }                   }     }                     return PLUGIN_CONTINUE } public enter_clantag(team) //team = 1 - Ts, team = 2 - CTs {     if(team == 1)     {           client_print(0,print_chat,"DEBUG_CLANTAG | %d |", team)                         copy (clanT, 31, message_Tag)     }     else     {         copy (clanCT, 31, message_Tag)     }         return PLUGIN_CONTINUE } public messagemode_clantag(id,level,cid) {     read_args(message_Tag, 191)         remove_quotes(message_Tag)         client_print(id,print_chat,"DEBUG_MESSAGEMODE | %s |", message_Tag)         return PLUGIN_CONTINUE }

Code:
    // Enter clan tags     register_concmd("clanTag","messagemode_clantag",ADMIN_LEVEL_A,"< message >");


Thanks,

EKS 10-05-2004 14:06

no you cant. You need to split it into 2 functions.

Johnny got his gun 10-05-2004 14:33

If you would somehow "pause" the function and wait for user input it would pause the whole server and your clients would time out eventually.

Infra 10-05-2004 14:34

ok so something like this?

Code:
    if (T_tagspos == 0)     {         new enter_tags         client_print(id,print_chat,"* [AMX MATCH] No Terrorist clantag found :/")                 enter_tags = get_cvar_num("amx_match_entertags")         if(enter_tags == 1)         {             copy (message_Tag, 191, "")                         client_cmd(id, "messagemode clanTag")             set_task(2.0, "clantag_Tloop")              }     }                     return PLUGIN_CONTINUE } public clantag_Tloop() {     if(strlen(message_Tag) != 0)     {         enter_clantag(1)                 client_print(id,print_chat,"* [AMX MATCH] %s has been added as the T clan tag", message_Tag)        }     else     {         set_task(2.0, "clantag_Tloop", 1340)     }   } public clantag_enter(team) //team = 1 - Ts, team = 2 - CTs {     if(team == 1)     {           client_print(0,print_chat,"DEBUG_CLANTAG | %d |", team)                         copy (clanT, 31, message_Tag)     }     else     {         copy (clanCT, 31, message_Tag)     }         return PLUGIN_CONTINUE } public clantag_messagemode(id,level,cid) {     read_args(message_Tag, 191)         remove_quotes(message_Tag)         client_print(id,print_chat,"DEBUG_MESSAGEMODE | %s |", message_Tag)         return PLUGIN_CONTINUE }

Code:
    // Enter clan tags     register_concmd("clanTag","messagemode_clantag",ADMIN_LEVEL_A,"< message >")


All times are GMT -4. The time now is 17:11.

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