Question about which is faster and less cpu usage?
#1

Hello guys today im going to ask you which method is better and faster? or maybe less CPU Usage

First Method
pawn Код:
new CuffTime[MAX_PLAYERS];
public OnFilterScriptInit()
{
    SetTimer("CuffTimer",1000,1);
    return 1;
}

CMD:cuff(playerid, params[])
{
    //All Cuff Code here!
    //cuf my own self and will be auto uncuffed in 25 seconds
    CuffTime[playerid] =25;
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
    TogglePlayerControllable(playerid, 0);
    return 1;
}

forward CuffTimer()
public CuffTimer()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(CuffTime[i] > 1)
        {
            CuffTime[i] --;
        }
        if(CuffTime[i] == 1)
        {  
            //All Auto-Uncuff code here!
            CuffTime[i] =0;
            SetPlayerSpecialAction(i, SPECIAL_ACTION_NONE);
            TogglePlayerControllable(i, 1);
        }
    }
    return 1;
}
OR

2nd Method
pawn Код:
new IsCuffed[MAX_PLAYERS];
public OnFilterScriptInit()
{
    return 1;
}

CMD:cuff(playerid, params[])
{
    //All Cuff Code here!
    //cuf my own self and will be auto uncuffed in 25 seconds
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
    TogglePlayerControllable(playerid, 0);
    SetTimerEx( "CuffTimer", 25000, false,"i", playerid);
    IsCuffed[playerid] =1;
    return 1;
}

forward CuffTimer(playerid)
public CuffTimer(playerid)
{  
    //When Auto-Uncuffed get called
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
    TogglePlayerControllable(playerid, 1);
    IsCuffed[playerid] =0;
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 7 Guest(s)