WeaponNames[model];
new WeaponNames[47][] = // As below
{
"Fists","Brass Knuckles","Golf Club","Nightstick","Knife","Baseball Bat","Shovel","Pool Cue","Katana","Chainsaw","Purple Dildo","Small White Vibrator","Large White Vibrator","Silver Vibrator",
"Flowers","Cane","Grenade","Tear Gas Grenade","Molotov Cocktail","Jetpack"," "," ","9mm Pistol","Silenced Pistol","Desert Eagle","12-gauge Shotgun","Sawn-off Shotgun","SPAS-12",
"Micro Uzi","MP5","AK-47","M4A1 Carbine","TEC-9","Country Rifle","Sniper Rifle","Rocket Launcher","Heatseeker","Flamethrower","Minigun","Satchel Charge","Detonator","Spray Can","Fire Extinguisher",
"Camera","Night Vision Goggles", "Thermal Goggles","Parachute"
};
if(!strcmp(WeaponNames[modelid], [second string here], true))
for(new w = 0; w < 45; w++)
{
if(!strcmp(WeaponNames[w], USER INPUT, true))
{
if(Playerhasthisweaponid)
{
//do the rest here
}
}
}
|
So if I looped through all of the ID's I could check which one compares correctly?
Would that work? Like this. pawn Code:
|
CMD:weptest(playerid, params[])
{
new string[50];
if(sscanf(params, "s[50]", string)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /weptest [weapon]");
for(new w = 0; w < 12; w++)
{
new model = WepModel[PlayerWeapons[w][playerid]];
if(!strcmp(WeaponNames[model], string, true))
{
format(string, sizeof(string), "Weapon: %s | Ammo: %d | Weapon ID: %d", WeaponNames[model], WepAmmo[w], w);
SendClientMessage(playerid, COLOUR_WHITE, string);
}
}
return 1;
}
CMD:weptest(playerid, params[])
{
new string[50];
if(sscanf(params, "s[50]", string)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /weptest [weapon]");
for(new w = 0; w < 47; w++)
{
if(!strcmp(WeaponNames[w], string, true))
{
format(string, sizeof(string), "Weapon: %s | Ammo: %d | Weapon ID: %d", WeaponNames[w], WepAmmo[w], w);
SendClientMessage(playerid, COLOUR_WHITE, string);
}
}
return 1;
}
CMD:weptest(playerid, params[])
{
new weapname[25];
if(sscanf(params, "s[25]", weapname)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /weptest [weapon]");
for(new w = 0; w < sizeof(WeaponNames); w++)
{
if(!strcmp(WeaponNames[w], weapname, true))
{
new string[65];
format(string, sizeof(string), "Weapon: %s | Ammo: %d | Weapon ID: %d", WeaponNames[w], WepAmmo[w], w);
SendClientMessage(playerid, COLOUR_WHITE, string);
break;
}
}
return 1;
}
|
Not quite sure why you're using 'PlayerWeapons' in the first place, this is all you really need:
pawn Code:
|
CMD:weptest(playerid, params[])
{
new string[50];
if(sscanf(params, "s[50]", string)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /weptest [weapon]");
for(new w = 0; w < 47; w++)
{
if(!strcmp(WeaponNames[w], string, true))
{
format(string, sizeof(string), "Weapon: %s | Ammo: %d | Weapon ID: %d", WeaponNames[w], WepAmmo[w], w);
SendClientMessage(playerid, COLOUR_WHITE, string);
}
}
return 1;
}