GetTimer or GlobalTimer?
#1

Hello, Guys I'd like to ask you a question, which of this code is more optimized and faster?, Example code will be written below, I need your comments guys which of these techniques is much better and faster

pawn Код:
//This process will be repeated alot of time, (like 60 codes/function with this)
CMD:Hi(playerid, params[])
{
    new
        DelayTime[MAX_PLAYERS];

    if((gettime() - DelayTime[playerid]) < 60)
        return SendClientMessage(playerid, -1, "Please Wait.")

    DelayTime[playerid] = gettime();
    return 1;
}
Or

pawn Код:
//This process will be repeated alot of time, (like 60 codes/function with this
public OnGameModeInit();
{
    SetTimer("@GlobalTimer", 1000, true);
    return 1;
}

//Global Variable
new
    DelayTime[MAX_PLAYERS];

CMD:hi(playerid, params[])
{
    if(DelayTime[playerid] >= 1)
        return SendClientMessage(playerid, -1, "Please Wait.")

    DelayTime[playerid] = 60;
    return 1;
}

forward @GlobalTimer(); public @GlobalTimer()
{
    if(DelayTime[playerid] >= 1)
        return DelayTime[playerid] --;
    if(DelayTime[playerid]) <= 1)
        return DelayTime[playerid] =0;
    return 1;
}
Just wanted to know which method is much faster.
Reply
#2

The first one but you won't feel a difference.
Reply
#3

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
The first one but you won't feel a difference.

Alright, It won't cause lag or something if used more than 60 times? I'm just confirming because one time I used [b]too much GetTickCount lags my server
Reply
#4

It doesn't matter, both are good.
Reply
#5

Always avoid timers whenever possible.
Reply
#6

60 times a what? Its a normal native function which runs at c++ speed
Reply
#7

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Always avoid timers whenever possible.
Thanks, so you're saying that I should use gettime(), instead of a timer.
Reply
#8

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Thanks, so you're saying that I should use gettime(), instead of a timer.
Yeah right thats what he's sayin
Reply
#9

Yeah, don't use timers for this kind of things.. also, what's with people using "@" in their functions? Looks pretty daem ugly imo
Reply
#10

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
60 times a what? Its a normal native function which runs at c++ speed
I mean like I'll use this method more or less than 60 times.

Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
Yeah, don't use timers for this kind of things.. also, what's with people using "@" in their functions? Looks pretty daem ugly imo
It's a style
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)