SA-MP Forums Archive
Is ok ? - 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: Is ok ? (/showthread.php?tid=639022)



Is ok ? - StR_MaRy - 10.08.2017

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 ?

Код HTML:
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;
}



Re: Is ok ? - Misiur - 10.08.2017

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


Re: Is ok ? - Banditul18 - 10.08.2017

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....


Re: Is ok ? - saffierr - 10.08.2017

Just save it when player disconnects? Duhh


Re: Is ok ? - Vince - 10.08.2017

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
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.


Re: Is ok ? - StR_MaRy - 10.08.2017

ok, i k how to do it , i just wanted to prove to someone else thx for your answears