[FilterScript] Digital Health & Armour
#15

Quote:
Originally Posted by iFiras
View Post
On top of your script:
Code:
#pragma tabsize 0
Good job btw.
@iFiras - Using #pragma tabsize 0 is a bad coding habit!, I'd suggest you to fix your indentation to get rid of that warning.

@[uL]Pottus - I Agree with you brother.

@FailerZ - Why do you need 500 string cells? Did you read about Y_Less's thread about Why you shouldn't make your strings 256 cells big, if you haven't click this link: https://sampforum.blast.hk/showthread.php?tid=55261

Anyways, I fixed the code and followed what Pottus said, You should say thank you after you see this , Your code will work only for ID:0 when ID:1 connects the Textdraw will show ID:0's Health and Armour

Fixed Code
Code:
/*******************************************************************************
*        		     Digital Health & Armour [DHA]- by FailerZ                 *
*        				 	       Copyright ©                  		       *
*******************************************************************************/

//================================ [Includes] ==================================
#include          <a_samp>              //Credits to Kalcor/Kye

//================================= [Variables] ===================================
new PlayerText:DigiHP[MAX_PLAYERS], PlayerText:DigiAP[MAX_PLAYERS];

//------------------------------------------------------------------------------
//CallBacks and Publics
public OnFilterScriptInit()
{
	print("---------------------------------------");
	print("| Digital Health & Armour by FailerZ  |");
	print("|             Loaded                  |");
	print("---------------------------------------");
	return 1;
}
//------------------------------------------------------------------------------
public OnFilterScriptExit()
{
	print("---------------------------------------");
	print("| Digital Health & Armour by FailerZ  |");
	print("|             Unloaded                |");
	print("---------------------------------------");
	return 1;
}
//------------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
	//HP Check
	PlayerTextDrawShow(playerid, DigiHP[playerid]);
	
	//AP Check
	new Float:Armour;
	GetPlayerArmour(playerid, Armour);
	if(Armour >= 1)
		return PlayerTextDrawShow(playerid, DigiAP[playerid]);
	
	CreateDigitalHealthAndArmour(playerid);
    return 1;
}

//------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid, reason)
{
	PlayerTextDrawHide(playerid, DigiHP[playerid]);
	PlayerTextDrawHide(playerid, DigiAP[playerid]);
	PlayerTextDrawDestroy(playerid, DigiHP[playerid]);
	PlayerTextDrawDestroy(playerid, DigiAP[playerid]);
    return 1;
}

//------------------------------------------------------------------------------
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
	return OnArmourAndHealthUpdate(playerid), 1; // means return 1; or return true;
}

stock OnArmourAndHealthUpdate(playerid)
{
	new Float:Health, Float:Armour, string[ 10 ];

	GetPlayerHealth(playerid, Health), GetPlayerArmour(playerid, Armour);

	//HP Check
	format(string, sizeof(string), "%.0f", Health);
	PlayerTextDrawSetString(playerid, DigiHP[playerid], string);
	
	//AP Check
	if(Armour >= 1)
	{
	    format(string, sizeof(string), "%.0f", Armour);
		PlayerTextDrawSetString(playerid, DigiAP[playerid], string);
	}
	else
	{
	    PlayerTextDrawHide(playerid, DigiAP[playerid]);
	}
	return true;
}

stock CreateDigitalHealthAndArmour(playerid)
{
		//HP Textdraw
	DigiHP[playerid] = CreatePlayerTextDraw(playerid, 566.000000, 68.000000, "100");
	PlayerTextDrawBackgroundColor(playerid, DigiHP[playerid], -1);
	PlayerTextDrawFont(playerid, DigiHP[playerid], 1);
	PlayerTextDrawLetterSize(playerid, DigiHP[playerid], 0.350000, 0.599999);
	PlayerTextDrawColor(playerid, DigiHP[playerid], 255);
	PlayerTextDrawSetOutline(playerid, DigiHP[playerid], 1);
	PlayerTextDrawSetProportional(playerid, DigiHP[playerid], 1);
	
	//AP Textdraw
	DigiAP[playerid] = CreatePlayerTextDraw(playerid, 566.000000, 47.000000, "100");
	PlayerTextDrawBackgroundColor(playerid, DigiAP[playerid], -1);
	PlayerTextDrawFont(playerid, DigiAP[playerid], 1);
	PlayerTextDrawLetterSize(playerid, DigiAP[playerid], 0.349999, 0.599999);
	PlayerTextDrawColor(playerid, DigiAP[playerid], 255);
	PlayerTextDrawSetOutline(playerid, DigiAP[playerid], 1);
	PlayerTextDrawSetProportional(playerid, DigiAP[playerid], 1);
}
Reply


Messages In This Thread
Digital Health & Armour - by FailerZ - 20.12.2013, 17:32
Re: Digital Health & Armour - by MORJAN1122 - 20.12.2013, 17:35
Re: Digital Health & Armour - by DeathFire - 20.12.2013, 17:36
Re: Digital Health & Armour - by FoxGaming - 20.12.2013, 17:41
Re: Digital Health & Armour - by FailerZ - 20.12.2013, 17:42
Re: Digital Health & Armour - by PT - 20.12.2013, 17:45
Re: Digital Health & Armour - by amirab - 20.12.2013, 18:03
Re: Digital Health & Armour - by DeathFire - 20.12.2013, 18:22
Re: Digital Health & Armour - by FailerZ - 20.12.2013, 18:55
Re: Digital Health & Armour - by DemME - 20.12.2013, 19:34
Re: Digital Health & Armour - by Alphlax - 20.12.2013, 20:44
Re: Digital Health & Armour - by Pottus - 20.12.2013, 20:48
Re: Digital Health & Armour - by niels44 - 20.12.2013, 20:52
Re: Digital Health & Armour - by iFiras - 20.12.2013, 20:58
Re: Digital Health & Armour - by Patrick - 20.12.2013, 21:14
Re: Digital Health & Armour - by Hansrutger - 20.12.2013, 22:44
Re: Digital Health & Armour - by Emmet_ - 20.12.2013, 22:51
Re: Digital Health & Armour - by Pottus - 20.12.2013, 22:59
Re: Digital Health & Armour - by Patrick - 20.12.2013, 23:45
Re: Digital Health & Armour - by Mark_Samp - 21.12.2013, 00:07
Re: Digital Health & Armour - by Don_Cage - 21.12.2013, 00:24
Re: Digital Health & Armour - by FailerZ - 21.12.2013, 05:57
Re: Digital Health & Armour - by Emmet_ - 21.12.2013, 05:59
Re: Digital Health & Armour - by FailerZ - 21.12.2013, 06:07
Re: Digital Health & Armour - by Auloger - 21.12.2013, 15:49
Re: Digital Health & Armour - by AhsanAman - 10.01.2014, 19:28
Re: Digital Health & Armour - by FailerZ - 14.01.2014, 08:06
Re: Digital Health & Armour - by SyntaxQ - 14.01.2014, 10:39
Re: Digital Health & Armour - by semen7907 - 31.01.2014, 11:20
Re: Digital Health & Armour - by mahardika - 31.01.2014, 11:38
Re: Digital Health & Armour - by Guest4390857394857 - 05.04.2014, 21:03
Re: Digital Health & Armour - by TDM - 06.04.2014, 20:09
Re: Digital Health & Armour [ReCoded!] [Fixed Version!] - by ItzColaBoi - 21.11.2017, 19:05

Forum Jump:


Users browsing this thread: 1 Guest(s)