You are setting the ZombieClass[] value via random_num( 1 , 4 ) which will give you a number in the range of 1 - 4. The max number that you can use to not error is 0 - 3; remember, arrays range from 0 to size-1. Change random_num(1,4) to random( 3 ). You will need to make adjustments with other parts of your code because it looks like you used numbers 1-4 for zombieclasses instead of 0-3. Instead of using numbers, use the enum names.
Code:
#define MAXCLASSES 4
new ZombieClass[33]
//CLASSES array sized @ 4. 0=Classic, 1=ELectric, 2=Strong, 3=Mystic
new const CLASSES[MAXCLASSES][] =
{
"Classic",
"Electric",
"Strong",
"Mystic"
}
//Use these enum names in your code instead of numbers!!
//Like this: if ( ZombieClass[ id ] == Strong ) etc
enum
{
Classic = 0,
Electric,
Strong,
Mystic
}
// ...
public fw_PlayerSpawn(id)
{
if (!is_user_alive(id))
return;
set_task(0.5, "ShowHealth", id)
g_zombie[id] = (get_user_team(id) == 1)
ZombieClass[id] = random_num(1, 4)
//Change to
ZombieClass[id] = random( 3 )
And here, it will be easier to use your enums
PHP Code:
// if ( ZombieClass[id] == Classic ) is the same as "if ZombieClass[] == 0"
if (ZombieClass[id] == 1)
{
new Float: Gravity1, Float: Health1
Health1 = get_pcvar_float(classic_health)
Gravity1 = get_pcvar_float(classic_gravity)
set_pev(id, pev_health, Health1)
set_user_gravity(id, Gravity1)
}
// if ( ZombieClass[id] == Electric ) is the same as "if ZombieClass[] == 1"
else if (ZombieClass[id] == 2)
__________________