[Ajuda] Servidor travando
#1

Bom, a situaзгo й a seguinte:
Eu tф com um gamemode aqui, que ele estб mais que livre de bugs em um geral, sу que possui um bug fatal, que compromete a jogabilidade.
A cada hora, no servidor, aparece uma mensagem informando o horбrio. Por exemplo, quando for 21:00, irб aparecer uma mensagem.
"Agora sгo 21:00 horas."
E quando isso acontece, o servidor simplesmente trava, por dois minutos. Trava no quesito servidor, como se a conexгo tivesse caнdo.
O mesmo acontece quando algum jogador crasha, desloga, й banido e й kickado.
Eu jб tentei buscar ajuda, jб tentei corrigir o bug de todas as maneiras possнveis, porйm, sem sucesso.
Procuro uma ajuda de alguйm daqui, valeu.
Reply
#2

Pesquise no seu GameMode a frase "Agora sгo ", e poste aqui as linhas que vкm antes e depois para que possamos ver o cуdigo que vem antes e depois de quando ocorre esse momento de mostrar as horas.
Reply
#3

Procure (Ctrl + F) em seus scripts "Agora sгo " e poste o cуdigo.
Reply
#4

http://pastebin.com/DkeXwWZv#
Ele й grande, em si.
Код:
public OneMinTimer()
{
    new string[128],tmphour,tmpminute,tmpsecond,year,month,day,mtext[50];
    gettime(tmphour, tmpminute, tmpsecond);
    getdate(year, month, day);
        FixHour(tmphour);
        tmphour = shifthour;
        if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
        {
            SetWorldTime(tmphour);
            ghour = tmphour;
            format(string, sizeof(string), "Agora sгo %d:00.",tmphour);
                SendClientMessageToAll(COLOR_WHITE,string);
                if(day > gday)
                {
                    switch(month)
                    {
                            case 1: mtext = "Janeiro";
                            case 2: mtext = "Fevereiro";
                            case 3: mtext = "Marзo";
                            case 4: mtext = "Abril";
                            case 5: mtext = "Maio";
                            case 6: mtext = "Junho";
                            case 7: mtext = "Julho";
                            case 8: mtext = "Agosto";
                            case 9: mtext = "Setembro";
                            case 10: mtext = "Outubro";
                            case 11: mtext = "Novembro";
                    case 12: mtext = "Dezembro";
                    }
                    gday=day;
                    format(string, sizeof(string), "Hoje й %s-%d-%d.", mtext,gday,year);
                    SendClientMessageToAll(COLOR_WHITE,string);
                }
                for(new i = 0; i < sizeof(CarInfo); i++)
                {
                    if(CarInfo[i][cOwned] == 1)
                    {
                        if(CarInfo[i][cDelay] > 0)
                        {
                                    CarInfo[i][cDelay]--;
                                }
                    if(IsPlayerUsingCar(i)) // Check if anyone is online that has a key to the car.
                    {
                        if(CarInfo[i][cTime] > 0) { CarInfo[i][cTime]=0; }
                    }
                    else
                    {
                        CarInfo[i][cTime]++;
                        if(CarInfo[i][cTime] >= 730) // Auto-Sell Car System
                        {
                                                if(CarInfo[i][cDonate] == 0)
                                                {
                                                    format(string, sizeof(string), "users/%s.ini", CarInfo[i][cOwner]);
                                            if(DOF2_FileExists(string))
                                            {
                                            if(i == DOF2_GetInt(string, "CarKey1")) DOF2_SetInt(string, "CarKey1", SCRIPT_CARS);
                                            else if(i == DOF2_GetInt(string, "CarKey2")) DOF2_SetInt(string, "CarKey2", SCRIPT_CARS);
                                            else if(i == DOF2_GetInt(string, "CarKey3")) DOF2_SetInt(string, "CarKey3", SCRIPT_CARS);
                                            DOF2_WriteFile();
                                            }
                                    format(string, sizeof(string), "O veнculo %d foi automaticamente vendido por estar inativo hб %d horas.", i, CarInfo[i][cTime]);
                                            SellLog(string);
                                            CarInfo[i][cOwned]=0;
                                                        CarInfo[i][cImpound]=0;
                                            CarInfo[i][cTime]=0;
                                                }
                        }
                    }
                }
                }
        for(new f = 0; f < sizeof(FactionInfo); f++) { FactionInfo[f][fLimit]=0; }
        SaveBizz();
                SaveProperty();
        SaveCars();
        SaveCars2();
        SaveFactions();
        SaveInts();
        new weather = random(16)+1;
            switch(weather)
            {
                case 0,1: Weather=1;
                    case 2: Weather=2;
                    case 3: Weather=3;
                    case 4: Weather=4;
                    case 5: Weather=5;
                    case 6: Weather=6;
                    case 7,8,9: Weather=7;
                    case 10: Weather=10;
                    case 11: Weather=11;
                    case 12: Weather=12;
                    case 13: Weather=13;
                    case 14: Weather=18;
                    case 15: Weather=8;
                    case 16: Weather=9;
            }
        SetWeather(Weather);
        switch(tmphour)
        {
                    case 0 .. 5, 21 .. 30:
                    {
                        for(new c = 0; c < MAX_VEHICLES; c++)
                        {
                                    if(VehicleInfo[c][vLights] == 1)
                                    {
                        CarLights(c,1);
                                }
                            }
                        }
        }
        }
        for(new weed = 0; weed < sizeof(WeedInfo); weed++)
    {
        if(WeedInfo[weed][wPlanted] == 1 && WeedInfo[weed][wTime] > 0)
        {
            WeedInfo[weed][wTime]--;
        }
        }
        for(new h = 0; h < sizeof(HouseInfo); h++)
        {
            if(HouseInfo[h][hSmoke] > 0)
            {
                HouseInfo[h][hSmoke]--;
                if(HouseInfo[h][hSmoke] == 0)
                {
                    DestroyDynamicObject(HouseInfo[h][hSmokeO][0]);
                    DestroyDynamicObject(HouseInfo[h][hSmokeO][1]);
                    DestroyDynamicObject(HouseInfo[h][hSmokeO][2]);
                    DestroyDynamicObject(HouseInfo[h][hSmokeO][3]);
                    DestroyDynamicObject(HouseInfo[h][hSmokeO][4]);
                    DestroyDynamicObject(HouseInfo[h][hSmokeO][5]);
                }
            }
        }
        for(new fi=0;fi<sizeof(FDInfo);fi++)
    {
        if(FDInfo[fi][fObject] == 0)
        {
            FDInfo[fi][fTime]--;
            if(FDInfo[fi][fTime] == 0)
            {
                DestroyDynamicObject(FDInfo[fi][fObject]);
                                FDInfo[fi][fObject]=0;
                        FDInfo[fi][fdX]=0.0;
                        FDInfo[fi][fdY]=0.0;
                        FDInfo[fi][fdZ]=0.0;
                        FDInfo[fi][fWorld]=0;
                        FDInfo[fi][fInt]=0;
                        FDInfo[fi][fTime]=0;
                        FDInfo[fi][fHealth]=0;
            }
        }
    }
        for(new v = 0; v < MAX_VEHICLES; v++)
        {
            if(VehicleInfo[v][vEngine] == 1
            && VehicleInfo[v][vType] != 3
            && VehicleInfo[v][vType] != 8
                && VehicleInfo[v][vType] != 9
                && VehicleInfo[v][vType] != 10
                && VehicleInfo[v][vType] != 11
                && VehicleInfo[v][vType] != 14
                && VehicleInfo[v][vType] != 16)
                {
                    if(VehicleInfo[v][vFuel] > 0)
                    {
                                switch(GetVehicleModel(v))
                                {
                                    case 400, 408, 413, 422, 440, 459, 470, 478, 482, 489, 495, 500, 505, 522, 531, 543, 552, 554, 579, 582, 605:
                                    {
                                            VehicleInfo[v][vFuel]-=2;
                                        }
                                        case 414, 455, 456, 498, 499, 524, 578, 609:
                                        {
                                            VehicleInfo[v][vFuel]-=3;
                                        }
                                        case 403, 443, 514, 515:
                                        {
                                            VehicleInfo[v][vFuel]-=4;
                                        }
                                    default:
                                    {
                                            VehicleInfo[v][vFuel]-=1;
                                        }
                                }
                    }
            }
            if(VehicleInfo[v][vWireTime] > 0)
                {
                    VehicleInfo[v][vWireTime]--;
            }
            if(VehicleInfo[v][vTDelay] > 0)
                {
                    VehicleInfo[v][vTDelay]--;
            }
        }
        foreach (Player,i)
        {
            SetPVarInt(i, "Hunger", GetPVarInt(i, "Hunger")+1);
            SetPVarInt(i, "PayDay", 1+GetPVarInt(i, "PayDay"));
        if(GetPVarInt(i, "Hunger") >= 5 && GetPVarInt(i, "Control") == 0
                && GetPVarInt(i, "Dead") == 0 && GetPVarInt(i, "Cuffed") == 0
                && GetPVarInt(i, "Jailed") == 0)
            {
                SetPVarInt(i, "Hunger", 0);
                new Float:health;
                GetPlayerHealth(i,health);
                if(health >= 11.0) { SetPlayerHealthEx(i,health-1.0); }
            }
            if(GetPVarInt(i, "Wound") == 1 && GetPVarInt(i, "Dead") == 0
                && GetPVarInt(i, "Cuffed") == 0 && GetPVarInt(i, "Jailed") == 0)
            {
                new Float:health;
                GetPlayerHealth(i,health);
                SetPlayerHealthEx(i,health-15.0);
               
                TextDrawShowForPlayer(i,WoundDraw[0]);
                        TextDrawShowForPlayer(i,WoundDraw[1]);
                        SetTimerEx("HideMsgDraw", 5000, false, "ii", i, 1);
            }
            if(GetPVarInt(i, "JobTime") > 0)
            {
                SetPVarInt(i,"JobTime",GetPVarInt(i, "JobTime")-1);
            }
                if(GetPVarInt(i, "DrugTime") == 0) { SetPlayerTime(i, tmphour, tmpminute); }
                PayDay(i);
        }
        if(GetPlayerVehicleID(IsBot("BusDriver")) != BotBus)
        {
        RemovePlayerFromVehicle(IsBot("BusDriver"));
                PutPlayerInVehicleEx(IsBot("BusDriver"),BotBus,0);
        }
        if(GetPlayerVehicleID(IsBot("BusDriver2")) != BotBus2)
        {
        RemovePlayerFromVehicle(IsBot("BusDriver2"));
                PutPlayerInVehicleEx(IsBot("BusDriver2"),BotBus2,0);
        }
        if(GetPlayerVehicleID(IsBot("Trainbot")) != BotTrain)
        {
            RemovePlayerFromVehicle(IsBot("Trainbot"));
            PutPlayerInVehicleEx(IsBot("Trainbot"),BotTrain,0);
        }
        if(GetPlayerVehicleID(IsBot("airplanebot")) != BotPlane)
        {
            RemovePlayerFromVehicle(IsBot("airplanebot"));
            PutPlayerInVehicleEx(IsBot("airplanebot"),BotPlane,0);
        }
        for(new i = 0; i < sizeof(FireInfo); i++)
        {
                if(FireInfo[i][fTime] > 0)
                {
                    FireInfo[i][fTime]--;
                    if(FireInfo[i][fTime] == 0)
                    {
                        DestroyDynamicObject(FireInfo[i][fObject][0]);
                        DestroyDynamicObject(FireInfo[i][fObject][1]);
                        FireInfo[i][fiX]=0.0;
                        FireInfo[i][fiY]=0.0;
                        FireInfo[i][fiZ]=0.0;
                        strmid(FireInfo[i][fName], "None", 0, strlen("None"), 255);
                    }
                }
        }
        for(new h= 0; h < sizeof(ParkMeter); h++)
        {
            if(ParkMetCash[h] > 0)
                {
                    ParkMetCash[h]--;
                    format(string, sizeof(string),"%d Minutos",ParkMetCash[h]);
                UpdateDynamic3DTextLabelText(ParkMetID[h], 0xFFFFFFFF, string);
                }
        }
        return 1;
}
Reply
#5

