AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Give all players item (https://forums.alliedmods.net/showthread.php?t=220859)

Randomize 07-15-2013 09:55

Give all players item
 
I was trying to give all players an item everytime they spawn. But it seems only me who receive it.
PHP Code:

RegisterHam(Ham_Spawn"player""fwd_spawn"1

PHP Code:

public fwd_spawn(id)
{
    
    new 
players[32], num
    get_players
(playersnum"ae""T")
        
    if (!
is_user_alive(id))
    if (
get_cvar_num("health_enable") == 1)
    {
        
set_user_health(id,  120)
    }
    
    new 
weapon get_user_weapon(id)
    if (
is_user_alive(id))
    {
        
acg_drawoverviewradar(id100180180255255255)
        
g_bEnabled[id] = 1
        acg_showteammate
(id1)        
        
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
        
give_item(id"weapon_hegrenade")
        
cs_set_user_bpammo(idCSW_HEGRENADE2)
        
        for(new 
0numi++)
        {
            
give_item(players[id], "weapon_m4a1")
        }
    }
    if (
weapon == CSW_HEGRENADE)
    {
        
cs_set_weapon_ammo(id2)
    }
    return 
PLUGIN_CONTINUE



K1d0x 07-15-2013 10:07

Re: Give all players item
 
PHP Code:

public fwd_spawn()
{
    new 
Players[32]
    new 
playerCountiid
    get_players
(PlayersplayerCount"ce""TERRORIST");
    
    for (
i=0i<playerCounti++) {
        
id Players[i
    
        if (
get_cvar_num("health_enable") == 1)
        {
            
set_user_health(id,  120)
        }
        
        new 
weapon get_user_weapon(id)
        if (
is_user_alive(id))
        {
            
acg_drawoverviewradar(id100180180255255255)
            
g_bEnabled[id] = 1
            acg_showteammate
(id1)        
            
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
            
give_item(id"weapon_hegrenade")
            
cs_set_user_bpammo(idCSW_HEGRENADE2)
            
            
give_item(id"weapon_m4a1")

            if (
weapon == CSW_HEGRENADE)
            {
                
cs_set_weapon_ammo(id2)
            }
        }
    }
    
    return 
PLUGIN_CONTINUE


PS: if you use flag "a" in get_players then you don't need to use is_user_alive(id) function, id = players are alive, no bots and are terrorists

ConnorMcLeod 07-15-2013 10:31

Re: Give all players item
 
Don't use get_players in Spawn callback ! DAMN !

Also, players[ id ] means nothing when you increment i.

K1d0x 07-15-2013 10:37

Re: Give all players item
 
Quote:

Originally Posted by ConnorMcLeod (Post 1991323)
Don't use get_players in Spawn callback ! DAMN !

Also, players[ id ] means nothing when you increment i.

PHP Code:

public fwd_spawn(id)
{
    if(!
is_user_alive(id))
        return 
0
    
    
if(get_user_team(id) == 1) {
        if (
get_cvar_num("health_enable") == 1)
        {
            
set_user_health(id,  120)
        }
            
        new 
weapon get_user_weapon(id)
        
        
acg_drawoverviewradar(id100180180255255255)
        
g_bEnabled[id] = 1
        acg_showteammate
(id1)        
        
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
        
give_item(id"weapon_hegrenade")
        
cs_set_user_bpammo(idCSW_HEGRENADE2)
        
        
give_item(id"weapon_m4a1")
        
        if (
weapon == CSW_HEGRENADE)
        {
            
cs_set_weapon_ammo(id2)
        }
    }
    
    return 
0



baneado 07-15-2013 10:38

Re: Give all players item
 
LOL? In your code when somebody respawn, you give weapons and health for all players...

zRokh 07-15-2013 11:08

Re: Give all players item
 
Quote:

Originally Posted by baneado (Post 1991332)
LOL? In your code when somebody respawn, you give weapons and health for all players...

CT1: *Thinking* oo, a camper with 3hp, im gonna knife him :D
CT2: *DEAD*
*All players get full HP and weapons*
*The sound of someone getting weapons*
http://25.media.tumblr.com/tumblr_lr...61hio1_500.jpg


All times are GMT -4. The time now is 06:20.

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