Page 1 of 1

team slot

Posted: 2011 Jul 26 00:25
by morka
Kaip supaprastinti toki koda?

Code: Select all

case 0..2:                            {                                if(iCTs <= 0)                                {                                    menu_additem(menu_team, "\wGo to the guards", "1", 0);                                } else                                 {                                    menu_additem(menu_team, "\dGo to the guards", "0", 1);                                }                            }                            case 3..4:                            {                                if(iCTs <= 1)                                {                                    menu_additem(menu_team, "\wGo to the guards", "1", 0);                                } else                                 {                                    menu_additem(menu_team, "\dGo to the guards", "0", 1);                                }                            }                            case 5..7:                            {                                if(iCTs <= 2)                                {                                    menu_additem(menu_team, "\wGo to the guards", "1", 0);                                } else                                 {                                    menu_additem(menu_team, "\dGo to the guards", "0", 1);                                }                            }                            case 8..10:                            {                                if(iCTs <= 3)                                {                                    menu_additem(menu_team, "\wGo to the guards", "1", 0);                                } else                                {                                    menu_additem(menu_team, "\dGo to the guards", "0", 1);                                }                            }                            case 11..18:                            {                                if(iCTs <= 4)                                {                                    menu_additem(menu_team, "\wGo to the guards", "1", 0);                                } else                                 {                                    menu_additem(menu_team, "\dGo to the guards", "0", 1);                                }                            }                            default:                            {                                 if(iCTs <= 6)                                {                                    menu_additem(menu_team, "\wGo to the guards", "1", 0);                                } else                                 {                                    menu_additem(menu_team, "\dGo to the guards", "0", 0);                                }                            }

Re: team slot

Posted: 2011 Jul 26 01:44
by hleV
Gali pašalint daxują skliaustų ({ ir }).

Code: Select all

if(iCTs <= 0){    menu_additem(menu_team, "\wGo to the guards", "1", 0);} else {    menu_additem(menu_team, "\dGo to the guards", "0", 1);}
->

Code: Select all

if(iCTs <= 0)    menu_additem(menu_team, "\wGo to the guards", "1", 0);else     menu_additem(menu_team, "\dGo to the guards", "0", 1);
Dėl optimizavimo tai čia viskas gerai pas tave. Aišku galėtum kešuot "\wGo to the guards" ir "\dGo to the guards" eilutes.

Re: team slot

Posted: 2011 Jul 26 19:23
by morka
Kada tuos kringerius {} naudot pvz

if()
{
veiksmas
veiksmas
}

if()
veiksmas

taip?

Re: team slot

Posted: 2011 Jul 26 20:05
by hleV
Taip.