SA-MP Forums Archive
Injury system bug - 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: Injury system bug (/showthread.php?tid=632634)



Injury system bug - Ronen765001 - 17.04.2017

Hello, I have a problem with my injury system.
The problem is, it fucks up like insane.
Sometimes it just shows "Internal Injury" even though I shot the person in every body part...
Anyway, if someone can tell why is this Bug happening, I'll be glad for that.
Thanks.
Код:
COMMAND:injuries(playerid, params[])
{
	new targetid;
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /injuries [playerid]");

	if(GetPVarInt(targetid, "Dead") != 2) return SendClientMessage(playerid, COLOR_ERROR, "This player is not dead.");

	new title[60];
	format(title, sizeof(title), "Injuries of %s", PlayerInfo[playerid][pName]);

	new content[1024];
	format(content, sizeof(content), "This player is injured in the following bodyparts:\n\n");

	new injury[128], injuries = 0;
	for(new i = 0; i < 10; i++)
	{
		format(injury, sizeof(injury), "");
		if(PlayerInfo[playerid][pInjuries][i] > 0)
		{
			switch(i)
			{
				case 1:
				{
					format(injury, sizeof(injury), "Chest Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
				case 2:
				{
					format(injury, sizeof(injury), "Groin Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
				case 3:
				{
					format(injury, sizeof(injury), "Left Arm Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
				case 4:
				{
					format(injury, sizeof(injury), "Right Arm Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
				case 5:
				{
					format(injury, sizeof(injury), "Left Leg Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
				case 6:
				{
					format(injury, sizeof(injury), "Right Leg Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
				case 7:
				{
					format(injury, sizeof(injury), "Head Injury x%i\n", PlayerInfo[playerid][pInjuries][i]);
					injuries++;
				}
			}
		}

		if(strlen(injury) > 0)
		{
			format(content, sizeof(content), "%s%s", content, injury);
		}
	}

	if(injuries == 0)
	{
		format(injury, sizeof(injury), "Internal Injury\n");
		format(content, sizeof(content), "%s%s", content, injury);
	}

	ShowPlayerDialogEx(playerid, DIALOG_INJURIES, DIALOG_STYLE_MSGBOX, title, content, "Close", "");
	return 1;
}