Checking Weapon ID-Name
#1

Hello SA-MP,

Story: I was quite exited listening to Snoop Dogg - Boss Life and developing my project, when i find myself with an error that says:

pawn Код:
error 035: argument type mismatch (argument 1)
Okay, i check and it was here:

pawn Код:
new checkweapon = CompareWeaponName(weapon);
So i went to the function to see if i did something wrong...

pawn Код:
public CompareWeaponName(string[])
{
    for (new i=1; i <= 47; i++)
    {
        if(strcmp(aWeaponNames[i], string, true) == 0)
        {
            return i;
        }
    }
    return false;
}
Now i'm hitting my head on a nail and i can't understand what's wrong.

Thanks for reading and possible help.
Reply
#2

Well are you sure that your 'weapon' var is a string?
Reply
#3

pawn Код:
CMD:giveweapon(playerid, params[])
{
    new id, weapon, ammo;
    if (sscanf(params, "usd", id, weapon, ammo)) SendClientMessage(playerid, 0xFF0000AA, "DEBUG: \"/giveweapon <playerid> <weaponid> <ammo>\"");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "DEBUG: \"/giveweapon <playerid> <weaponid> <ammo>\"");
    new checkweapon = CompareWeaponName(weapon);
    if(!checkweapon) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Not a valid Weapon Name");
    if(IsPlayerConnected(id))
    {
        if(checkweapon==2||checkweapon==4||checkweapon==5||checkweapon==6||checkweapon==14||checkweapon==41||checkweapon==43)
        {
            GivePlayerWeapon(id, weapon, 1);
            return true;
        }
        else GivePlayerWeapon(id, weapon, ammo);
    }
    return true;
}
Reply
#4

pawn Код:
CMD:giveweapon(playerid, params[])
{
    new id, weapon[26], ammo;
    if (sscanf(params, "usd", id, weapon, ammo)) SendClientMessage(playerid, 0xFF0000AA, "DEBUG: \"/giveweapon <playerid> <weaponid> <ammo>\"");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "DEBUG: \"/giveweapon <playerid> <weaponid> <ammo>\"");
    new checkweapon = CompareWeaponName(weapon);
    if(!checkweapon) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Not a valid Weapon Name");
    if(IsPlayerConnected(id))
    {
        if(checkweapon==2||checkweapon==4||checkweapon==5||checkweapon==6||checkweapon==14||checkweapon==41||checkweapon==43)
        {
            GivePlayerWeapon(id, checkweapon, 1);
            return true;
        }
        else GivePlayerWeapon(id, checkweapon, ammo);
    }
    return true;
}
Reply
#5

What's the change?
Reply
#6

Just copy it, I change to weapon variable to a string.
And changed your GivePlayerWeapon from:
GivePlayerWeapon(id,weapon,ammo);
to
GivePlayerWeapon(id,checkweapon,ammo);
Reply
#7

Good point, i forgot it, but it will not fix the error

EDIT: Well, doesn't really fix it
Reply
#8

Send me the cmd you have now.
Or did you copy the cmd I modded?
Reply
#9

Just changed the weapon to checkweapon on GivePlayerWeapon()
Reply
#10

Omg, why don't you just copy the cmd that i have sent you.
Like I said, I also changed to weapon variable to a string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)