AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Looping for players and weapon pick up (https://forums.alliedmods.net/showthread.php?t=120561)

t3hNox 03-06-2010 04:41

Looping for players and weapon pick up
 
Hi there,
I'm trying things out and I have two questions.

First. I want to get a current amount of players. Code:
PHP Code:

        new const MAXPLAYERS get_maxplayers() 
    new 
playerCount
    
for (new 0<= MAXPLAYERSp++) {
        
playerCount++
    }
    if(
playerCount >= 6) {
        
//do something 
    


Second. Is there a more efficient way how to do this ?
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init() {
        
//register
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink_post"1);

}

public 
fwd_PlayerPreThink_post(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    static 
iWpn;
    
iWpn get_pdata_cbase(id373);
    
    if(
pev_valid(iWpn) && get_user_team(id) == 1)
    {
        if(
get_pdata_int(iWpn43) != CSW_KNIFE ) { 
            
engclient_cmd(id"weapon_knife");
            
client_print(idprint_center"** You cannot pick up this weapon **")
        }
    }
    return 
FMRES_IGNORED;


(The code above is mostly copied from another plugin.) How can I make that grenades and USP can be picked up too ?

I was in hurry when I wrote this so excause me for mistakes.


All times are GMT -4. The time now is 08:40.

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