PDA

View Full Version : Is ok ?


StR_MaRy
10/08/2017, 03:26 PM
Hey guys is ok if load this thing every single seccond ?

I mean it may create lag or if i add let's say 30+ lines should make lag or something ?

function OnAccountSave(playerid)
{
if(PlayerInfo[playerid][pLogged] == 0) return 1;
new query[456], final[1028];
format(query, sizeof(query), "UPDATE `Accounts` SET ");
strcat(final,query);
format(query, sizeof(query), "`Level` = '%d',",PlayerInfo[playerid][pLevel]);
strcat(final,query);
format(query, sizeof(query), "`Sex` = '%d',",PlayerInfo[playerid][pSex]);
strcat(final,query);
format(query, sizeof(query), "`Skin` = '%d',",PlayerInfo[playerid][pSkin]);
strcat(final,query);
format(query, sizeof(query), "`Hours` = '%d',",PlayerInfo[playerid][pHours]);
strcat(final,query);
format(query, sizeof(query), "`Minutes` = '%d',",PlayerInfo[playerid][pMinutes]);
strcat(final,query);
format(query, sizeof(query), "`Language` = '%d',",PlayerInfo[playerid][pLanguage]);
strcat(final,query);
format(query, sizeof(query), "`Admin` = '%d',",PlayerInfo[playerid][pAdmin]);
strcat(final,query);
format(query, sizeof(query), "`Helper` = '%d',",PlayerInfo[playerid][pHelper]);
strcat(final,query);
format(query, sizeof(query), "`Respect` = '%d',",PlayerInfo[playerid][pRespect]);
strcat(final,query);
format(query, sizeof(query), "`Money` = '%d',",PlayerInfo[playerid][pMoney]);
strcat(final,query);
format(query, sizeof(query), "`Bank` = '%d',",PlayerInfo[playerid][pBank]);
strcat(final,query);
format(query, sizeof(query), "`Age` = '%d',",PlayerInfo[playerid][pAge]);
strcat(final,query);
format(query, sizeof(query), "`Reports` = '%d',",PlayerInfo[playerid][pReports]);
strcat(final,query);
format(query, sizeof(query), "`Newbies` = '%d',",PlayerInfo[playerid][pNewbies]);
strcat(final,query);
format(query, sizeof(query), "`Warn` = '%d',",PlayerInfo[playerid][pWarn]);
strcat(final,query);
format(query, sizeof(query), "`MuteTime` = '%d',",PlayerInfo[playerid][pMuteTime]);
strcat(final,query);
format(query, sizeof(query), "`Mute` = '%d',",PlayerInfo[playerid][pMute]);
strcat(final,query);
format(query, sizeof(query), "`Banned` = '%d',",PlayerInfo[playerid][pBanned]);
strcat(final,query);
format(query, sizeof(query), "`BanDays` = '%d',",PlayerInfo[playerid][pBanDays]);
strcat(final,query);
format(query, sizeof(query), "`BannedBy` = '%s',",PlayerInfo[playerid][pBannedBy]);
strcat(final,query);
format(query, sizeof(query), "`MarkX` = '%f',",PlayerInfo[playerid][pMarkX]);
strcat(final,query);
format(query, sizeof(query), "`MarkY` = '%f',",PlayerInfo[playerid][pMarkY]);
strcat(final,query);
format(query, sizeof(query), "`MarkZ` = '%f',",PlayerInfo[playerid][pMarkZ]);
strcat(final,query);
format(query, sizeof(query), "`BannedReason` = '%s',",PlayerInfo[playerid][pBannedReason]);
strcat(final,query);
format(query, sizeof(query), "`Crashed` = '%d',",PlayerInfo[playerid][pCrashed]);
strcat(final,query);
format(query, sizeof(query), "`DrivingLicenseA` = '%d',",PlayerInfo[playerid][pDrivingLicenseA]);
strcat(final,query);
format(query, sizeof(query), "`DrivingLicenseB` = '%d',",PlayerInfo[playerid][pDrivingLicenseB]);
strcat(final,query);
format(query, sizeof(query), "`DrivingLicenseC` = '%d',",PlayerInfo[playerid][pDrivingLicenseC]);
strcat(final,query);
format(query, sizeof(query), "`WeaponLicense` = '%d',",PlayerInfo[playerid][pWeaponLicense]);
strcat(final,query);
format(query, sizeof(query), "`FlyingLicense` = '%d',",PlayerInfo[playerid][pFlyingLicense]);
strcat(final,query);
format(query, sizeof(query), "`NavigationLicense` = '%d',",PlayerInfo[playerid][pNavigationLicense]);
strcat(final,query);
format(query, sizeof(query), "`Work` = '%d',",PlayerInfo[playerid][pWork]);
strcat(final,query);
format(query, sizeof(query), "`AdminJailed` = '%d',",PlayerInfo[playerid][pAdminJailed]);
strcat(final,query);
format(query, sizeof(query), "`AdminJailedReason` = '%s',",PlayerInfo[playerid][pAdminJailedReason]);
strcat(final,query);
format(query, sizeof(query), "`AdminJailedMinutes` = '%d',",PlayerInfo[playerid][pAdminJailedMinutes]);
strcat(final,query);
format(query, sizeof(query), "`AdminJailedAdmin` = '%s',",PlayerInfo[playerid][pAdminJailedAdmin]);
strcat(final,query);
format(query, sizeof(query), "`AlreadyVoted` = '%s',",PlayerInfo[playerid][pAlreadyVoted]);
strcat(final,query);
format(query, sizeof(query), "`Tester` = '%d',",PlayerInfo[playerid][pTester]);
strcat(final,query);
format(query, sizeof(query), "`Recover` = '%s'",PlayerInfo[playerid][pRecover]);
strcat(final,query);
format(query, sizeof(query), " WHERE ID = %d", PlayerInfo[playerid][pID]);
strcat(final,query);
mysql_format(mysql, final, sizeof(final), "%s", final);
mysql_query(mysql, final, false);
return 1;
}

Misiur
10/08/2017, 04:09 PM
Building the query itself is not an issue, but if you run it for all players every second you just created self denial of service attack

Banditul18
10/08/2017, 06:27 PM
Kill me please....

Why you even want to save all the stats every seconds after all? Why not only when its change and update that particualr one that changed?

And mysql_query....Use mysql_tquery instead
This is worse than DDOS , this is host overkill....

saffierr
10/08/2017, 06:30 PM
Just save it when player disconnects? Duhh

Vince
10/08/2017, 06:45 PM
Why not only when its change and update that particualr one that changed?

This right here. You will have more queries overall but they will be shorter and quicker and they eradicate the need to explicitly save on disconnect. And in case of a server crash (OnPlayerDisconnect/OnGameModeExit are not called) it prevents data loss.

Furthermore, the banned and jailed stuff should not be in this table because it implies the player can be banned or jailed only once. Better to make separate tables for those.

StR_MaRy
10/08/2017, 11:43 PM
ok, i k how to do it , i just wanted to prove to someone else :) thx for your answears