giveallweapon having "i" error
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That's not the only problem. You also use return in the loop instead of continue;

You must also check the Wepid because if you pass any out-of-bounds value in aWeaponNames, it's going to give a run time error: Array index out of bounds.
pawn Код:
dcmd_giveallweapon(playerid, params[])
{
    new Wepid, Ammo;
    if(sscanf(params, "ii", Wepid,Ammo)) return SendClientMessage(playerid, -1,"{FF0099}[ADMIN]{FFFFFF}/giveallweapon [Wepid] [Ammo]");
    if(!(0 <= Wepid <= 46) || (Wepid == 19 || Wepid == 20 || Wepid == 21)) return SendClientMessage(playerid, -1,"Weapon IDs: 0-46. 19/20/21 are invalid.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GivePlayerWeapon(i, Wepid, Ammo);
    }
    new string[128];
    format(string,sizeof(string),"{FF0099}[ADMIN]{FFFFFF}Everyone has been given a %s!",aWeaponNames[Wepid]);
    SendClientMessageToAll(COLOR_ADMIN,string);
    return 1;
}
Working perfectly.Konstantinos,its been long that i've been going through all your posts and threads,you've really helped me while coding!Every code posted by you only works fine for me!
Reply


Messages In This Thread
giveallweapon having "i" error - by Sojo12 - 22.03.2014, 11:50
Re: giveallweapon having "i" error - by Dan. - 22.03.2014, 11:51
Re: giveallweapon having "i" error - by aboa - 22.03.2014, 11:53
Re: giveallweapon having "i" error - by ReD_HunTeR - 22.03.2014, 11:55
Re: giveallweapon having "i" error - by Sojo12 - 22.03.2014, 11:58
Re: giveallweapon having "i" error - by Hanuman - 22.03.2014, 11:58
Re: giveallweapon having "i" error - by Konstantinos - 22.03.2014, 11:59
Re: giveallweapon having "i" error - by Sojo12 - 22.03.2014, 12:04

Forum Jump:


Users browsing this thread: 2 Guest(s)