18.09.2011, 18:46
Hello,
I do not go on. My server takes, since I rewrote the script to MySQL, massive amount of CPU. I cant find an answer, why it is so. I build only once a connection to the MySQL database under "OnGameModeInit". I load Users under OnPlayerLogin like this:
I renamed the OnPlayerUpdate to PlayerRefresh, but it will takes still more than 50% of the CPU. The players only will updated if they disconnect. it looks like (unter OnPlayerDisconnect) this:
MySQLUpdatePlayerInt contains:
anybody have an idea, how to fix the cpu-laggs? it can lead to blocking of my server
regards and thanks
/edit: oh, and i forget to say, that the cpu increases, when 1 or more player is connected about 2-10 minutes...
I do not go on. My server takes, since I rewrote the script to MySQL, massive amount of CPU. I cant find an answer, why it is so. I build only once a connection to the MySQL database under "OnGameModeInit". I load Users under OnPlayerLogin like this:
pawn Код:
public OnPlayerLogin(playerid, password[])
{
MySQLCheck();
new mysql_row[1024], string2[1024], playername[MAX_PLAYER_NAME], ipaddress[16], string[256];
GetPlayerIp(playerid, ipaddress, sizeof(ipaddress));
GetPlayerName(playerid, playername, sizeof(playername));
format(string2,sizeof(string2),"SELECT * FROM `players` WHERE Name = '%s' AND Password = '%s' LIMIT 1", playername, password);
mysql_query(string2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_fetch_row(mysql_row);
mysql_fetch_field_row(string2,"Password");
format(PlayerInfo[playerid][pKey], 128,"%s", string2);
mysql_fetch_field_row(string2,"PlayerLevel");
PlayerInfo[playerid][pLevel] = strval(string2);
mysql_fetch_field_row(string2,"AdminLevel");
PlayerInfo[playerid][pAdmin] = strval(string2);
mysql_free_result();
(At the End of this part:
pawn Код:
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
MySQLCheck();
new name[MAX_PLAYER_NAME], query[MAX_STRING];;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
MySQLUpdatePlayerInt(name,"PlayerLevel", PlayerInfo[playerid][pLevel]);
MySQLUpdatePlayerInt(name,"AdminLevel", PlayerInfo[playerid][pAdmin]);
(At the end: MySQLUpdatePlayerInt(name,"BannedAdmin", PlayerInfo[playerid][pBannedAdmin]);)
pawn Код:
MySQLUpdatePlayerInt(name[], column[], value)
{
new query[MAX_STRING];
format(query,sizeof(query),"UPDATE players SET %s = '%d' WHERE Name = '%s' LIMIT 1", column, value, name);
mysql_query(query);
}
regards and thanks
/edit: oh, and i forget to say, that the cpu increases, when 1 or more player is connected about 2-10 minutes...