Checking Weapon ID-Name -
Ruben_Alonso - 21.04.2012
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.
Re: Checking Weapon ID-Name -
Roel - 21.04.2012
Well are you sure that your 'weapon' var is a string?
Re: Checking Weapon ID-Name -
Ruben_Alonso - 21.04.2012
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;
}
Re: Checking Weapon ID-Name -
Roel - 21.04.2012
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;
}
Re: Checking Weapon ID-Name -
Ruben_Alonso - 21.04.2012
What's the change?
Re: Checking Weapon ID-Name -
Roel - 21.04.2012
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);
Re: Checking Weapon ID-Name -
Ruben_Alonso - 21.04.2012
Good point, i forgot it, but it will not fix the error
EDIT: Well, doesn't really fix it
Re: Checking Weapon ID-Name -
Roel - 21.04.2012
Send me the cmd you have now.
Or did you copy the cmd I modded?
Re: Checking Weapon ID-Name -
Ruben_Alonso - 21.04.2012
Just changed the weapon to checkweapon on GivePlayerWeapon()
Re: Checking Weapon ID-Name -
Roel - 21.04.2012
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.