SA-MP Forums Archive
MySQL connecting twice - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL connecting twice (/showthread.php?tid=603334)



MySQL connecting twice - theonethatownz - 21.03.2016

Have an issue with MySQL Connecting twice, this means it loads two sets of each vehicles up, etc

pawn Код:
ManualVehicleEngineAndLights();
    ShowPlayerMarkers(0);
    EnableStuntBonusForAll(0);
    DisableInteriorEnterExits();
    SetGameModeText(SCRIPT_VERSION);
    new string[128];
    format(string, sizeof(string), "hostname %s", Hostname);
    SendRconCommand(string);
    mysql_log(LOG_ALL);
    mysql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
    if(mysql_errno() != 0)
    {
        printf("[MySQL] The connection has failed.");
    }
    else
    {
        printf("[MySQL] The connection was successful.");
    }
    mysql_tquery(mysql, "SELECT * FROM `vehicles` ORDER BY ID ASC", "LoadVehicles");
    return true;



Re: MySQL connecting twice - theonethatownz - 24.03.2016

Still need help,
Shows the successful message twice and spawns two lots of vehicles from a table.


Re: MySQL connecting twice - NaS - 24.03.2016

Quote:
Originally Posted by theonethatownz
Посмотреть сообщение
Still need help,
Shows the successful message twice and spawns two lots of vehicles from a table.
Do you have this in your script?

Код:
main(){}
Somehow the main function cannot be packed into one line, that makes OnGameModeInit call 2 times.
Put the brackets in a new line and a space between them, if that is the case.
Else I don't know what it could be, eventually a bad hook.


Re: MySQL connecting twice - theonethatownz - 24.03.2016

Yes, its one line. Ill do it like
pawn Код:
main()
{
}