Invalid Function or Declaration
#1

I'm trying my hands on a anti-weapon hack system and I'm getting this nasty error I can't seem to fix. I know there's an unmatched closing brace somewhere, but my eyes can't seem to find it... -.- Maybe someone else can spot it.
pawn Код:
(2161): error 010: invalid function or declaration
Reply
#2

erm i dont know it it will work but i just replaced the switch(weapon) to if(weapon) and it compiled without errors =P

give it a try.(my first try to solve =P)and its not a missing brace
Reply
#3

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
erm i dont know it it will work but i just replaced the switch(weapon) to if(weapon) and it compiled without errors =P

give it a try.(my first try to solve =P)and its not a missing brace
It compiled without errors because it has the "stock" initialiser. So the compiler just skips that area of code unless it is used. And a switch is far more efficient than an if, else if structure.
Reply
#4

but i dont get it it had a stock tag b4 too. so all i did was replace the word "swtch" with "if". so if it doesnt check the code how did the error dissappear. just give it a try
Reply
#5

what is line 2160-2162?
Reply
#6

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
but i dont get it it had a stock tag b4 too. so all i did was replace the word "swtch" with "if". so if it doesnt check the code how did the error dissappear. just give it a try
Quote:
Originally Posted by SA-MP Wiki
stock is used to declare variables and functions which may not be used but which you don't want to generate unused warnings for.
Basically its saying that if you don't use the function with the stock initialiser, the compiler won't generate warnings or errors for it so it "skips" over the code.
Reply
#7

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
what is line 2160-2162?
Line 2161 is commented on stock SetPlayerAmmoEx
Reply
#8

Quote:
Originally Posted by Th3Angel
Посмотреть сообщение
Basically its saying that if you don't use the function with the stock initialiser, the compiler won't generate warnings or errors.
well i feel its only stating abt the declaration of vars.

Why dont you just try you gm replacing it -.- im eagry for the results ;(
Reply
#9

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
well i feel its only stating abt the declaration of vars.

Why dont you just try you gm replacing it -.- im eagry for the results ;(
Its not going to work... Because if you just replaced the switch with if, there's still part of the switch structure. And if I changed it to and if, else if structure, there's no point because they're really both the same thing...
Reply
#10

pawn Код:
stock SetPlayerAmmoEx(playerid, weapon, ammo) //Line 2161
{
    new slot;
    switch(weapon)
    {
        case 0..1: slot = 0;
        case 2..9: slot = 1;
        case 22..24: slot = 2;
        case 25..27: slot = 3;
        case 28..29: slot = 4;
        case 30..31: slot = 5;
        case 33..34: slot = 6;
        case 35..38: slot = 7;
        case 16..18, 39: slot = 8;
        case 41..43: slot = 9;
        case 11..15: slot = 10; // YOU MISSED THE =
        case 44..46: slot = 11;
        case 40: slot = 12;
    }
    pAmmo[playerid][slot] = ammo;
    SetPlayerAmmo(playerid, weapon, ammo);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)