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

Task only for terrorist


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 06-25-2015 , 11:53   Task only for terrorist
Reply With Quote #1

I want to exec /hello (say command) on terrorist after 1 minute of round start how can i do that ?
Awesome_man is offline
Shlomi
Junior Member
Join Date: Oct 2013
Old 06-25-2015 , 13:22   Re: Task only for terrorist
Reply With Quote #2

hook new round event and use set task of 60 seconds.
then loop through all players, check which id's are valid (connected players and on terrorists team), and use client_cmd( ) on those id's.
gl
Shlomi is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-25-2015 , 14:15   Re: Task only for terrorist
Reply With Quote #3

Quote:
Originally Posted by Shlomi View Post
hook new round event and use set task of 60 seconds.
then loop through all players, check which id's are valid (connected players and on terrorists team), and use client_cmd( ) on those id's.
gl
get_players already give you valid players and you can filter by team(flag "e")
__________________
HamletEagle is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 06-25-2015 , 22:51   Re: Task only for terrorist
Reply With Quote #4

ok i tried but it's not compiling

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("HLTV", "hello", "a", "1=0", "2=0")  
    
    
}

public hello()
{
    set_task(60.0,"hello",id)
}

public hello(id)
{
    
        new players[32], pnum, numT, playersNum
        playersNum = get_playersnum()
        get_players(players, pnum, "ch")
        
        for ( new i; i<pnum; i++ )
        {
                if ( cs_get_user_team( players[i] ) == CS_TEAM_T )
                        numT++;
        }

        if ((playersNum >= 2) && (numT == 0))
        {
            client_cmd(id,"say /hello");
        }
    
}

Last edited by Awesome_man; 06-25-2015 at 23:10.
Awesome_man is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-25-2015 , 23:56   Re: Task only for terrorist
Reply With Quote #5

1. You have 2 functions named 'hello'. You can't do that.
2. In the first hello function, you are using 'id' variable that is not defined anywhere.
3. Your condition in the second hello() says if num players >=2 and terrorist count = 0, say hello. I thought you wanted terrorists to say hello. How is this possible when you are only executing that if terrorist count = 0.
4. You are executing a command using 'id' that has no value since this would would be the same id that was passed in set_task(), which has no value and wasn't defined.
5. You didn't listen to HamletEagle. get_players() will give you the count of terrorists automatically when you use it correctly.
6. Your original post and your code sample do not match so I'm confused about what you need.

Here's code based on your original post, if this isn't what you need then try to make it do what you want, or give more details:
PHP Code:

#include <amxmodx>
#include <cstrike>

public plugin_init() 
{
    
register_event"HLTV""RoundStart" "a" "1=0" "2=0" );  
}

public 
RoundStart()
{
    
set_task60.0 "hello" );
}

public 
hello()
{
    new 
players32 ] , pnum;
    
get_playersplayers pnum "che" "TERRORIST" );
    
    for ( new 
pnumi++ )
    {
        
client_cmdplayers] , "say /hello" );
    }

__________________

Last edited by Bugsy; 06-25-2015 at 23:56.
Bugsy is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 06-26-2015 , 00:37   Re: Task only for terrorist
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
1. You have 2 functions named 'hello'. You can't do that.
2. In the first hello function, you are using 'id' variable that is not defined anywhere.
3. Your condition in the second hello() says if num players >=2 and terrorist count = 0, say hello. I thought you wanted terrorists to say hello. How is this possible when you are only executing that if terrorist count = 0.
4. You are executing a command using 'id' that has no value since this would would be the same id that was passed in set_task(), which has no value and wasn't defined.
5. You didn't listen to HamletEagle. get_players() will give you the count of terrorists automatically when you use it correctly.
6. Your original post and your code sample do not match so I'm confused about what you need.

Here's code based on your original post, if this isn't what you need then try to make it do what you want, or give more details:
PHP Code:

#include <amxmodx>
#include <cstrike>

public plugin_init() 
{
    
register_event"HLTV""RoundStart" "a" "1=0" "2=0" );  
}

public 
RoundStart()
{
    
set_task60.0 "hello" );
}

public 
hello()
{
    new 
players32 ] , pnum;
    
get_playersplayers pnum "che" "TERRORIST" );
    
    for ( new 
pnumi++ )
    {
        
client_cmdplayers] , "say /hello" );
    }

Thanks it's working fine now
Awesome_man 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 10:54.


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