Server freeze / Crash
#1

Okay, here is where it freezes:



What causes it is this:

OnGameModeInit(); No problem
pawn Код:
public OnGameModeInit()
{
    SetGameModeText("SF-RP v0.1b");
    AddPlayerClass(1,-2289.6543,211.1139,35.3125, 0,0,0,0,0,0,0);
    new Hour, Minute, Second;
    gettime(Hour, Minute, Second);
    SetWorldTime(Hour);
   
    mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    mysql_debug(1);
   
    DisableInteriorEnterExits();
    loadarrowpickups();
    loadmaps();
    loadbusiness();
    loadhouses();
    SetTimer("MoneyTimer", 1000, 1);
    return 1;

}
Here is the "loadbusiness" stock, which contains a stock which crashes it.
pawn Код:
stock loadbusiness()
{
    for(new i=0; i<MAX_BUSINESSES; i++)
    {
        currbusiness += 1;
        LoadBusinessInfo(i); // When this is commented out, there is no crash
        CreatePickup(1272, 1, BVar[i][bpickupx], BVar[i][bpickupy], BVar[i][bpickupz], 0);
    }
    print("Buinesses Loaded");
}
This is the "LoadBusinessInfo" stock, which is what ultimately crashes the server.
pawn Код:
stock LoadBusinessInfo(iBusiness)
{
    new Query[700];
    mysql_query("SELECT * FROM businessinfo");
    while(mysql_fetch_row(Query))
    {
        sscanf(Query, "e<p<|>dfffs[28]s[24]dddddfff>", BVar[iBusiness][bid], BVar[iBusiness][bpickupx], BVar[iBusiness][bpickupy], BVar[iBusiness][bpickupz], BVar[iBusiness][bname],
        BVar[iBusiness][bowner], BVar[iBusiness][bprice], BVar[iBusiness][bpayout], BVar[iBusiness][blocked], BVar[iBusiness][benterable], BVar[iBusiness][binterior],
        BVar[iBusiness][bintx], BVar[iBusiness][binty], BVar[iBusiness][bintz], BVar[iBusiness][bInt]);
    }
    mysql_free_result();
    return 1;
}
Any ideas what I am doing wrong?
Reply
#2

Try the function below:

pawn Код:
stock LoadBusinessInfo(iBusiness)
{
    new Query[700];
    format(Query, 128, "SELECT * FROM businessinfo WHERE `business_id_field_name` = '%d'", iBusiness);
    mysql_query(Query);
    mysql_store_result();
    while(mysql_fetch_row(Query))
    {
        sscanf(Query, "p<|>e<dfffs[28]s[24]dddddfff>", BVar[iBusiness]);
    }
    mysql_free_result();
    return 1;
}
Reply
#3

Same result:

Reply
#4

How about update your plugins ?
Reply
#5

Changed business_id_field_name to your field name?
Reply
#6

Quote:
Originally Posted by Pedro_Miranda
Посмотреть сообщение
Changed business_id_field_name to your field name?
Yeah, still freezes at the same spot..

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
How about update your plugins ?
They are up to date..
Reply
#7

Try these

Код:
stock loadbusiness()
{
    new businessCount = LoadBusinessInfo();
    for(new i=0; i<businessCount; i++)
    {
        currbusiness += 1;
        CreatePickup(1272, 1, BVar[i][bpickupx], BVar[i][bpickupy], BVar[i][bpickupz], 0);
    }
    print("Buinesses Loaded");
}

stock LoadBusinessInfo()
{
    new Query[700];
    mysql_query("SELECT * FROM businessinfo");
	new i = 0;
    while(mysql_fetch_row(Query))
    {
        sscanf(Query, "e<p<|>dfffs[28]s[24]dddddfff>", BVar[i][bid], BVar[i][bpickupx], BVar[i][bpickupy], BVar[i][bpickupz], BVar[i][bname],
        BVar[i][bowner], BVar[i][bprice], BVar[i][bpayout], BVar[i][blocked], BVar[i][benterable], BVar[i][binterior],
        BVar[i][bintx], BVar[i][binty], BVar[i][bintz], BVar[i][bInt]);
		i++;
    }
    mysql_free_result();
    return --i;
}
Edit: if that doesn't work, substitute using the sscanf parameters that Pedro_Miranda provided:
Код:
stock LoadBusinessInfo()
{
    new Query[700];
    mysql_query("SELECT * FROM businessinfo");
    new i = 0;
    while(mysql_fetch_row(Query))
    {
        sscanf(Query, "p<|>e<dfffs[28]s[24]dddddfff>", BVar[i]);
	i++;
    }
    mysql_free_result();
    return --i;
}
Reply
#8

Okay, that works but it now interferes with the Login / Register script. Even if the account is registered it says that it is not and makes a new entry. I have put in the code you have said above, this is my Register / Login dialogue.

pawn Код:
stock InitConnection(playerid)
{
    new
        Query[90],
        EscName[MAX_PLAYER_NAME];

    mysql_real_escape_string(pName(playerid), EscName);

    format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `username` = '%s'", EscName);
    mysql_query(Query);
    mysql_store_result();

    if(mysql_num_rows() != 0)
    {
        format(Msg, sizeof(Msg), "Please enter your password below to log onto your account\n", pName(playerid), playerid);
        DialogPassword(playerid, LOGIN, "Account Login", Msg, "Login", "Leave");
    }
    else
    {
        format(Msg, sizeof(Msg), "This account is not registered, please enter a password below to continue\n", pName(playerid), playerid);
        DialogPassword(playerid, REGISTER, "Account Registration", Msg, "Register", "Leave");
    }
    mysql_free_result();
}
I cannot find where it conflicts either.
Reply
#9

