SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Русский/Russian

Reply
 
Thread Tools Display Modes
Old 03/02/2017, 12:35 PM   #1301
jakebat
Big Clucker
 
Join Date: Aug 2013
Posts: 69
Reputation: 2
Default Re: Оптимизация кода

Возможно ли оптимизировать?
PHP Code:
    else if(playertextid == TDautosalon[playerid][15])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 175;}else{colorcarz[playerid][1] = 175;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
         else if(
playertextid == TDautosalon[playerid][16])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 1;}else{colorcarz[playerid][1] = 1;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][17])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 155;}else{colorcarz[playerid][1] = 155;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][18])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 111;}else{colorcarz[playerid][1] = 111;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][19])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 162;}else{colorcarz[playerid][1] = 162;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][20])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 0;}else{colorcarz[playerid][1] = 0;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][21])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 194;}else{colorcarz[playerid][1] = 194;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][22])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 187;}else{colorcarz[playerid][1] = 187;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][23])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 174;}else{colorcarz[playerid][1] = 174;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][24])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 136;}else{colorcarz[playerid][1] = 136;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][25])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 006;}else{colorcarz[playerid][1] = 006;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][26])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 128;}else{colorcarz[playerid][1] = 128;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          } 
jakebat is offline   Reply With Quote
Old 03/02/2017, 01:43 PM   #1302
Gettopro
Big Clucker
 
Join Date: Oct 2011
Posts: 165
Reputation: 4
Default Re: Оптимизация кода

Quote:
Originally Posted by jakebat View Post
Возможно ли оптимизировать?
PHP Code:
    else if(playertextid == TDautosalon[playerid][15])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 175;}else{colorcarz[playerid][1] = 175;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
         else if(
playertextid == TDautosalon[playerid][16])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 1;}else{colorcarz[playerid][1] = 1;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][17])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 155;}else{colorcarz[playerid][1] = 155;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][18])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 111;}else{colorcarz[playerid][1] = 111;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][19])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 162;}else{colorcarz[playerid][1] = 162;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][20])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 0;}else{colorcarz[playerid][1] = 0;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][21])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 194;}else{colorcarz[playerid][1] = 194;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][22])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 187;}else{colorcarz[playerid][1] = 187;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][23])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 174;}else{colorcarz[playerid][1] = 174;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][24])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 136;}else{colorcarz[playerid][1] = 136;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][25])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 006;}else{colorcarz[playerid][1] = 006;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          }
        else if(
playertextid == TDautosalon[playerid][26])
         {
         if(
GetPVarInt(playerid,"color") != 1) {colorcarz[playerid][0] = 128;}else{colorcarz[playerid][1] = 128;}
         
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
        return 
true;
          } 
