Raised This Month: $ Target: $400
 0% 

how to check if player is...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Checkmarks
BANNED
Join Date: Sep 2007
Location: kentucky
Old 12-11-2007 , 16:57   how to check if player is...
Reply With Quote #1

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..
Checkmarks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-11-2007 , 18:12   Re: how to check if player is...
Reply With Quote #2

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")
                }
            }
        }
    } 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Checkmarks
BANNED
Join Date: Sep 2007
Location: kentucky
Old 12-11-2007 , 18:26   Re: how to check if player is...
Reply With Quote #3

I really don't understand about any of that, I don't know what all those codes mean O.o
Checkmarks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-11-2007 , 18:42   Re: how to check if player is...
Reply With Quote #4

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
     
}

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hackandmore
Member
Join Date: Jul 2007
Location: pe strada
Old 02-18-2008 , 10:22   Re: how to check if player is...
Reply With Quote #5

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
__________________
some +karma please
[IMG]http://img253.**************/img253/9467/semnatura2cw6.jpg[/IMG][IMG]http://img236.**************/img236/9776/steauatr9.jpg[/IMG]

Last edited by hackandmore; 02-18-2008 at 10:24. Reason: spelling error
hackandmore is offline
Send a message via Yahoo to hackandmore
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 11:07.


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