Raised This Month: $ Target: $400
 0% 

Only when being terrorist or CT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
amxxlover
Junior Member
Join Date: Mar 2010
Old 03-07-2010 , 17:32   Only when being terrorist or CT
Reply With Quote #1

I try to make make clients who are in the terrorists or CT team say "I'm a terrorist or CT" when the doAction in the plugin is triggered or as soon they are terrorist or CT. When i use the below script clients who are not terrorist or CT say each 2 secconds "I'm a terrorist or CT". However these clients aren't terrorist or CT the "client_cmd(id,"say I'm a terrorists or CT")" line in the script is executed what shouldn't be happened if im right. Anyone can tell me what i did wrong or make a working script?

PHP Code:
public doAction(id)
{
    if ( 
get_user_team(id) != && get_user_team(id) != )
    {
        
set_task(2.0"doAction",id)
    }
    
client_cmd(id,"say I'm a terrorist or CT")


Last edited by amxxlover; 03-07-2010 at 17:34.
amxxlover is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-07-2010 , 22:06   Re: Only when being terrorist or CT
Reply With Quote #2

PHP Code:
public doAction(id)
{
    if ( 
get_user_team(id) != && get_user_team(id) != )
    {
        
set_task(2.0"doAction",id)
    }
    
client_cmd(id,"say I'm a terrorist or CT")



PHP Code:
public doAction(id)
{
    if(
get_user_team(id) == 1)
    {
        
client_cmd(id,"say I'm a terrorist");
    }
    if(
get_user_team(id == 2)
    {
        
client_cmd(id"say I'm a CT");
    }



then call it where you want.
if you want it to loop every x amounts of seconds
PHP Code:
set_task(Time"Function"id_,_,_,b); //The b flag is the loop tag.

If No loop

set_task
(Time"Function"id); 
Doc-Holiday is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-07-2010 , 22:32   Re: Only when being terrorist or CT
Reply With Quote #3

Tsk tsk NcB... all that C++ reading has caused you to get sloppy.

Don't use get_user_team, it returns false results sometimes. Also, the code NcB posted had a couple of bracket-eering errors in it.

Code:
#include <amxmodx> #include <cstrike> // ... public doAction( id ) {     new CsTeams:iTeam = cs_get_user_team( id )         switch( iTeam )     {         case CS_TEAM_T:         {             client_cmd( id, "say terrorist" )         }                 case CS_TEAM_CT:         {             client_cmd( id, "say counter-terr" )         }                 default: // spec or unassigned         {             client_cmd( id, "say spec" )         }     } }

EDIT: *giggle* at the coincidental timing.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT

Last edited by wrecked_; 03-07-2010 at 22:36.
wrecked_ is offline
Old 03-07-2010, 22:34
fysiks
This message has been deleted by fysiks. Reason: nvm
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-07-2010 , 23:12   Re: Only when being terrorist or CT
Reply With Quote #4

If you're only using a value once, no need to create a variable.
PHP Code:
switch( cs_get_user_teamid ) ) 
You can also do something like this.
PHP Code:
new CsTeams:iTeam cs_get_user_teamid );

if ( 
CS_TEAM_T <= iTeam <= CS_TEAM_CT )
    
client_printid print_chat "I am a %s" iTeam == CS_TEAM_T "Terrorist" "CT" ); 
I don't understand completely what you are trying to do. If you can explain better we can help better.
__________________

Last edited by Bugsy; 03-07-2010 at 23:21.
Bugsy is offline
amxxlover
Junior Member
Join Date: Mar 2010
Old 03-08-2010 , 00:53   Re: Only when being terrorist or CT
Reply With Quote #5

All 3 thank you very much
Ive choicen for wrecked_ his script because spectators and unassigned team players could easely say something to so an extra thumb up for you

edit: Reason for the script is to make players who join the T or CT team automaticly execute a command.

Last edited by amxxlover; 03-08-2010 at 01:04.
amxxlover is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-08-2010 , 08:40   Re: Only when being terrorist or CT
Reply With Quote #6

The thing you want to try to avoid is writing the same code twice. If you use the same function on T\CT (aside from a chat msg) you can do this (same for unassigned\spec).
PHP Code:
new CsTeams:iTeam cs_get_user_teamid );

switch ( 
iTeam )
{
     case 
CS_TEAM_T CS_TEAM_CT:
     {
          
client_printid print_chat "* You are a %s" iTeam == CS_TEAM_T "Terrorist" "CT" );
          
//call your other function(s)
     
}
     case 
CS_TEAM_UNASSIGNED CS_TEAM_SPECTATOR//default works too
     
{
          
client_printid print_chat "* %s" iTeam == CS_TEAM_UNASSIGNED "Choose a team!" "Why don't you play instead of spectate?" );
          
//call your other function(s)
     
}

If using wrecked's code and you do not use the iTeam variable again in your function, switch it directly.
PHP Code:
switch ( cs_get_user_teamid ) ) 
__________________

Last edited by Bugsy; 03-08-2010 at 08:49.
Bugsy is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-09-2010 , 00:33   Re: Only when being terrorist or CT
Reply With Quote #7

I have always used get_user_team and have never had an error...

when it returns 0 i believe it just gets handled no actual run time error.. i could be wrong though...
Doc-Holiday is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-09-2010 , 07:03   Re: Only when being terrorist or CT
Reply With Quote #8

Quote:
Originally Posted by NcB_Sav View Post
I have always used get_user_team and have never had an error...

when it returns 0 i believe it just gets handled no actual run time error.. i could be wrong though...
It's not that it errors, it returns false results on occasion.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-10-2010 , 18:44   Re: Only when being terrorist or CT
Reply With Quote #9

Quote:
Originally Posted by wrecked_ View Post
It's not that it errors, it returns false results on occasion.
Good ta know.
Doc-Holiday 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 03:59.


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