AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Optimize this.. (https://forums.alliedmods.net/showthread.php?t=130711)

quelospario 06-26-2010 17:52

Optimize this..
 
PHP Code:

static nextclassLvl[33]
Lvl[id] = random_num(0200)

switch(
Lvl[id])
{
      case 
0..24nextclass 25-Lvl[id]
      case 
25..49nextclass 50-Lvl[id]
      case 
50..74nextclass 75-Lvl[id]
      case 
75..99nextclass 100-Lvl[id]
      case 
100.124nextclass 125-Lvl[id]
      case 
125..149nextclass 150-Lvl[id]
      case 
150..174nextclass 175-Lvl[id]
      case 
175..199nextclass 200-Lvl[id]
      default: 
nextclass 999
}
     
client_print(0print_chat,"NextLevelClass: %d"nextclass


Sylwester 06-26-2010 18:05

Re: Optimize this..
 
PHP Code:

static nextclassLvl[33]
Lvl[id] = random_num(0200)
nextclass 25-Lvl[id]%25
client_print
(0print_chat,"NextLevelClass: %d"nextclass


quelospario 06-26-2010 18:10

Re: Optimize this..
 
Quote:

Originally Posted by Sylwester (Post 1220806)
PHP Code:

static nextclassLvl[33]
Lvl[id] = random_num(0200)
nextclass 25-Lvl[id]%25
client_print
(0print_chat,"NextLevelClass: %d"nextclass


I love you.

RedRobster 06-26-2010 18:11

Re: Optimize this..
 
What does the percent sign do in
PHP Code:

25-Lvl[id]%25 

Thanks.

Sylwester 06-26-2010 18:13

Re: Optimize this..
 
modulo operator

wrecked_ 06-26-2010 18:13

Re: Optimize this..
 
Quote:

Originally Posted by RedRobster (Post 1220813)
What does the percent sign do in
PHP Code:

25-Lvl[id]%25 

Thanks.

Modulo. It returns the remainder.

30 % 25 = 5
100 % 100 = 0
5 % 3 = 2

RedRobster 06-26-2010 18:13

Re: Optimize this..
 
Thanks. :oops:


All times are GMT -4. The time now is 14:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.