Raised This Month: $ Target: $400
 0% 

Timer Return Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bigbuck
Senior Member
Join Date: Jul 2009
Old 10-20-2009 , 20:09   Timer Return Problem
Reply With Quote #1

I am having some problems understanding the whole Plugin_Continue, Plugin_Handled, and Plugin_Stop for timers. When OnClientPutInServer is triggered, I set off a 1.5 second timer which runs the code below. In this function I have a set of different situations contained in if statements. The first if is there to make sure we have at least the min number of bots. The rest are to take place after that min limit has been reached. Only one of those situations should be called at once so if one does get called I do not want the rest of the if statements being called.

PHP Code:
/**
 * Spawn correct number of starting bots
 *
 */
public ActionControlClients(HandletimeranyClient)
{
    
// Get survivor values
    
new survivors         TeamPlayers(2);
    new 
human_survivors    HumanTeamPlayers(2);
    new 
survivors_min    GetConVarInt(Survivors_Min_Limit);
    new 
survivors_max    GetConVarInt(Survivors_Max_Limit);

    
// We need to atleast reach our min number
    
if (survivors survivors_min)
    {
        for (;
survivors survivors_minsurvivors++)
        {
            
SpawnFakeClient();
            
LogMessage("Spawning starting bots");
        }

        return 
Plugin_Continue;
    }

    if (
Bot_Takeover)
    {
        
// If team is full of humans tell client so
        
if (human_survivors == survivors_max)
        {
            
survivors_full true;
            
LogMessage("Survivor team full. human survivors = %i"human_survivors);
        }

        
// If min survivor limit is all humans and max survivor limit hasn't been reached yet
        
if (human_survivors == survivors_min && survivors != survivors_max)
        {
            
// Add one to survivor limit and spawn bot
            
new survivors_min_new survivors_min 1;
            
SetConVarInt(Survivors_Min_Limitsurvivors_min_new);
            
SpawnFakeClient();
            
LogMessage("Spawning bot for takeover. human_survivors = %i, survivors = %i"human_survivorssurvivors);

            
// Let the new client know a bot is spawning for him and what to do
            
bot_spawned true;

            return 
Plugin_Continue;
        }

        
// If survivor team is full but contains bots change the human players team
        
if (survivors == survivors_max && human_survivors != survivors_max)
        {
            
ChangeClientTeam(Client2);
            
LogMessage("Changing client team. survivors = %i, human_survivors = %i"survivorshuman_survivors);

            
// Let the client know he has been auto connected
            
auto_connect true;

            return 
Plugin_Continue;
        }
    }

    
// Once the missing bots are made, dispose of the timer
    
SpawnTimer INVALID_HANDLE;

    return 
Plugin_Stop;

Bigbuck is offline
Bigbuck
Senior Member
Join Date: Jul 2009
Old 10-21-2009 , 15:43   Re: Timer Return Problem
Reply With Quote #2

Any ideas? If I didn't explain it well enough let me know and I can try again.
Bigbuck is offline
Scuzzy
Senior Member
Join Date: Oct 2007
Old 10-21-2009 , 16:50   Re: Timer Return Problem
Reply With Quote #3

Edit: I was was way off base: http://wiki.alliedmods.net/Timers_(SourceMod_Scripting)

Last edited by Scuzzy; 10-21-2009 at 21:07.
Scuzzy is offline
Bigbuck
Senior Member
Join Date: Jul 2009
Old 10-21-2009 , 20:17   Re: Timer Return Problem
Reply With Quote #4

I gave that a try and it seemed to just loop. Maybe the Plugin_Stop at the end has to be there?
Bigbuck is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 10-21-2009 , 20:52   Re: Timer Return Problem
Reply With Quote #5

return Plugin_Stop will stop the timer, if thats what youre trying to do.
retsam is offline
Reply



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 01:13.


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