AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Any way to optimise this? (https://forums.alliedmods.net/showthread.php?t=210614)

Podarok 03-12-2013 16:16

Any way to optimise this?
 
Hey guys. So i have a code, first of all, i get the champions name, then check whether a user has this champion and apply some privileges to him. It looks like this :
Code:
new champions_name[64]; new cclass = get_champion(id) get_class_name(cclass, champions_name, 63) // Then i do tonns of checks if (equali(champions_name, "Podarok") //bla bla bla
I do like 15-20 checks- it works fine , but im pretty sure there must be a way in optimising this code.

YamiKaitou 03-12-2013 16:18

Re: Any way to optimise this?
 
With the output you gave alone, it is fine

Podarok 03-12-2013 16:20

Re: Any way to optimise this?
 
Okay. Thanks. Nothing then.

EDUTz 03-12-2013 17:53

Re: Any way to optimise this?
 
you could always use switch(champions_name), just saying.

YamiKaitou 03-12-2013 17:57

Re: Any way to optimise this?
 
Quote:

Originally Posted by EDUTz (Post 1911556)
you could always use switch(champions_name), just saying.

A switch doesn't work on an array

EDUTz 03-12-2013 18:00

Re: Any way to optimise this?
 
crap, i haven't read it all. based on what he posted, he could switch(cclass) but i don't know how he used it.

fysiks 03-12-2013 19:49

Re: Any way to optimise this?
 
Quote:

Originally Posted by EDUTz (Post 1911560)
he could switch(cclass) but i don't know how he used it.

That won't help either.

EDUTz 03-12-2013 20:37

Re: Any way to optimise this?
 
Quote:

Originally Posted by fysiks (Post 1911616)
That won't help either.

wrong, it would help.

switch(cclass)
{
case CLASS_IDIOT:

as i said, i don't know what he did there, but just assuming he just did a new class for war3ft, he won't need it.

YamiKaitou 03-12-2013 21:35

Re: Any way to optimise this?
 
He asked how to optimize the code he posted. Not to assume the rest of the code and optimize that. For all we know, he is already using a switch on cclass.

Backstabnoob 03-13-2013 08:07

Re: Any way to optimise this?
 
Quote:

I do like 15-20 checks
I take this as he's copy pasting equali 15-20 times, which is horrible, considering, as EDUTz said, he can just switch through the class ID.


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

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