AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Round Counter (https://forums.alliedmods.net/showthread.php?t=144124)

ichiban 11-29-2010 06:33

Round Counter
 
I am trying to record the amount of rounds played. It is currently increasing by two instead of one. What could the problem be?

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Test"

new iRound[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("TeamScore""teamScore""a");    
    
register_clcmd("say /round","showRound");
}

public 
teamScore()
{
    
//Increase Rounds Played for All Players
    
for(new 1<= get_maxplayers(); i++)
    {
        if(
is_user_connected(i))
        {
            if (!(
cs_get_user_team(i) == CS_TEAM_SPECTATOR))
            {
                
iRound[i]++;
            }
        }
    }
}

public 
showRound(id)
{
    
client_print(idprint_chat"You have played %i rounds"iRound[id]);



drekes 11-29-2010 07:09

Re: Round Counter
 
Try hooking the rounds like this:
PHP Code:

register_logevent("Event_RoundStart"2"1=Round_Start"); 

And do this to check team:
PHP Code:

if(cs_get_user_team(i) != CS_TEAM_SPECTATOR


abdul-rehman 11-29-2010 08:58

Re: Round Counter
 
This is da method i would use to count no of rounds which have passed
Code:
#include < amxmodx > new g_iRounds public plugin_init( ) {     register_plugin( "Blah", "blah", "blah" )     register_logevent( "event_round_start", 2, "1=Round_Start" )     register_clcmd( "say /round", "hook" ) } public hook( id )     client_print( id, print_chat, "No of rounds which have been played: %d", g_iRounds ) public event_round_start( )     g_iRounds++

dFF 11-29-2010 09:01

Re: Round Counter
 
Also reset g_iRounds when game commencing or server restart if You want.

drekes 11-29-2010 10:19

Re: Round Counter
 
Quote:

Originally Posted by abdul-rehman (Post 1359482)
This is da method i would use to count no of rounds which have passed

He's counting the amount of rounds an individual player has played.

abdul-rehman 11-29-2010 10:44

Re: Round Counter
 
Quote:

Originally Posted by drekes (Post 1359547)
He's counting the amount of rounds an individual player has played.

Quote:

Originally Posted by ichiban (Post 1359415)
I am trying to record the amount of rounds played.

I think he needs to be more descriptive nextime

ichiban 11-29-2010 21:19

Re: Round Counter
 
Thank you both.

I used both of your improvements.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Test"

new g_iPlayerRounds[33];
new 
g_iTotalRounds;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_logevent("Event_RoundStart"2"1=Round_Start");
    
register_clcmd("say /round","showRound");
}

public 
Event_RoundStart()
{
    
//Increase Rounds Played for All Players
    
for(new 1<= get_maxplayers(); i++)
    {
        if(
is_user_connected(i))
        {
            if (
cs_get_user_team(i) != CS_TEAM_SPECTATOR)
            {
                
g_iPlayerRounds[i]++;
            }
        }
    }
    
    
//Increase Total Rounds
    
g_iTotalRounds++;      
}

public 
showRound(id)
{
    
client_print(idprint_chat"You have played %i/%i rounds"g_iPlayerRounds[id], g_iTotalRounds);



nikhilgupta345 11-29-2010 21:35

Re: Round Counter
 
Make sure you reset the index when the client disconnect and/or connects to/from the server.


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

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