Error help related to arrays
#1

I'm trying to create damage system which displays all damage a player takes. I've encountered a problem.
Whenever a player takes a headshot, I want function GetWeaponDamage(I made it) to multiply and show it as, for example, 60 instead of 30. This is the error:
pawn Код:
error 033: array must be indexed (variable "GetWeaponDamage")
The actual line:
pawn Код:
format(AddStr, sizeof(AddStr), "\n%d hits from %s("COL_RED"-%d"COL_WHITE") to HEAD", ShotAt[playerid][i][Bodypart][z], WeaponName(i), GetWeaponDamage(i)*2), strcat(dmgstring, AddStr);
The GetWeaponDamage(i)*2 does the error


This is GetWeaponDamage:
pawn Код:
GetWeaponDamage(WeaponID)
{
    new wepdamage[20];
    switch(WeaponID)
    {
        case 0,1..8: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_BRASS));
        case 22: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_COLT));
        case 23: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_SILENCED));
        case 24: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_DEAGLE));
        case 25: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_SHOTGUN));
        case 27: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_COMBAT));
        case 28: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_UZI));
        case 29: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_MP5));
        case 30: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_AK47));
        case 31: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_M4));
        case 32: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_TEC9));
        case 33: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_RIFLE));
        case 34: format(wepdamage,sizeof(wepdamage), "%d", floatround(WEAPON_DMG_SNIPER));
    }
    return wepdamage;
}
And the defines of WEAPON_DMG_something are 5.0, 20.0 etc...
Reply


Messages In This Thread
Error help related to arrays - by barbarbar1 - 15.08.2016, 09:42
Re: Error help related to arrays - by SyS - 15.08.2016, 10:01
Re: Error help related to arrays - by barbarbar1 - 15.08.2016, 10:14
Re: Error help related to arrays - by Stinged - 15.08.2016, 11:43

Forum Jump:


Users browsing this thread: 1 Guest(s)