AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Need script (https://forums.alliedmods.net/showthread.php?t=168506)

airidas338 09-30-2011 07:12

[Help] Need script
 
How to get CT count and T count? (what is Code?)

Napoleon_be 09-30-2011 07:54

Re: [Help] Need script
 
IF you press "TAB" you will see the count of the teams.

airidas338 09-30-2011 07:55

Re: [Help] Need script
 
I need a native for scripting...

Evaldas.Grigas 09-30-2011 07:57

Re: [Help] Need script
 
Quote:

Originally Posted by Napoleon_be (Post 1565794)
IF you press "TAB" you will see the count of the teams.

Hahahaha. Nice one.
I think your searching for this one? http://forums.alliedmods.net/showthread.php?p=193086

Elusive138 09-30-2011 07:58

Re: [Help] Need script
 
This was a stock I wrote some time ago
PHP Code:

stock get_player_team_count(&ctnum, &tnum) {
    
ctnum 0;
    
tnum 0;
    new 
maxplayers get_maxplayers();
    for (new 
1<= maxplayersi++) {
        if (!
is_user_connected(i))
            continue;
        
        switch (
cs_get_user_team(i)) {
            case 
CS_TEAM_Ttnum++;
            case 
CS_TEAM_CTctnum++;
        }
    }


Here's another one to get the player ids in a team
PHP Code:

stock get_players_byteam(players[32], &playersnumCsTeams:teamaliveonly=0) {  
    
playersnum 0;
    new 
maxplayers get_maxplayers();
    for (new 
1<= maxplayersi++) {
        if (!
is_user_connected(i))
            continue;
            
        if (
aliveonly && !is_user_alive(i))
            continue;
        
        if (
cs_get_user_team(i) == team) {
            
players[playersnum++] = i;
        }
    }


It's also possible to do both using get_players(), but I preferred to use the CsTeams enum rather than strings I could never remember. If you use them don't forget to #include <cstrike>

airidas338 09-30-2011 07:58

Re: [Help] Need script
 
THNX this will be ok

drekes 09-30-2011 08:56

Re: [Help] Need script
 
@ Elusive138

Your loops are wrong.
When you use the value of get_maxplayers(), you have to start from 1 & include the maxplayers.

like:
PHP Code:

for(new 1<= maxplayersi++); 


Elusive138 09-30-2011 09:45

Re: [Help] Need script
 
Quote:

Originally Posted by drekes (Post 1565827)
@ Elusive138

Your loops are wrong.
When you use the value of get_maxplayers(), you have to start from 1 & include the maxplayers.

like:
PHP Code:

for(new 1<= maxplayersi++); 


Ah... probably not a good thing I never noticed. Thanks for the tip, luckily I haven't used that on anything too important yet... I hope. *goes to check*

maoxianxie 10-01-2011 00:20

Re: [Help] Need script
 
Whats the meaning of "&" in "get_player_team_count(&ctnum, &tnum)" ?
And how should I use the stock function in my own code if I want to set the T's health to the ctnum*1000?
Sorry for my lack of such knowledge.


All times are GMT -4. The time now is 19:42.

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