/w2 questions
#1

Well, I don't have any issues or anything, the command I already have works, however there are two things I tried to do to improve my /w2 command and couldn't find a way to do it.

1. As of now, it only works by "/w2 [weapon name]" and if you will type the weapon id instead of the weapon name it won't find the weapon.
So how can I make it so it'll work for both weapon names and weapon ids?

2. As of now, if I type in a weapon name that wasn't found (E.G. if I'd type in "blahasdh" it'd do the same) then it just gives me the weapon "Brass Knuckles" for some reason.
I want instead, that if it couldn't find the weapon id, that it will say a message like "Error, invalid weapon name"

How can I do these?

Here is my cmd
PHP код:
CMD:w2(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[Error] You are not authorised to use this command!");
    new 
wepname[60], message[60];
    if(
sscanf(params"s[10]"wepname)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /w2 [Weapon Name]");
    else
    {
        new 
wepid GetWeaponModelIDFromName(wepname);
        if(
wepid <= || wepid 47) return SendClientMessage(playeridCOLOR_RED"[ERROR]: Invalid WEAPONID/NAME");
        
GivePlayerWeapon(playeridwepid500);
        
format(messagesizeof(message), "[Info] You were given weapon %s (ID: %d) with 500 ammo."aWeaponNames[wepid], wepid);
        
SendClientMessage(playeridCOLOR_WHITEmessage);
    }
    return 
1;

Here is the stock I use (even though I believe every1 are using the same one anyways)
PHP код:
GetWeaponModelIDFromName(wname[])
{
    for(new 
047i++)
    {
        if (
== 19 || == 20 || == 21) continue;
        if (
strfind(aWeaponNames[i], wnametrue) != -1)
        {
            return 
i;
        }
    }
    return 
1;

Reply


Messages In This Thread
/w2 questions - by Tomer!.$ - 31.08.2013, 19:02
Re: /w2 questions - by PrinceKumar - 31.08.2013, 19:35
Re: /w2 questions - by Tomer!.$ - 01.09.2013, 11:27
Re: /w2 questions - by xganyx - 01.09.2013, 11:37
Re: /w2 questions - by Dragonsaurus - 01.09.2013, 11:37
Re: /w2 questions - by Tomer!.$ - 01.09.2013, 11:51
Re: /w2 questions - by Dragonsaurus - 01.09.2013, 12:04

Forum Jump:


Users browsing this thread: 4 Guest(s)