Код:
SaveBizz();
SaveProperty();
SaveCars();
SaveCars2();
SaveFactions();
SaveInts();
tira isso aqui nao tem necessidade de salvar toda hora pode ser isso que esta causando o travamento teste ai
Reply
#6

Quote:
Originally Posted by SkilL_Fly
Посмотреть сообщение
Код:
SaveBizz();
SaveProperty();
SaveCars();
SaveCars2();
SaveFactions();
SaveInts();
tira isso aqui nao tem necessidade de salvar toda hora pode ser isso que esta causando o travamento teste ai
Na verdade, eu salvaria a cada modificaзгo de variбvel da empresa pelo fato do SA:MP ser muito instбvel e crashar sem motivos (na verdade tem, mas sгo imprevisнveis)

Dependendo do tanto de informaзгo salva nгo congelaria seu servidor por todo esse tempo, mas vocк tambйm estб usando muitos e muitos loops de uma vez, que com certeza causa um congelamento por algum tempo. Tente evitar uma sequencia de cуdigos muito grandes pois sгo esses que congelam seu servidor e cuidado com loops muito grande pois eles tambйm causam esse congelamento.
Reply
#7

Quote:
Originally Posted by Dr_Pawno
Посмотреть сообщение
Na verdade, eu salvaria a cada modificaзгo de variбvel da empresa pelo fato do SA:MP ser muito instбvel e crashar sem motivos (na verdade tem, mas sгo imprevisнveis)
Acho isso um bocado bizarro. Se crasha й porque muito provavelmente algo estб mal no seu script ou nos seus plugins. Vocк usa o plugin CrashDetect?
Reply
#8

