AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved foreach() equivalent in AMXX? (https://forums.alliedmods.net/showthread.php?t=298709)

gabuch2 06-20-2017 21:30

foreach() equivalent in AMXX?
 
Hello

I have these groups of arrays

Code:
//this group appears in HALF-LIFE new const g_sMonsterGroup1[][] = {     "monster_alien_controller",     "monster_alien_grunt",     "monster_alien_slave",     "monster_apache",     "monster_babycrab",     "monster_barnacle",     "monster_barney",     "monster_bigmomma",     "monster_bullchicken",     //"monster_cockroach",     "monster_gargantua",     "monster_grunt_repel",     "monster_headcrab",     "monster_houndeye",     "monster_human_assassin",     "monster_human_grunt",     "monster_ichthyosaur",     "monster_leech",     "monster_miniturret",     "monster_nihilanth",     "monster_osprey",     "monster_rat",     "monster_scientist",     "monster_sentry",     "monster_snark",     "monster_tentacle",     "monster_turret",     "monster_zombie" } //this group appears in COUNTER-STRIKE new const g_sMonsterGroup2[][] = {     "func_hostage" } //this group appears in OPPOSING FORCE new const g_sMonsterGroup3[][] = {     "monster_alien_babyvoltigore",     "monster_alien_voltigore",     "monster_assassin_repel",     "monster_blkop_osprey",     "monster_blkop_apache",     "monster_cleansuit_scientist",     "monster_gonome",     "monster_grunt_ally_repel",     "monster_human_grunt_ally",     "monster_human_medic_ally",     "monster_human_torch_ally",     "monster_male_assassin",     "monster_medic_ally_repel",     "monster_otis",     "monster_pitdrone",     "monster_shockroach",     "monster_shocktrooper",     "monster_torch_ally_repel",     "monster_zombie_barney",     "monster_zombie_soldier",     "monster_geneworm",     "monster_pitworm" } //this group appears in SVEN COOP new const g_sMonsterGroup4[][] = {     "monster_alien_tor",     "monster_babygarg",     "monster_bodyguard",     "monster_chumtoad",     "monster_hwgrunt",     "monster_hwgrunt_repel",     "monster_kingpin",     "monster_robogrunt",     "monster_robogrunt_repel",     "monster_sqknest" } //this group appears in TEAM FORTRESS CLASSIC new const g_sMonsterGroup5[][] = {     "building_sentrygun_base",     "building_sentrygun",     "building_teleporter",     "building_dispenser" }

How can I make an equivalent of this, for example, in AMXX?

Code:

foreach(string in g_sMonsterGroup5)
{
        RegisterHam(Ham_TakeDamage, string, "eventDamage", 1);
}

Thanks in advance

klippy 06-20-2017 21:31

Re: foreach() equivalent in AMXX?
 
PHP Code:

for(new 0sizeof(g_sMonsterGroup5); i++)
{
    
RegisterHam(Ham_TakeDamageg_sMonsterGroup5[i], "eventDamage"1);



gabuch2 06-20-2017 21:33

Re: foreach() equivalent in AMXX?
 
Now I feel dumb. :oops:

Thank you so much Klippy!


All times are GMT -4. The time now is 23:03.

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