Quote:
Originally Posted by vIBIENNYx
Посмотреть сообщение
Okay, that works but it now interferes with the Login / Register script. Even if the account is registered it says that it is not and makes a new entry. I have put in the code you have said above, this is my Register / Login dialogue.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
       
        case REGISTER:
        {
            if(!response)
            {
                //format(Msg, sizeof(Msg), ""#CBLUE"Player: "#CORANGE"%s(%d) "#CBLUE"has been kicked - Reason: Not registering!", pName(playerid), playerid);
                //SendClientMessageToAll(COLOR_GREY, Msg);
                Kick(playerid);
            }
            else
            {
                if(!strlen(inputtext)) DialogPassword(playerid, REGISTER, "Account Registration", "You must enter a password below to continue", "Register", "Leave");

                new
                    Query[100],
                    EscPass[30],
                    EscName[MAX_PLAYER_NAME];

                mysql_real_escape_string(pName(playerid), EscName);
                mysql_real_escape_string(inputtext, EscPass);

                format(Query, sizeof(Query), "INSERT INTO `playerinfo` (`username`, `ppassword`) VALUES ('%s', md5('%s'))", EscName, EscPass);
                mysql_query(Query);

                // Player has registered

                SendClientMessage(playerid, 0xFFFFFFFF, "You are now registered!");
                StopAudioStreamForPlayer(playerid);
                SpawnPlayer(playerid);
                GivePlayerCash(playerid, 500);
                SavePVar(playerid);
                loggedin[playerid] = 1;
                TogglePlayerControllable(playerid, 1);
               
            }
        }
        case LOGIN:
        {
            if(!response)
            {
                Kick(playerid);
            }
            else
            {
                if(!strlen(inputtext)) DialogPassword(playerid, LOGIN, "Account Login", "You must enter a password below to continue\n", "Login", "Leave");

                new
                    EscPass[38],
                    Query[128];

                mysql_real_escape_string(inputtext, EscPass);

                format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `username` = '%s' AND `ppassword` = md5('%s')", pName(playerid), EscPass);

                mysql_query(Query);
                mysql_store_result();

                if(mysql_num_rows() > 0)
                {
                    LoadPlayerInfo(playerid);
                    // Player Has logged in

                    SendClientMessage(playerid, 0xFFFFFFFF, "You have logged in successfully");
                    SpawnPlayer(playerid);
                    if(PVar[playerid][currclothes] > 1)
                    {
                        SetPlayerSkin(playerid, PVar[playerid][currclothes]);
                    }
                    else
                    {
                        SetPlayerSkin(playerid, 1);
                    }
                    new str[128];

                    TogglePlayerControllable(playerid, 1);
                    SetPlayerScore(playerid, PVar[playerid][level]);
                    format(str,sizeof(str),"%s | Admin Level: %d | Player Level: %d | Faction: %d", RemoveUnderScore(playerid), PVar[playerid][alevel], GetPlayerScore(playerid), PVar[playerid][factionID]);
                    SendClientMessage(playerid, 0x66999999, str);
                   
                    GivePlayerMoney(playerid, PVar[playerid][money]);
                    StopAudioStreamForPlayer(playerid);
                    loggedin[playerid] = 1;
                    TogglePlayerControllable(playerid, 1);
                    if(PVar[playerid][ajail] > 0)
                    {
                        format(str, sizeof(str), "You have %d minutes left in ajail.", PVar[playerid][ajail]);
                        SendClientMessage(playerid, 0x66666666, str);
                        switch(random(2))
                        {
                            case 0:
                            {
                                SetPlayerInterior(playerid, 6);
                                SetPlayerPos(playerid, 265,86,1001.0391);
                                SetPlayerFacingAngle(playerid, 270);
                                SetCameraBehindPlayer(playerid);
                                TogglePlayerControllable(playerid, 0);
                                Ajailtimer = SetTimerEx("UnAjailTimer", 60000, true, "i", playerid);
                                return 1;
                            }
                            case 1:
                            {
                                SetPlayerInterior(playerid, 6);
                                SetPlayerPos(playerid, 265,82,1001.0391);
                                SetPlayerFacingAngle(playerid, 270);
                                SetCameraBehindPlayer(playerid);
                                TogglePlayerControllable(playerid, 0);
                                Ajailtimer = SetTimerEx("UnAjailTimer", 60000, true, "i", playerid);
                                return 1;
                            }
                            case 2:
                            {
                                SetPlayerInterior(playerid, 6);
                                SetPlayerPos(playerid, 265,77,1001.0391);
                                SetPlayerFacingAngle(playerid, 270);
                                SetCameraBehindPlayer(playerid);
                                TogglePlayerControllable(playerid, 0);
                                Ajailtimer = SetTimerEx("UnAjailTimer", 60000, true, "i", playerid);
                                return 1;
                            }
                        }
                    }
                }
                else
                {
                    loginchances[playerid] -=1;
                    if(loginchances[playerid] == 0)
                    {
                        Kick(playerid);
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, 0xFFFFFFFF, "You have entered an incorrect password, try again.");
                        DialogPassword(playerid, LOGIN, "Account Login", "You have entered an incorrect password, try again.", "Login", "Leave");
                    }
                }
            }
        }
    }
    return 1;
}
I cannot find where it conflicts either.
Are you sure this wasn't a pre-existing error? Haven't looked over the code yet, will do that after this post.
Reply
#10

I need to see the code in the OnPlayerConnect, Something with the query you use to checked registration status may be messed up.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)