Quote:
Originally Posted by SkilL_Fly
Посмотреть сообщение
Код:
SaveBizz();
SaveProperty();
SaveCars();
SaveCars2();
SaveFactions();
SaveInts();
tira isso aqui nao tem necessidade de salvar toda hora pode ser isso que esta causando o travamento teste ai
deu totalmente certo
so q eu tenho uma duvida agora, tipo, tem em outros comandos isso tlgd, e trava do msm jeito
eu posso tirar isso dos outros comandos? vai continuar salvando as contas e essas coisas?
Reply
#9

Quote:
Originally Posted by Baldinho
Посмотреть сообщение
deu totalmente certo
so q eu tenho uma duvida agora, tipo, tem em outros comandos isso tlgd, e trava do msm jeito
eu posso tirar isso dos outros comandos? vai continuar salvando as contas e essas coisas?
evita coloca muitos save junto coloca quando servidor desligar ou o player sair sу nгo tem tanta necessidade de salvar sempre sempre
Reply
#10

O ideal й vocк fazer o save de tal modificaзгo no momento em que houver a alteraзгo, ou seja, cria uma public geral como Property_Save(pid) nela vocк poe pra salvar as variбveis todas do pid que for requisitado. Eu faзo assim e atй agora nгo me deu problema, olhe que estou fazendo isso a quase 1 ano e geralmente com instabilidades no host e ataques nunca ocasionou problemas.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)