The function took 5325ms to execute?
#1




pawn Код:
public SyncUp()
{
    SyncTime();
    AranjareCeas();
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {

        if(UsedFind[i] >= 1)
        {
            UsedFind[i] += 1;
            if(UsedFind[i] >= 2)
            {
                UsedFind[i] = 0;
            }
        }
        if(IsPlayerConnected(i))
        {
            if(CellTime[i] > 0)
            {
                if (CellTime[i] == cchargetime)
                {
                    CellTime[i] = 1;
                    if(Mobile[Mobile[i]] == i)
                    {
                        CallCost[i] = CallCost[i]+callcost;
                    }
                }
                CellTime[i] = CellTime[i] +1;
                if (Mobile[Mobile[i]] == -1 && CellTime[i] == 5)
                {
                    if(IsPlayerConnected(Mobile[i]))
                    {
                        new string[456];
                        new called[MAX_PLAYER_NAME];
                        GetPlayerName(Mobile[i], called, sizeof(called));
                        format(string, sizeof(string), "* %s's phone rings in his pocket.", called);
                        SendClientMessage(Mobile[i], COLOR_PURPLE, string);
                        SetPlayerChatBubble(Mobile[i], string,COLOR_PURPLE, 10.0, strlen(string)*200);
                    }
                }
            }
        }
        if(FindTime[i] > 0)
        {
            if(FindTime[i] == FindTimePoints[i]) { FindTime[i] = 0; FindTimePoints[i] = 0; FindingID[i] = 0; DisablePlayerCheckpointEx(i,3); PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0); GameTextForPlayer(i, "~r~RedMarker gone", 2500, 1); }
            else
            {
                new string[456];
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(FindingID[i], X,Y,Z);
                SetPlayerCheckpointEx(i, 3, X,Y,Z, 1);
                format(string, sizeof(string), "finding..", FindTimePoints[i] - FindTime[i]);
                GameTextForPlayer(i, string, 1500, 6);
                FindTime[i] += 1;
            }
        }
        DashCam(i);
    }
    for(new i = 0; i < sVehicles + 1; i++)
    {
        new Float:x,Float:y,Float:z;
        new masina = VehicleInfo[i][vVeh];
        GetVehiclePos(masina ,x,y,z);
        if(x != OldVehicleKM[masina][0] && y != OldVehicleKM[masina][1])
        {
            GetVehiclePos(masina, OldVehicleKM[masina][0], OldVehicleKM[masina][1], OldVehicleKM[masina][2]);
            VehicleInfo[i][vKM] += 1;
        }

    }
}
dashcam:

pawn Код:
function DashCam(playerid)
{
    if(PlayerInfo[playerid][pMember] == 1)
    {
        if(DashCamEnabled[playerid] == 1)
        {
            new id = GetVehicleInfrontID(GetPlayerVehicleID(playerid))
            if(!IsACopCar(id))
            {
                if(Motor[GetPlayerVehicleID(playerid)] != 0) { DashCamEnabled[playerid] = 0 , SendClientMessage(playerid, COLOR_LIGHTRED, " Radar disabled because you started the engine."); return 1; }
                new string[300];
                new Float: velocityX, Float: velocityY, Float: velocityZ;
                GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
                new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 120.666667, floatround_round);
                if(speed > DashSpeed[playerid])
                {
                    PlayerPlaySound(playerid,21000,0,0,0);
                    format(string, sizeof(string), "~R~%d",speed);
                    GameTextForPlayer(playerid, string, 1000, 3);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        if(IsPlayerInVehicle(i, id) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
                        {

                            PlayerPlaySound(i,21000,0,0,0);
                            if(GetPlayerMoney(i) < DashPrice[playerid])
                            {
                                format(string,sizeof(string), " Ai acordat wanted jucгtorului %s pentru neplгtirea amenzii de viteze.", GetName(i));
                                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                                SetPlayerCriminalEx(i,playerid,"neplгtirea amenzii de vitezг", 1);
                            }
                            else
                            {
                                format(string,sizeof(string), " Ai acordat o amendг de vitezг jucгtorului %s (%s$)", GetName(i), FormatMoney(DashPrice[playerid]));
                                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                                format(string,sizeof(string), " Ai primit o amendг de vitezг de la politistul %s (%s$ - %d km/h)", GetName(playerid), FormatMoney(DashPrice[playerid]), speed);
                                SendClientMessage(i, COLOR_LIGHTRED, string);
                                SafeGivePlayerMoney(playerid, DashPrice[playerid]);
                                SafeGivePlayerMoney(i, - DashPrice[playerid]);
                            }


                        }
                    }
           
                }
            }
        }
    }
    return 1;

}
Reply
#2

You have 3 loops. Optimize your script wtf is this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)