SA-MP Forums Archive
dmg amount, save in-array - 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: dmg amount, save in-array (/showthread.php?tid=617511)



dmg amount, save in-array - FinStar - 22.09.2016

Hello, I want to ask how to save amount damage to that player and then how to display it in the dialogue?


Code:
#define MAX_BODY_PARTS 7
#define MAX_WEAPONS 55

new Damage[MAX_PLAYERS][MAX_BODY_PARTS][MAX_WEAPONS];


DisplayDamages(toplayer, playerid)
{
	new playername[MAX_PLAYER_NAME], title[45];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(title, sizeof(title), "DMG info player: %s.", playername);
	if(!CountDamages(playerid)) return ShowPlayerDialog(toplayer, D_DAMAGES, DIALOG_STYLE_LIST, title, "Nothing injuries", ">>>", "");
	new gText[1000], fstr[200];
	new Float:armour;
	GetPlayerArmour(playerid, armour);
	for(new i = 0; i < MAX_BODY_PARTS; i++)
	{
		for(new z = 0; z < MAX_WEAPONS; z++)
		{
			if(!Damage[playerid][i][z]) continue;
			switch(i)
			{
				case 0 .. 15: format(fstr, sizeof(fstr), "%d hit(y) from %s, body part %s\n", Damage[playerid][i][z], GetWeaponNameEx(z), GetBodyPartName(i + 3));
				//case 54: format(fstr, sizeof(fstr), "%d falls to the %s\n", Damage[playerid][i][z], GetBodyPartName(i));
				//default: format(fstr, sizeof(fstr), "%d bullets from %s to the %s\n", Damage[playerid][i][z], GetWeaponNameEx(z), GetBodyPartName(i + 3));
			}
			strcat(gText, fstr);
		}
	}
	ShowPlayerDialog(toplayer, D_DAMAGES, DIALOG_STYLE_LIST, title, gText, "Close", "");
	return 1;
}


public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
	if((0 <= weaponid <= 46) || weaponid == 54)
	{
		if(BODY_PART_TORSO <= bodypart <= BODY_PART_HEAD) Damage[playerid][(bodypart - 3)][weaponid]++;
		{
		
		}
return 1;
	}