20.12.2013, 21:14
@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
@[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 ArmourFixed 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);
}