Писал с телефона, возможны небольшие неточности по коду:
PHP Code:
new const tstMsv[12] = {175,1,155,111,162,0,194,187,174,136,006,128};
for(new 
i;sizeof(tstMsv);i++){
    if(
playertextid != TDautosalon[playerid][i+15]) continue;
    
colorcarz[playerid][(GetPVarInt(playerid,"color") != 1)?0:1] = tstMsv[i];
    
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
    return 
true;

Gettopro is offline   Reply With Quote
Old 03/02/2017, 02:01 PM   #1303
jakebat
Big Clucker
 
Join Date: Aug 2013
Posts: 69
Reputation: 2
Default Re: Оптимизация кода

Quote:
Originally Posted by Gettopro View Post
Писал с телефона, возможны небольшие неточности по коду:
PHP Code:
new const tstMsv[12] = {175,1,155,111,162,0,194,187,174,136,006,128};
for(new 
i;sizeof(tstMsv);i++){
    if(
playertextid != TDautosalon[playerid][i+15] continue;
    
colorcarz[playerid][(GetPVarInt(playerid,"color") != 1)?0:1] = tstMsv[i];
    
ChangeVehicleColor(carsex[playerid], colorcarz[playerid][0], colorcarz[playerid][1]);
    return 
true;

Сделал почти так же, только немного по-другому и без тернарных.
Но, у тебя способ мне понравился. Спасибо.
jakebat is offline   Reply With Quote
Old 12/02/2017, 07:23 PM   #1304
jakebat
Big Clucker
 
Join Date: Aug 2013
Posts: 69
Reputation: 2
Default Re: Оптимизация кода

Как бы оптимизировать?
PHP Code:
if(strcmp(cmd"/giverank"true) == 0)
    {
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return    SCM(playeridCOLOR_WHITE"Введите: /giverank [id] [ранг]");
        new 
para1;
        new 
level;
        
para1 ReturnUser(tmp);
        
tmp strtok(cmdtextidx);
        
level strval(tmp);
        if(
PlayerInfo[playerid][pMember] == 1) { if(level 14 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 14!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 2) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 3) { if(level 15 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 15!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 4) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 5) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 6) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 7) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 5!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 10) { if(level 14 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 5!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 11) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 7!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 12) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 13) { if(level 10 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 10!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 14) { if(level 10 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 10!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 15) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 16) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 5!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 17) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 18) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 19) { if(level 15 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 15!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 21) { if(level 14 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 14!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 23) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 8!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 24) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 8!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 25) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 8!"); return true; } }
        
        if (
PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 12
        
||PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 13
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 4
        
||PlayerInfo[playerid][pMember] == 10 &&PlayerInfo[playerid][pRank] >= 14
        
||PlayerInfo[playerid][pMember] == 11 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 12 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 13 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 14 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 15 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 16 &&PlayerInfo[playerid][pRank] >= 5
        
||PlayerInfo[playerid][pMember] == 17 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 18 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 19 &&PlayerInfo[playerid][pRank] >= 12
        
||PlayerInfo[playerid][pMember] == 21 &&PlayerInfo[playerid][pRank] >= 12
        
||PlayerInfo[playerid][pMember] == 23 
        
|| PlayerInfo[playerid][pMember] == 24
        
|| PlayerInfo[playerid][pMember] == 25 )
        {
            if(!
IsPlayerConnected(para1)) return SCM(playeridCOLOR_GRAD1"Данный игрок не найден");
            if (
PlayerInfo[playerid][pMember] != PlayerInfo[para1][pMember]) return SCM(playeridCOLOR_GRAD1"Данный игрок не в вашей фракции!");
            if(
para1 == playerid) return SCM(playeridCOLOR_GREY"[Ошибка] Вы указали свой ID"); 
            if (
PlayerInfo[para1][pLeader] >= 1) return SCM(playeridCOLOR_GREY"[Ошибка] Вы указали ID лидера"); 
            if(
PlayerInfo[playerid][pMember] > && PlayerInfo[playerid][pRank] < level) return SCM(playerid,COLOR_GREY,"Ошибка");
            if(
PlayerInfo[playerid][pLeader] <= && PlayerInfo[playerid][pRank] <=  PlayerInfo[para1][pRank]) return SCM(playeridCOLOR_GREY"Ошибка");
            
PlayerInfo[para1][pRank] = level;
            
SendMes(para10x6BB3FFAA"Вас повысил/понизил до %d ранга %s",levelGN(playerid));
            
SendMes(playerid0x6BB3FFAA"Вы повысили %s до %d ранга."GN(para1),level);
        }
        else 
SCM(playeridCOLOR_GRAD1"Вы не можете повышать/понижах        return true;
    } 
jakebat is offline   Reply With Quote
Old 13/02/2017, 06:30 AM   #1305
stabker
High-roller
 
stabker's Avatar
 
Join Date: Mar 2012
Location: Andromeda Galaxy
Posts: 1,254
Reputation: 70
Default Re: Оптимизация кода

