[FilterScript] Armour & Health Numbers
#1

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; }
Reply
#2

Nice work mate
Reply
#3

thanks
Reply
#4

Nice job.
Reply
#5

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

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 )
Reply
#7

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
Reply
#8

@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.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)