26.10.2013, 20:24
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
Or
Just wanted to know which method is much 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;
}
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;
}