Raised This Month: $51 Target: $400
 12% 

Check Everyone's Bool


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Skippy
Senior Member
Join Date: Nov 2011
Old 03-10-2013 , 15:28   Check Everyone's Bool
Reply With Quote #1

So what I'm wanting to do is not having a command continue until everyone has inserted a different command. Look at the coding and you will probably see what I mean.

PHP Code:
#include <sourcemod>

new bool:Yes[MAXPLAYERS+1];

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_yes"Command_Yes);
    
RegAdminCmd("sm_continue"Command_ContinueADMFLAG_SLAY);
}

public 
OnClientPutInServer(client)
{
    
Yes[client] = false;
}

public 
Action:Command_Yes(clientargs)
{
    if(
IsClientInGame(client)
    {
        
Yes[client] = true;
    }    
    return 
Plugin_Handled;
}    

public 
Action:Command_Continue(clientargs)
{
    if(
IsClientInGame(client))
    {
        for(new 
1<= MaxClientsi++)
        {    
            if(
Yes[i] == false)
            {
                
PrintToChat(client"Can't continue, not everyone has inserted the command.");
            }
            if(
Yes[i] == true)
            {
                
PrintToChat(client"Everyone has inserted the command. Lets Continue.");
            }
        }
    }
    return 
Plugin_Handled;

__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-10-2013 , 16:46   Re: Check Everyone's Bool
Reply With Quote #2

PHP Code:
public Action:Command_Continue(clientargs)
{
    if(!
client) return Plugin_Handled;
    for(new 
1<= MaxClientsi++)
    {
//      if (!IsClientInGame(i)) continue; // Maybe?
//      if (IsFakeClient(i)) continue; // This too?
        
if (Yes[i]) continue; // It's true, so move on to the next one
        // If we've made it this far, i's Yes is false
        
PrintToChat(client"Can't continue, not everyone has inserted the command.");
        return 
Plugin_Handled// or break; to just break out of the for loop
    
}
    
PrintToChat(client"Everyone has inserted the command. Lets Continue.");
    
// Code
    
return Plugin_Handled;

__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 03-10-2013 at 16:47.
MasterOfTheXP is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 03-10-2013 , 19:30   Re: Check Everyone's Bool
Reply With Quote #3

Okay I have this is it isn't working out right. It's some how getting by and allowing the StartWarningTimer() and BeforeStartingCheck() to both go through.

PHP Code:

public Action:Roundend_Check(Handle:timer)
{
    new 
iStarter GetClientOfUserId(g_Starter);
    new 
bool:bFirst true;
    for (new 
1<= MaxClientsi++) 
    { 
        if (
Yes[i] == true) continue;
        
        
PrintToChat(iStarter"Can't continue, not everyone has inserted the command.");
        if (
Yes[i] == false)
        {
            if (
bFirst
            {
                
Format(BufferMsizeof(BufferM), "No Answer: %N\n"i);
                
bFirst false;
            } 
            else 
            {
                
Format(BufferMsizeof(BufferM), "%s%N\n"BufferMi); 
            }
            if (
Yes[i] == true)
            {    
                
PrintHintText(iBufferM);
            }    
        }
        
BufferM[0] = '\0';
        
StartWarningTimer();
        break;    
    } 
    
BeforeStartingCheck();

__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.

Last edited by Skippy; 03-10-2013 at 19:31.
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-10-2013 , 22:27   Re: Check Everyone's Bool
Reply With Quote #4

You're going to want to validate player [i] before checking anything with them
__________________
View my Plugins | Donate
TnTSCS is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 03-11-2013 , 00:04   Re: Check Everyone's Bool
Reply With Quote #5

What would I validate? It's in a timer.
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-11-2013 , 11:10   Re: Check Everyone's Bool
Reply With Quote #6

PHP Code:
for (new 1<= MaxClientsi++)
{
    if (
IsClientInGame(i))
    {
        
// Your code here after validating i is a client that is in game and not just a client slot
    
}

Only because you're using
PHP Code:
PrintHintText(iBufferM); 
if i is not in game, PrintHintText might throw an error and stop processing any further i's
__________________
View my Plugins | Donate
TnTSCS is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 03-11-2013 , 19:56   Re: Check Everyone's Bool
Reply With Quote #7

Quote:
Originally Posted by TnTSCS View Post
PHP Code:
for (new 1<= MaxClientsi++)
{
    if (
IsClientInGame(i))
    {
        
// Your code here after validating i is a client that is in game and not just a client slot
    
}

Only because you're using
PHP Code:
PrintHintText(iBufferM); 
if i is not in game, PrintHintText might throw an error and stop processing any further i's

Hmm alright, now how do I check it so it count it for the scouts. Like it won't continue unless all the scouts have yes set to true
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-11-2013 , 23:58   Re: Check Everyone's Bool
Reply With Quote #8

I don't know what you are asking for. If this is for TF2 I won't be of much help since I don't play or code for that game. I know scout is a class, right?
__________________
View my Plugins | Donate
TnTSCS is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 03-12-2013 , 00:35   Re: Check Everyone's Bool
Reply With Quote #9

You'd look for TF2_GetPlayerClass == TFClass_Scout I suppose, not familiar with TF2 either.
__________________
thetwistedpanda is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 03-12-2013 , 02:03   Re: Check Everyone's Bool
Reply With Quote #10

Yes I know but do you check the yes = true and the class at the same time or set the yes = true under checking the class.
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy 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 15:22.


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