[FilterScript] Digital Health & Armour
#1

-
Digital Health and Armour [DHA]
by FailerZ


Introduce:
● This script display the amount of the player Health and Armour.
Note: This FliterScript doesn't set the player Armour and/or Health.

------------------------------------------------------------------------------------------------

Features:
● Includes free! No includes just <a_samp> for sure.
● Bugs free! No bugs in this script TESTED.
● Displays the Armour when you have it only! e.g. If you got 0 Armour the number will not displayed.
● Works with any gamemode! Will not affect anything in your gamemode.
● Tidy and Clean code.

------------------------------------------------------------------------------------------------

ScreenShots:







------------------------------------------------------------------------------------------------

Download:
* Fixed Versions || ReCoded *
SolidFiles (Recommended)
Pastebin (Not Recommended || Code is messed up here)
------------------------------------------------------------------------------------------------

Installation:
● Place the DHA.pwn and DHA.amx in your filterscripts folder after downloading them.
● Open your server.cfg and type DHA near the filterscripts line..
HTML Code:
filterscripts DHA
● Run your gamemode and enjoy

------------------------------------------------------------------------------------------------

Credits:
● Kalcor/Kye, For SA-MP.
● ME (FailerZ), For making it from scratch.
● You, For downloading it

------------------------------------------------------------------------------------------------

Notes:
● You are ALLOWED to edit this FS to fit your server.
● You are NOT ALLOWED to re release it after editing.
● You are NOT ALLOWED to remove the credits.
pawn Code:
//      /$$$$$$$$            /$$ /$$                     /$$$$$$$$
//      | $$_____/          |__/| $$                    |_____ $$
//      | $$        /$$$$$$  /$$| $$  /$$$$$$   /$$$$$$      /$$/
//      | $$$$$    |____  $$| $$| $$ /$$__  $$ /$$__  $$    /$$/
//      | $$__/     /$$$$$$$| $$| $$| $$$$$$$$| $$  \__/   /$$/
//      | $$       /$$__  $$| $$| $$| $$_____/| $$        /$$/
//      | $$      |  $$$$$$$| $$| $$|  $$$$$$$| $$       /$$$$$$$$
//      |__/       \_______/|__/|__/ \_______/|__/      |________/

/*******************************************************************************
*                  Digital Health & Armour [DHA] - by FailerZ                  *
*                                  Copyright ©                                 *
*******************************************************************************/
Reply
#2

Nice one +REP
Reply
#3

Nice!!
Reply
#4

Nice and simple.. Very useful for dm and fr srv's.
Reply
#5

Thanks guys i hope you enjoyed it
Reply
#6

very useful.

nice job.
Reply
#7

good and useful +REP
Reply
#8

Quote:
Originally Posted by amirab
View Post
good and useful +REP
you can't give rep -_-
Reply
#9

Updated, It will use OnPlayerUpdate(playerid) to avoid lag..
Please re download if you are using it.
Thanks.
Reply
#10

I've tried to do it trought pastbin, and it gives me some warns
Quote:

C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(106) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(122) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(12 : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(132) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(187) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(196) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(230) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(231) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(274) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(275) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


10 Warnings.

Reply
#11

Good script mate
Reply
#12

This will not work as expected as updating the textdraw for one player will update for all players you need to use player textdraws for each player and create them when a player connects.

Also, there is absolutely no point of using OnPlayerUpdate() for this OnPlayerTakeDamage() and OnPlayerSpawn() would be fine as you only need to update the textdraw when the player actually takes damage.

Last problem you don't need to show the textdraw every time you update the string

TextDrawShowForPlayer(playerid, DigiAP); absolutely not needed at all.
Reply
#13

using asimple cleo mod works aswell...

nice work tho.
Reply
#14

Quote:
Originally Posted by DemME
View Post
I've tried to do it trought pastbin, and it gives me some warns
Code:
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(106) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(122) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(12 : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(132) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(187) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(196) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(230) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(231) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(274) : warning 217: loose indentation
C:\Documents and Settings\user\Desktop\R-RP\gamemodes\test.pwn(275) : warning 217: loose indentation
Pawn compiler 3.2.3664	 Copyright © 1997-2006, ITB CompuPhase


10 Warnings.
On top of your script:
Code:
#pragma tabsize 0
Good job btw.
Reply
#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
#16

I have heard really bad stories about murders happen if you use too much stuff on OnPlayerUpdate. Kidding, but I've been reminded tons of times by the people I ask for help to almost never use OnPlayerUpdate. Instead they told me to use a timer. Anyways nice work! :P
Reply
#17

Let me just throw in my two cents, I noticed pds2k12 did so and [uL]Pottus also, but this is my overall opinion.

Firstly, this only uses 2 global textdraws, meaning that only 1 player can actually use this. Any other players on the server would get mixed results, so I recommend you create 2 player textdraws for each player.

Secondly,

Code:
public OnPlayerUpdate(playerid)
{
        //HP Check
        new Float:Health, hstr[500];
        GetPlayerHealth(playerid, Health);
        format(hstr, sizeof(hstr), "%.0f", Health);
        TextDrawSetString(DigiHP, hstr);
        TextDrawShowForPlayer(playerid, DigiHP);
       
        //AP Check
        new Float:Armour, astr[500];
        GetPlayerArmour(playerid, Armour);
        if(Armour >= 1)
        {
            format(astr, sizeof(astr), "%.0f", Armour);
                TextDrawSetString(DigiAP, astr);
            TextDrawShowForPlayer(playerid, DigiAP);
        }
        else
        {
            TextDrawHideForPlayer(playerid, DigiAP);
        }
        return 1;
}
Why would you possibly need 2 x 500 cell strings (1,000 cells = 4,000 bytes) for something that would only need about ~12 cells?

Anyways, once you fix up this filterscript then I'll get around to adding it to my debugging server, as it'll make it easier for me to keep track of health.

P.S. Don't take this personally, this is only constructive criticism!
Reply
#18

It's good that there is lots of people that can see all the issues instantly and point them out it's really more important to know not what to do rather than what to do otherwise you'll never learn anything!
Reply
#19

Quote:
Originally Posted by Hansrutger
View Post
I have heard really bad stories about murders happen if you use too much stuff on OnPlayerUpdate. Kidding, but I've been reminded tons of times by the people I ask for help to almost never use OnPlayerUpdate. Instead they told me to use a timer. Anyways nice work! :P
The code he have doesn't really cause the server to lag. We are just giving him ideas what to do and stuff, @Emmet I also mentioned that above, about 500 string cells
Reply
#20

At least something new
Good job
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)