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 p = 0; p <= MAXPLAYERS; p++) {
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(id, 373);
if(pev_valid(iWpn) && get_user_team(id) == 1)
{
if(get_pdata_int(iWpn, 43) != CSW_KNIFE ) {
engclient_cmd(id, "weapon_knife");
client_print(id, print_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.
|