Comparing a string to a string in an array?
#10

Quote:
Originally Posted by Threshold
View Post
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 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;
}
EDIT: What's the difference between model and ID? Does ID refer to the weapon slot in which they are held?
Try this:
PHP Code:
CMD:weptest(playeridparams[])
{
    new 
string[50];
     if(
sscanf(params"s[50]"string)) return SendClientMessage(playeridCOLOUR_GREY"Usage: /weptest [weapon]");
    for(new 
047w++)
    {
        if(!
strcmp(WeaponNames[w], stringtrue))
        {
            
format(stringsizeof(string), "Weapon: %s | Ammo: %d | Weapon ID: %d"WeaponNames[w], WepAmmo[w], w);
            
SendClientMessage(playeridCOLOUR_WHITEstring);
        }
    }
    return 
1;

Both are same -_-
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)