SA-MP Forums Archive
[FilterScript] Armour & Health Numbers - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Armour & Health Numbers (/showthread.php?tid=422489)



Armour & Health Numbers - P3DRO - 13.03.2013

I'm a rookie to Pawno, currently I'm scripting an AAD GM and I will be releasing some code that I will use in the AAD GM. For my debut as a scripter I decided to release a simple yet useful filterscript that shows your Armour and Health as a number in your Armour and Health bars.

Print - http://gyazo.com/cc308266b7674d19b79a0927b5dd6f76

In case you detect some bug or any mistake I did please let me know so I can improve. Thank you and I hope you enjoy

Код:
#include <a_samp>

#define SLOTS 50 // Change it to your Server Slots

new txdstr[25];

new Float:Armour;
new Float:Health;

new Text:ArmourTXD[SLOTS];
new Text:HealthTXD[SLOTS];

public OnFilterScriptInit() {
	for (new i=0; i <= SLOTS; i++) {
		ArmourTXD[i] = TextDrawCreate(600.000000, 43.000000, "Armour: 100");
		TextDrawAlignment(ArmourTXD[i], 3);
		TextDrawBackgroundColor(ArmourTXD[i], 255);
		TextDrawFont(ArmourTXD[i], 3);
		TextDrawLetterSize(ArmourTXD[i], 0.359999, 1.300000);
		TextDrawColor(ArmourTXD[i], -1);
		TextDrawSetOutline(ArmourTXD[i], 1);
		TextDrawSetProportional(ArmourTXD[i], 1);

		HealthTXD[i] = TextDrawCreate(600.000000, 64.000000, "Health: 100");
		TextDrawAlignment(HealthTXD[i], 3);
		TextDrawBackgroundColor(HealthTXD[i], 255);
		TextDrawFont(HealthTXD[i], 3);
		TextDrawLetterSize(HealthTXD[i], 0.359999, 1.300000);
		TextDrawColor(HealthTXD[i], -1);
		TextDrawSetOutline(HealthTXD[i], 1);
		TextDrawSetProportional(HealthTXD[i], 1); }

	return 1; }

public OnFilterScriptExit() {
    for (new i=0; i <= SLOTS; i++) {
        TextDrawDestroy(ArmourTXD[i]);
        TextDrawDestroy(HealthTXD[i]); }

	return 1; }

public OnPlayerSpawn(playerid) {
	TextDrawShowForPlayer(playerid, ArmourTXD[playerid]);
	TextDrawShowForPlayer(playerid, HealthTXD[playerid]);

	return 1; }

public OnPlayerUpdate(playerid) {
	GetPlayerArmour(playerid, Armour);
	if (Armour > 0) {
	    format(txdstr, 25, "%.0f", Armour);
		TextDrawSetString(ArmourTXD[playerid], txdstr);
		TextDrawShowForPlayer(playerid, ArmourTXD[playerid]); }
	else TextDrawHideForPlayer(playerid, ArmourTXD[playerid]);

	GetPlayerHealth(playerid, Health);
	format(txdstr, 25, "%.0f", Health);
	TextDrawSetString(HealthTXD[playerid], txdstr);

	return 1; }

public OnPlayerDeath(playerid, killerid, reason) {
	TextDrawSetString(HealthTXD[playerid], "0");

	return 1; }



Re: Armour & Health Numbers - Jewell - 14.03.2013

Nice work mate


Re: Armour & Health Numbers - P3DRO - 14.03.2013

thanks


Re: Armour & Health Numbers - Lyksus - 14.03.2013

Nice job.


Re: Armour & Health Numbers - theomanking - 14.03.2013

WTF? This only show you Armour And Health are 100 lol.
Dude change it to it's amount!


Re: Armour & Health Numbers - 2KY - 14.03.2013

I suggest using PlayerTextDraws rather than normal textdraws, as you won't have to create 50 of them, and they have their own counter on how many is allowed. ( www.wiki.sa-mp.com/wiki/Limits ) & ( www.wiki.sa-mp.com/wiki/CreatePlayerTextDraw )


Re: Armour & Health Numbers - P3DRO - 14.03.2013

Quote:
Originally Posted by theomanking
Посмотреть сообщение
WTF? This only show you Armour And Health are 100 lol.
Dude change it to it's amount!
Have you tested the fs? i dont think you did...

@2ky thanks for the sugestion, i will try and learn it so i can use it in the future


Re: Armour & Health Numbers - Brokenbreaken - 14.03.2013

@2up Player can have at at screen 92 textdraw, NO can create 92 textdraws.
@topic You can do to this callback OnPlayerTakeDamage, OnPlayerUpdate is too often performed.


Re: Armour & Health Numbers - P3DRO - 14.03.2013

Quote:
Originally Posted by Brokenbreaken
Посмотреть сообщение
@topic You can do to this callback OnPlayerTakeDamage, OnPlayerUpdate is too often performed.
nice suggestion, but for some reason it doesnt work.