AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to check if player is... (https://forums.alliedmods.net/showthread.php?t=64257)

Checkmarks 12-11-2007 16:57

how to check if player is...
 
How can I check to see if the player is the last one on his team alive.
I also want to check to see (inside the previous check) if there are 3 or more players on the OTHER team alive along with him.
Example: 1 Terrorist and 3(or more) CT's remain. I want to check to see if this is true or not, so that I can then give the Terrorist some special abilities.
Example2: 1 CT and 3 Terrorists. I want to check to see if this is true nor not, so that I can then give the CT some special abilites.
etc. etc. etc.

Oh and also, I'm pretty inexperienced, so as clear as you can be would help a lot ;)

Thanks in advance..

ConnorMcLeod 12-11-2007 18:12

Re: how to check if player is...
 
miscstats.sma, this is checked each time someone dies.
PHP Code:

    if (LastMan)
    {
        new 
cts[32], ts[32], ctsnumtsnum
        
new maxplayers get_maxplayers()
        new 
team
        
        
for (new i=1i<=maxplayersi++)
        {
            if (!
is_user_connected(i) || !is_user_alive(i))
            {
                continue
            }
            
team get_user_team(i)
            if (
team == 1)
            {
                
ts[tsnum++] = i
            
} else if (team == 2) {
                
cts[ctsnum++] = i
            
}
        }
        
        if (
ctsnum == && tsnum == 1)
        {
            new 
ctname[32], tname[32]
            
            
get_user_name(cts[0], ctname31)
            
get_user_name(ts[0], tname31)
            
            
set_hudmessage(0255255, -1.00.3506.06.00.50.15, -1)
            
ShowSyncHudMsg(0g_center1_sync"%s vs. %s"ctnametname)
            
            
play_sound("misc/maytheforce")
        }
        else if (!
g_LastAnnounce)
        {
            new 
oposite 0_team 0
            
            
if (ctsnum == && tsnum 1)
            {
                
g_LastAnnounce cts[0]
                
oposite tsnum
                _team 
0
            
}
            else if (
tsnum == && ctsnum 1)
            {
                
g_LastAnnounce ts[0]
                
oposite ctsnum
                _team 
1
            
}

            if (
g_LastAnnounce)
            {
                new 
name[32]
                
                
get_user_name(g_LastAnnouncename31)
                
                
set_hudmessage(0255255, -1.00.3806.06.00.50.15, -1)
                
ShowSyncHudMsg(0g_center1_sync"%s (%d HP) vs. %d %s%s: %L"nameget_user_health(g_LastAnnounce), opositeg_teamsNames[_team], (oposite == 1) ? "" "S"LANG_PLAYERg_LastMessages[random_num(03)])
                
                if (!
is_user_connecting(g_LastAnnounce))
                {
                    
client_cmd(g_LastAnnounce"spk misc/oneandonly")
                }
            }
        }
    } 


Checkmarks 12-11-2007 18:26

Re: how to check if player is...
 
I really don't understand about any of that, I don't know what all those codes mean O.o

ConnorMcLeod 12-11-2007 18:42

Re: how to check if player is...
 
Same simplfied with what you want :
PHP Code:

#include <amxmodx>

new g_maxplayers

public plugin_init()
{
    
register_plugin("name""version""authoe")
    
register_event("DeathMsg""eDeathMsg""a"// this event is called everytime someone dies
}

public 
plugin_cfg()
{
    
g_maxplayers get_maxplayers() // here we get how many players can be on the server
}

public 
eDeathMsg()
{
    new 
ctsnum // CT number (0 as we just created it
    
new tsnum  // T num
    
new team
        
    
for (new i=1i<=g_maxplayersi++) // here a loop from player 1 to the max
    
{// we only want to collect alive players
        
if (!is_user_connected(i) || !is_user_alive(i))
        { 
// so if the player is not on the server, or is dead
            
continue // we just continue to the next possible player
        
}
        
// if the player n°i is alive, the check his team
        
team get_user_team(i// if player team is 1 (T) or 2(CT), increase this team players number
        
if (team == 1)
        {
            
tsnum++ = i
          
}
        else if (
team == 2)
        {
            
ctsnum++ = // same here
        
}
    }

    if (
ctsnum == && tsnum == 3)
     {
        
// do code here    
    
}
     else if (
tsnum == && ctsnum == 3)
     {
        
// do code here
     
}



hackandmore 02-18-2008 10:22

Re: how to check if player is...
 
hi...
there ar some errors in the second post
"must be lvalue <non-constant>

Code:

tsnum++ = i
compiling error same at
Code:

ctsnum++ = i
i think you should delete the " = i" part from each of them


All times are GMT -4. The time now is 11:07.

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