Is this function optimized?
#1

Hi, I want to know if there's a way to optimize this function:

PHP код:
stock AdminRank(playerid)
{
    new 
rank[40];
    switch(
PlayerInfo[playerid][pAdmin])
    {
        case 
0rank "Nothing";
        case 
1rank "{FFFF28}[Temp admin]";
        case 
2rank "{660066}[Junior Admin]";
        case 
3rank "{FF8000}[Senior Admin]";
        case 
4rank "{2F5E35}[Head Admin]";
        case 
5rank "{00FFFF}[Global Admin]";
        case 
6rank "{80FF00}[Community Manager]";
        case 
7rank "{80FF00}[Server Owner]";
    }
    return 
rank;

Thanks for replying.
Reply
#2

new rank[29]; would be enough, and i clearly see that its optimized
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
an array might be more effective.
pawn Код:
static const gAdminRanks[][] = {
    "None", // 0
    "Moderator", // 1
    "Junior", // 2
    "Senior" // 3
};

format(msg, sizeof(msg), "Player %d's admin level is: %s", targetid, gAdminRanks[PlayerInfo[targetid][pAdmin]]);
Dis.
Reply
#4

is this optimized?:

printf("%d",1+1);
Reply
#5

Quote:
Originally Posted by Ihateyou
Посмотреть сообщение
is this optimized?:

printf("%d",1+1);
Make the calculations and store the result in another variable, then print that variable.
Reply
#6

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Dis.
I wouldn't say that is any way, you don't see me using that function to retrieve dynamic faction ranks. So if it works it works at the end of the day, and if it doesn't exceed the required string length (the return string) then yeah its optimized enough for its purpose. (FYI: i know this is the internet but considering using real words).

Quote:
Originally Posted by Ihateyou
Посмотреть сообщение
is this optimized?:

printf("%d",1+1);
I don't know if you're asking a serious question but by the looks of it you're not (Make you're own thread if you're going to troll, look forward to getting banned if they feel like doing it.)
Reply
#7

Quote:
Originally Posted by zT KiNgKoNg
Посмотреть сообщение
I wouldn't say that is any way, you don't see me using that function to retrieve dynamic faction ranks. So if it works it works at the end of the day, and if it doesn't exceed the required string length (the return string) then yeah its optimized enough for its purpose. (FYI: i know this is the internet but considering using real words).




I don't know if you're asking a serious question but by the looks of it you're not (Make you're own thread if you're going to troll, look forward to getting banned if they feel like doing it.)
just making fun of retards creating threads like this .. learn 2 sarcasm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)