Help with for(new i = 0 and ....
#2

Please, tabulate your code correctly, you'll see problems like that instantly.


pawn Code:
CMD:giveweaponall(playerid,params[])
{
    #pragma unused params
    new string[128];
    new Ammo;
    new Wepid;
    new ID;
    if(AdminLevel[playerid] < 4) return SendClientMessage(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}You do not have the the right admin level for this command.");
    if(sscanf(params,"ii",Wepid,Ammo))
    {
        SendClientMessage(playerid,COLOR_WHITE,""COL_USAGE"[SYNTAX] {FFFFFF}/giveweaponall [WEAPON_ID] [AMMO]");
        return 1;
    }
    if(!IsValidWeapon(Wepid)) return SendClientMessage(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}Invalid weapon ID. Please enter a weapon ID between <1-18> || <22-46>.");
    if(AdminLevel[playerid] < 5)
    {
        if(Wepid == 38) return SCM(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}This weapon is not allowed in this command.");
        if(Wepid == 45) return SCM(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}This weapon is not allowed in this command.");
        if(Wepid == 44) return SCM(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}This weapon is not allowed in this command.");
        if(Wepid == 39) return SCM(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}This weapon is not allowed in this command.");
        if(Wepid == 40) return SCM(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}This weapon is not allowed in this command.");
        if(Wepid == 36) return SCM(playerid,COLOR_WHITE,"{AFAFAF}[Error]: {FFFFFF}This weapon is not allowed in this command.");
    }

    format(string,sizeof(string),""COL_ADMIN"[ADMIN] {FFFFFF}All players have been given a %s from %s(%d)!",aWeaponNames[Wepid],PlayerName(playerid),ID);
    SendClientMessageToAll(COLOR_WHITE,string);

    format(string,sizeof(string),"%s(%d) has given all players a %s",PlayerName(playerid),playerid,aWeaponNames[Wepid]);
    SendPROMessage(string);

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(JailTime[i] == 0)
        {
            GivePlayerWeapon(i,Wepid,Ammo);
        }
    }
    return 1;
}
I moved "Player adsad has given..." as it's called using SendClientMessageToAll, we don't want it sent MAX_PLAYERS times, and I removed return in loop
Reply


Messages In This Thread
Help with for(new i = 0 and .... - by aCloudy - 12.03.2015, 15:57
Re: Help with for(new i = 0 and .... - by Misiur - 12.03.2015, 16:03

Forum Jump:


Users browsing this thread: 1 Guest(s)