AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   weapon drop plugin (https://forums.alliedmods.net/showthread.php?t=17848)

ch3cker 09-10-2005 10:37

weapon drop plugin
 
can zou help me with this plugin ??
on my computer it`s working but on the internet server it`s dont working:

Code:

#include <amxmodx>

public plugin_init() {
       
        register_plugin("weapon drop","1.0","ch3cker") 
        register_logevent("new_round",2,"0=World triggered","1=Round_Start")
}

public new_round()
{
    new players[32]
    new inum
    get_players(players,inum)
    for(new i; i <= inum; i++) {
                                  new weapon[32]
                                new wnum
                                get_user_weapons(players[i],weapon,wnum)
                                for(new a; a <= wnum; a++) {
                                client_cmd(players[i],"%s",weapon[a])
                                client_cmd(players[i],"drop")
                return PLUGIN_CONTINUE
                  }
        }
}

normaly it should drop the weapon on the start of a round. Plz help me

XxAvalanchexX 09-10-2005 13:13

First, let's fix up your indenting:

Code:
public new_round() {     new players[32]     new inum     get_players(players,inum)     for(new i; i <= inum; i++) {         new weapon[32]         new wnum         get_user_weapons(players[i],weapon,wnum)         for(new a; a <= wnum; a++) {             client_cmd(players[i],"%s",weapon[a])             client_cmd(players[i],"drop")             return PLUGIN_CONTINUE         }     } }

First thing's first: Your for() loops shouldn't be checking if i/a is <=, it should simply be <. The reason is that the functions return the number of items starting at 1, but array indexes start at 0, so the max array index is the number of items - 1.

Secondly, you return PLUGIN_CONTINUE, thus stopping the entire function, after the first player's first weapon is dropped. Remove that and it should work.

ch3cker 09-10-2005 13:36

ok thx
i will test it


All times are GMT -4. The time now is 14:25.

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