AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   If you don't type .rdy in 2 minutes, you get kicked. (https://forums.alliedmods.net/showthread.php?t=161987)

Diegorkable 07-13-2011 14:41

If you don't type .rdy in 2 minutes, you get kicked.
 
Hey guys.
I'm trying to make a pug mode that when a player connects it reads from a file if the pug is running, if its not running it tells him to type .rdy, if he's not typing it after 2 minutes he's getting kicked. The wierd problem is that 2 minutes after plugin precache the 'server' is getting kicked o.0

for example, if the server was name Allied Modders Pug, you'd see 2 minutes after plugin precache in chat

Allied Modders Pug was kicked for not typing .rdy within 2 minutes (i did a client_print that when someone gets kicked it types it).

Why is this...? How do I prevent it? I did an array of timeleft for everyone that when a player connects it reads his STEAM_ID into a cell in the array and then gives him his own timeleft, cuz if there would be 1 variable of timeleft then any player that will connect will have the remaining time the first player who joined has left.

Xalus 07-13-2011 14:47

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
The ready thing is easy.

1. Detect Connect
2. Set Task (id + 841) for example
3. Detect say: .rdy
4. If he said, remove task (id + 841)
5. if he didn't say u handle it in the Handler of the task.

fysiks 07-13-2011 15:15

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
Show the code.

Diegorkable 07-13-2011 15:32

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
PHP Code:

public client_connect(id)
{
    new 
playername[32]
    
    
get_user_name(idplayername31)
    
    new 
pug fopen(pug_ini_file"r")
    
    
fseek(pug, -1SEEK_END)
    
getchar fgetc(pug)
    
    if (
getchar == '0')
    {
    
        
client_print(idprint_chat"%s Please type .rdy to be Ready! You will be kicked in %d seconds if you don't type it."PREFIXtimeleft)
        
timeleft -= 30
        set_task
(30.0"Continue")
        
    }
    
    else
    {
        
client_print(idprint_chat"%s You have entered to this match as it has already started, you will be used as a substitution."PREFIX)
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_HANDLED
}

public Continue(
id)
{
    
    new 
playersteam[30]
    
get_user_authid(idplayersteam29)
    
    for (new 
kk<typedalrdycounter k++)
    {
        if (
equali(playersteamtypedalrdy[k]))
        {
            return 
PLUGIN_HANDLED;
        }
        
        else
        {
            continue;
        }
    }
    new 
playername[32]
    
    
get_user_name(idplayername31)
    
    
client_print(idprint_chat"%s Please type .rdy to be Ready! You will be kicked in %d seconds if you don't type it."PREFIXtimeleft)
    switch(
timeleft)
    {
        case 
90:
        {
            
timeleft -= 30
            set_task
(30.0"Continue")
        }
        
        case 
60:
        {
            
timeleft -= 30
            set_task
(30.0"Continue")
        }
        
        case 
30:
        {
            
timeleft -= 20
            set_task
(20.0"Continue")
        }
        
        case 
10:
        {
            
timeleft 0
            set_task
(10.0"Continue")
        }
        
        case 
0:
        {
            
client_cmd(id"disconnect")
            
client_print(0print_chat"%s %s have been kicked for not typing .rdy for 2 minutes."PREFIXplayername)
        }
    }
    
    return 
PLUGIN_HANDLED
}

public 
Prepare(id)
{
    new 
playersteam[30]
    
get_user_authid(idplayersteam29)
    
    for (new 
kk<typedalrdycounter k++)
    {
        if (
equali(playersteamtypedalrdy[k]))
        {
            
client_print(idprint_chat"%s You have already typed .rdy!"PREFIX)
            return 
PLUGIN_HANDLED;
        }
        
        else if ((
iszero[k] != 1))
        {
            
client_print(idprint_chat"%s You are now ready!"PREFIX)
            
copy(typedalrdy[k], 29playersteam)
            
typedalrdycounter++
            
playersleft--
            
iszero[typedalrdycounter] = 1
        
}
        
    }
        
    if (
iszero[typedalrdycounter] != 1)
    {
        
copy(typedalrdy[typedalrdycounter], 29playersteam)
        
typedalrdycounter++
        
playersleft--
    } 


Diegorkable 07-13-2011 15:57

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
Can I just set then the first client that connects (which will be the server itself)'s time to unlimited?

fysiks 07-13-2011 16:18

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
YOu have to provide a task id, in your case it would be the id variable.

PHP Code:

set_task(30.0"Continue"id

However, I'm having trouble understanding your code. Setting all those recursive tasks is confusing and you have unnecessary repeated code (getting the auth id).

Diegorkable 07-13-2011 18:00

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
its not unnecessary, you should understand the logic behind my code, thats why you should come on steam more often so i can bug you with questions, fysiks :D

Diegorkable 07-13-2011 18:04

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
And I'll ask again, can I just set the first client that connects's timeleft to unlimited? or something that won't let him continue to any 'kicking' action? Because I make a guess now using my sense that the first client that will log in the server is the server itself (that was getting kicked after 2 minutes)

jimaway 07-13-2011 19:10

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
just add id to set_task, since the default id is 0
and id 0 = server

fysiks 07-14-2011 00:03

Re: If you don't type .rdy in 2 minutes, you get kicked.
 
Quote:

Originally Posted by Diegorkable (Post 1510108)
its not unnecessary, you should understand the logic behind my code

It is unnecessary to check someones SteamID several times since it doesn't change while they are on the server. If you think it is necessary then there is some sort of flaw in your logic (or it's bad logic). IMO

Quote:

Originally Posted by Diegorkable (Post 1510111)
And I'll ask again, can I just set the first client that connects's timeleft to unlimited? or something that won't let him continue to any 'kicking' action? Because I make a guess now using my sense that the first client that will log in the server is the server itself (that was getting kicked after 2 minutes)

The server never joins the game. You keep refering to "timeleft" but I have no idea where this number comes from (you don't show enough code).


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

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