Raised This Month: $ Target: $400
 0% 

Function done twice


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
lagbeast
Junior Member
Join Date: Jul 2007
Old 07-07-2007 , 20:07   Function done twice
Reply With Quote #1

im not sure why this is happening. i have a function that once you get to two rounds, the script will transfer the players to the other team and the restart the round. now the script does that, but it does it two times and i have been sitting here for two hours and trying to figure out why and now i have given up and ask for ur pro-assistance!

also, how do you print out the value of a boolean? with string u use %s and int %i but how do u do with bool?

anyways, here is the relevant code

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fun>
#include <cstrike>

new team_wins[2]
new 
bool:swapMess



public plugin_init() {
    
register_plugin("ready""1.00""hehu")
    
register_event("TeamScore""team_score""a")
    
register_logevent("round_start"2"1=Round_Start")
    
//register_logevent("round_end",2,"1=Round_End")
}

public 
team_score()
{
     new 
team[2]
     
read_data(1team1)
     
    if(
team[0] == 'C') {
        
team_wins[0] = read_data(2
     } else if(
team[0] == 'T') {
        
team_wins[1] = read_data(2
    }
     
     if(
team_wins[0]+team_wins[1]==2)
     {
         
swapMess=true
        
     
}
     return 
PLUGIN_CONTINUE
}

public 
round_start()
{
    if(
swapMess==true)
    {    
        
swapMess=false
        swap
()
        
//server_cmd("sv_restartround 10")
        
        
    
}
    return 
swapMess
}
public 
swap() {
    new 
maxplayers=get_maxplayers()
    new 
team[16]
    for(new 
i=0;i<=maxplayers;i++)
        if(
is_user_connected(i)) {
            
get_user_team(i,team,15)
            if(
equal(team,"CT")) {
                if(
is_user_alive(i)) 
                {
                    
user_kill(i)
                    
cs_set_user_team(iCS_TEAM_T)
                }
            } 
            else 
            {
                if(
equal(team,"TERRORIST")) {
                    if(
is_user_alive(i)) 
                    {
                        
user_kill(i)
                        
cs_set_user_team(iCS_TEAM_CT)
                    }
                }
            }

        }
    return 
PLUGIN_CONTINUE
    
}
    

some of the code i have found in the forums, like the one for swapping teams
lagbeast is offline
 



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 21:34.


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