AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Help with stock (https://forums.alliedmods.net/showthread.php?t=308627)

iceeedr 06-27-2018 19:52

Help with stock
 
Hello moders, good night, I hope everyone is well. Could someone give me an example of how to create (if not exist) a function that returns a specific number of players per team. Below I have a small example.

PHP Code:

#include <amxmodx>
#include <cstrike>

enum uUserData
{    
    
bool:bSurrender
}

new 
UserData[MAX_PLAYERS 1][uUserData]

// The player performs the function
    
UserData[id][bSurrender] = true
}

//Now what I need is a function that returns me the players who are surrendering, by teams [CT and TR] 


Bugsy 06-27-2018 20:16

Re: Help with stock
 
Call get_players() twice using the team flag. Use 2 parameters on your function, both by-reference.

iceeedr 06-27-2018 23:22

Re: Help with stock
 
Solved with

PHP Code:

GetSurrender(CsTeams:Team)
{
    new 
Players[32],Num;
    
get_players(Players,Num,"ceh",Team == CS_TEAM_T "TERRORIST" "CT");

    new 
Count 0;

    for(new 
0;Num;i++)
    {
        if(
UserData[Players[i]][bSurrender])
        {
            
Count++;
        }
    }

    return 
Count;


Thanks Bugsy and Smiley :)


All times are GMT -4. The time now is 12:38.

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