09.02.2012, 12:33
Is it safe to use the R7 on a live server?
[16:00:42] [debug] Server crashed while executing mode_r7.amx [16:00:42] [debug] Backtrace (most recent call first): [16:00:42] [debug] #0 native mysql_ping() from mysql.dll [16:00:42] [debug] #1 public Server_DatabaseConnect()+0x210 at mode_r7.pwn:369 [16:00:42] [debug] #2 public zcmd_OnGameModeInit()+0xb8 at mode_r7.pwn:88 [16:00:42] [debug] #3 native CallLocalFunction() from samp-server.exe [16:00:42] [debug] #4 public Server_DatabaseConnect()+0x210 at mode_r7.pwn:369 [16:00:42] [debug] #5 public zcmd_OnGameModeInit()+0xb8 at mode_r7.pwn:88
//printf("Conexгo com a database realizada com sucesso!\nPing: %d", mysql_ping(MYSQL_GAME_CONNECTION));
public OnPlayerConnect(playerid)
{
SetPlayerCameraPos(playerid, -2321.0840, 1322.4452, 62.1136);
SetPlayerCameraLookAt(playerid, -2322.0059, 1322.8374, 61.9684);
Player_SetTextDraws(playerid);
GetPlayerName(playerid, query, MAX_PLAYER_NAME);
mysql_real_escape_string(query, gPlayerInfo[playerid][gPlayerName], MYSQL_GAME_CONNECTION);
Player_SetStatusLabel(playerid, "Checando a Existencia da conta...");
Player_CheckIfExists(playerid);
GetPlayerIp(playerid, gPlayerInfo[playerid][gPlayerIP], 16);
rdns(gPlayerInfo[playerid][gPlayerIP], playerid);
TextDrawShowForPlayer(playerid, TD_SERVER_LOGO);
Player_SetStatusLabel(playerid, "Checando a Existencia da conta...");
Player_CheckIfExists(playerid);
return 1;
}
public Player_CheckIfExists(playerid)
{
mysql_format(MYSQL_GAME_CONNECTION, query, "SELECT * FROM `game_player` WHERE `name`='%s'", gPlayerInfo[playerid][gPlayerName]);
mysql_function_query(MYSQL_GAME_CONNECTION, query, true, "r@Player_CheckIfExists", "i", playerid);
return 1;
}
public r@Player_CheckIfExists(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
Player_SetStatusLabel(playerid, "Conta existente, digite a senha para prosseguir.");
gPlayerInfo[playerid][gPlayerStat] = PLAYER_STAT_LOGGING;
gPlayerInfo[playerid][gPlayerLoginTries] = 0;
format(query, 128, "Bem-vindo de volta, %s!\n\nInsira sua senha no campo a seguir para logar em sua conta.", gPlayerInfo[playerid][gPlayerName]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Bem-vindo ao " C_SERVERNAME, query, "Entrar", "Cancelar");
return 1;
}
Player_SetStatusLabel(playerid, "Registro:");
SendClientMessage(playerid, -1, "Prossiga com o registro para continuar:");
return 1;
}
@[Diablo] you can still fetch the data in the PAWN thread with mysql_retrieve_row() and such(you will have to set the cache variable to false then).
But, there is still a backward compatibility define pawn Код:
@Stewie` as Sergei said and as I said above, if you had used the threded model before, the above define should do the job.. unless you're using one of the removed functions like: pawn Код:
|
(7029) : error 017: undefined symbol "mysql_query"
#if defined mysql_query
#error mysql_query is defined
#endif
Result:
15) : fatal error 111: user error: mysql_query is defined
#define mysql_query(%1,%2,%3,%4) \ mysql_function_query(%4, %1, false, "OnQueryFinish", "siii", %1, %2, %3, %4)
I think you should delete the spaces in a_mysql.inc, like this:
Код:
#define mysql_query(%1,%2,%3,%4) \ mysql_function_query(%4, %1, false, "OnQueryFinish", "siii", %1, %2, %3, %4) And to be completely honest, I don't think you should stick to the old method of having an OnQueryFinish callback. I find the cache method very convenient to use. Besides, you don't even need 4 parameters to be passed to the callback most of the time, but having the ability to pass more parameters using the 5th+ parameter is great. |
[12/02/2012 18:23:00] [debug] [Sacnr.amx]: During execution of IRC_OnReceiveRaw():
[12/02/2012 18:23:00] [debug] [Sacnr.amx]: Run time error 8: "Heap underflow"
[12/02/2012 18:23:00] [debug] [Sacnr.amx]: Heap index (HEA) is 0xBDE, heap bottom (HLW) is 0x2B5BB0
[12/02/2012 18:23:00] [debug] [Sacnr.amx]: Call stack (most recent call first):
[12/02/2012 18:23:00] [debug] The server has crashed executing 'Sacnr.amx'
[12/02/2012 18:23:00] [debug] [Sacnr.amx]: Call stack (most recent call first):
mysql_query("SELECT MAX(buSQLID) FROM Buildings");
mysql_store_result();
new SQL[20];
mysql_fetch_row_format(SQL, "|");
new sqlid = strval(SQL);
Simply setting the cache to true in mysql_function_query won't do the trick, you need to use the cache functions in the returning callback as well.
cache_get_data returns stores the amount of rows and fields in the given parameters. This is useful for checking validity of what a SELECT query outputs and looping through the results as well. cache_get_row stores the field data in the destination string. It is as simple as that: pawn Код:
There's also cache_get_field_content which will get the data by the field's name, for example: pawn Код:
I have a house loading/parsing function which runs on startup only. When using the regular method (store the result, put mysql_fetch_row_format in a loop, etc), it took around 2.5 seconds to execute. I converted that function to use the cache method and the differences are slightly astonishing! For the sake of it, I searched them out in my outbox (sent to xxmitsu previously), and for the old method, all mysql_fetch_row calls took ~3000ms, sscanf parsing took ~30ms and other parts of code in the loop ~130ms. After converting, the whole execution time is ~300ms, cache functions take around 160ms of it. I didn't run very many tests, but when starting the server up on Windows, I can clearly tell that the gain in startup is literally seconds! |