SA-MP Forums Archive
What is the best way for saving guns? - 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: What is the best way for saving guns? (/showthread.php?tid=623624)



What is the best way for saving guns? - knuckleduster5 - 02.12.2016

Hello!
I'm using this method for saving gun but I'm worried about this. I want the know what's your method about saving guns?

Here is mine:

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	new
		tmp_accguns[13][2],
		tmp_string[64],
		query[516];

	for(new i = 0; i <= 12; i++)
	{
		GetPlayerWeaponData(playerid, i, tmp_accguns[i][0], tmp_accguns[i][1]);
	}

	for(new i = 0; i <= 12; i++)
	{
		format(tmp_string, sizeof(tmp_string), "weapon%d", i);
		mysql_format(mysql, query, sizeof(query), "UPDATE `hesaplar` SET `%s`=%d WHERE `sqlid`=%d", tmp_string, tmp_accguns[i][0], hesap[playerid][sqlid]);
		mysql_tquery(mysql, query, "", "");

		format(tmp_string, sizeof(tmp_string), "ammo%d", i);
		mysql_format(mysql, query, sizeof(query), "UPDATE `hesaplar` SET `%s`=%d WHERE `sqlid`=%d", tmp_string, tmp_accguns[i][1], hesap[playerid][sqlid]);
		mysql_tquery(mysql, query, "", "");
	}

	new
		tmp_satir[64];

    for(new i = 0; i <= 12; i++)
	{
	    format(tmp_satir, sizeof(tmp_satir), "weapon%d", i);
	    hesap_weaponlar[playerid][i][0] = cache_get_field_content_int(0 , tmp_satir);

    	format(tmp_satir, sizeof(tmp_satir), "ammo%d", i);
    	hesap_weaponlar[playerid][i][1] = cache_get_field_content_int(0 , tmp_satir);
	}
    return true;
}



Re: What is the best way for saving guns? - knuckleduster5 - 02.12.2016

bump


Re: What is the best way for saving guns? - Dayrion - 03.12.2016

Your server will probably get a heart attack if 50 players use a minigun.


Re: What is the best way for saving guns? - knuckleduster5 - 03.12.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Your server will probably get a heart attack if 50 players use a minigun.
Yes, I know this but what else i do?

Timer per second. (trash)
OnPlayerUpdate. (so trash)
OnPlayerWeaponShoot. (trash but acceptable)

Please help me!


Re: What is the best way for saving guns? - knuckleduster5 - 03.12.2016

Fixed.


Re: What is the best way for saving guns? - SickAttack - 03.12.2016

Array, man. Save weapons on disconnect.


Re: What is the best way for saving guns? - Vince - 03.12.2016

I suggest you read this tutorial of mine.


Re: What is the best way for saving guns? - knuckleduster5 - 09.12.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
I suggest you read this tutorial of mine.
Thanks sir, +rep