Quote:
Originally Posted by jakebat View Post
Как бы оптимизировать?
PHP Code:
if(strcmp(cmd"/giverank"true) == 0)
    {
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return    SCM(playeridCOLOR_WHITE"Введите: /giverank [id] [ранг]");
        new 
para1;
        new 
level;
        
para1 ReturnUser(tmp);
        
tmp strtok(cmdtextidx);
        
level strval(tmp);
        if(
PlayerInfo[playerid][pMember] == 1) { if(level 14 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 14!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 2) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 3) { if(level 15 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 15!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 4) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 5) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 6) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 7) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 5!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 10) { if(level 14 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 5!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 11) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 7!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 12) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 13) { if(level 10 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 10!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 14) { if(level 10 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 10!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 15) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 16) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 5!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 17) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 18) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 9!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 19) { if(level 15 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 15!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 21) { if(level 14 || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 14!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 23) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 8!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 24) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 8!"); return true; } }
        else if(
PlayerInfo[playerid][pMember] == 25) { if(level || level 1) { SCM(playeridCOLOR_GREY"Нельзя меньше 1 и больше 8!"); return true; } }
        
        if (
PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 12
        
||PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 13
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == &&PlayerInfo[playerid][pRank] >= 4
        
||PlayerInfo[playerid][pMember] == 10 &&PlayerInfo[playerid][pRank] >= 14
        
||PlayerInfo[playerid][pMember] == 11 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 12 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 13 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 14 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 15 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 16 &&PlayerInfo[playerid][pRank] >= 5
        
||PlayerInfo[playerid][pMember] == 17 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 18 &&PlayerInfo[playerid][pRank] >= 7
        
||PlayerInfo[playerid][pMember] == 19 &&PlayerInfo[playerid][pRank] >= 12
        
||PlayerInfo[playerid][pMember] == 21 &&PlayerInfo[playerid][pRank] >= 12
        
||PlayerInfo[playerid][pMember] == 23 
        
|| PlayerInfo[playerid][pMember] == 24
        
|| PlayerInfo[playerid][pMember] == 25 )
        {
            if(!
IsPlayerConnected(para1)) return SCM(playeridCOLOR_GRAD1"Данный игрок не найден");
            if (
PlayerInfo[playerid][pMember] != PlayerInfo[para1][pMember]) return SCM(playeridCOLOR_GRAD1"Данный игрок не в вашей фракции!");
            if(
para1 == playerid) return SCM(playeridCOLOR_GREY"[Ошибка] Вы указали свой ID"); 
            if (
PlayerInfo[para1][pLeader] >= 1) return SCM(playeridCOLOR_GREY"[Ошибка] Вы указали ID лидера"); 
            if(
PlayerInfo[playerid][pMember] > && PlayerInfo[playerid][pRank] < level) return SCM(playerid,COLOR_GREY,"Ошибка");
            if(
PlayerInfo[playerid][pLeader] <= && PlayerInfo[playerid][pRank] <=  PlayerInfo[para1][pRank]) return SCM(playeridCOLOR_GREY"Ошибка");
            
PlayerInfo[para1][pRank] = level;
            
SendMes(para10x6BB3FFAA"Вас повысил/понизил до %d ранга %s",levelGN(playerid));
            
SendMes(playerid0x6BB3FFAA"Вы повысили %s до %d ранга."GN(para1),level);
        }
        else 
SCM(playeridCOLOR_GRAD1"Вы не можете повышать/понижах        return true;
    } 
Создать массив, который будет хранить соответствующую инфу для каждой фракции (начиная с какого ранга можно повышать, количество рангов).
__________________
stabker is offline   Reply With Quote
Old 13/02/2017, 09:14 PM   #1306
jakebat
Big Clucker
 
Join Date: Aug 2013
Posts: 69
Reputation: 2
Default Re: Оптимизация кода

Quote:
Originally Posted by stabker View Post
Создать массив, который будет хранить соответствующую инфу для каждой фракции (начиная с какого ранга можно повышать, количество рангов).
Благодарю) Переделал и сократил до 19 строчек)
jakebat is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 10:28 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.