Health Detection/Injury System
#1

So, I want to make a system where it detects your health and if its 10hp, it forces you into a animation and displays a text above your head saying (( THIS PLAYER IS INJURED )).
Now, I found a code after searching around SAMP forums, but not exactly sure where to insert it. Remember, this code doesn't have the animation or the text.
If the player gets shot again, the text will change to (( THIS PLAYER IS DEAD )), and thus, they'll be taken to a hospital.

Код:
new Float: playersHealth;  
GetPlayerHealth(playerid, playersHealth);  
if(playersHealth = 10)
{
    SendClientMessage(playerid, -1, "You are critically injured. You may /acceptdeath or wait for a medic to revive you.");
    LoopingAnim(playerid,"SWEET","Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0); 
}
Now, I understand the code and all, BUT. I'm not sure whether to insert it into OnPlayerTakeDamage or OnPlayerGiveDamage. I would think that it goes into GiveDamage, but anyway. I still need the text displaying above and the animation. Also, you won't be able to get out of this animation until your health is 0.
Talking about a medic reviving you, here's the stock that I have for it.
Код:
if(!(PlayerInfo[playerid][pMember] >= 7 && PlayerInfo[playerid][pMember] <= 8))
Maybe add it to a strcmp command. The script that I use uses strcmp although I'd much prefer it ZCMD, anyways.
Reply
#2

you can use them at OnPlayerUpdate ! it will help you

OnPlayerUpdate

and for your Text you can use <<Create3DTextLabel>>

and if you loop animation he cant get out of that ! also you will need end loop at some point and you can easly use TogglePlayerControllable
or
ApplyAnimation
which automatcly has a fet to loop animation

if you want the exact code tell ill make it for you
Reply
#3

Here's what you could do, I have a similar system in my script.

Код:
new Injured[MAX_PLAYERS];
Код:
public OnPlayerUpdate(playerid)
{
    new Float: playersHealth;  
    GetPlayerHealth(playerid, playersHealth);  
    if(playersHealth <= 10)
   {
       SendClientMessage(playerid, -1, "You are critically injured. You may /acceptdeath or wait for a medic to 
       revive you.");
       LoopingAnim(playerid,"SWEET","Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0); 
       Injured[playerid] = 1;
    }
}
And then:
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if(Injured[damagedid] == 1)
    {
        SetPlayerChatBubble(damagedid, (( THIS PLAYER IS DEAD )), RED, 100.0, 4343344); //or just make a 3d text
     }
}
Just a thought.
Reply
#4

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
you can use them at OnPlayerUpdate ! it will help you

OnPlayerUpdate

and for your Text you can use <<Create3DTextLabel>>

and if you loop animation he cant get out of that ! also you will need end loop at some point and you can easly use TogglePlayerControllable
or
ApplyAnimation
which automatcly has a fet to loop animation

if you want the exact code tell ill make it for you
Mind giving me an example of everything you stated above?
I'm not a scripting professional or anything, I would call my self moderately novice.
I would greatly appreciate this, your credits will be added to the script along with a rep (if you can give me a FULLY working script, or even a proper guidelines to get it working).

The above applies for anybody.
Reply
#5

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Here's what you could do, I have a similar system in my script.

Код:
new Injured[MAX_PLAYERS];
Код:
public OnPlayerUpdate(playerid)
{
    new Float: playersHealth;  
    GetPlayerHealth(playerid, playersHealth);  
    if(playersHealth <= 10)
   {
       SendClientMessage(playerid, -1, "You are critically injured. You may /acceptdeath or wait for a medic to 
       revive you.");
       LoopingAnim(playerid,"SWEET","Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0); 
       Injured[playerid] = 1;
    }
And then:
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if(Injured[damagedid] == 1)
    {
        SetPlayerChatBubble(damagedid, (( THIS PLAYER IS DEAD )), RED, 100.0, 4343344);
     }
}
Just a thought.
ye its allright
but you have to do if(playersHealth <= 10 && playersHealth != 0)
cuse as i know he dont wants that for who got killed and also if hes hp became 0 it will loop in if statement of onplayerupdate
Reply
#6

Quote:

Injured[playerid] = 1;

Is that some sort of enumerator I need to make?

EDIT: NEVER MIND!
Reply
#7

Код:
//Vortex Gaming Realistic Damage Script.
//Credits go to: Arthur Kane and khRamin78 from SA-MP Forums.
#define FILTERSCRIPT

//---Includes---//
#include <a_samp>
#include <streamer>
//--------------//

//----Defines----//
#define WEAPON_BODY_PART_CHEST 3
#define WEAPON_BODY_PART_CROTCH 4
#define WEAPON_BODY_PART_LEFT_ARM 5
#define WEAPON_BODY_PART_RIGHT_ARM 6
#define WEAPON_BODY_PART_LEFT_LEG 7
#define WEAPON_BODY_PART_RIGHT_LEG 8
#define WEAPON_BODY_PART_HEAD 9
//---------------//

new Injured[MAX_PLAYERS];

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("VORTEX GAMING REALISTIC DAMAGE SYSTEM LOADED");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	print("\n--------------------------------------");
	print("VORTEX GAMING REALISTIC DAMAGE SYSTEM UNLOADED");
	print("--------------------------------------\n");
	return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
	new Float:HP;
	new Float:Armour;
	if(!IsPlayerConnected(playerid)) return 0;
    if(!IsPlayerConnected(issuerid)) return 0;
	GetPlayerHealth(playerid, HP);
	GetPlayerArmour(playerid, Armour);
	if(weaponid == 24) SetPlayerHealth(playerid, HP-50);//DesertEagle Deducts HP
	if(weaponid == 24) SetPlayerArmour(playerid, Armour-50);//DesertEagle Deducts Armour/Kevlar
    if(weaponid == 22) SetPlayerHealth(playerid, HP-50);//Colt45 Deducts HP
	if(weaponid == 22) SetPlayerArmour(playerid, Armour-50);//Colt45 Deducts Armour/Kevlar
    if(weaponid == 32) SetPlayerHealth(playerid, HP-10);//Tec9 Dedcuts HP
	if(weaponid == 32) SetPlayerArmour(playerid, Armour-10);//Tec9 Deducts Armour/Kevlar
    if(weaponid == 28) SetPlayerHealth(playerid, HP-10);//Uzi Deducts HP
    if(weaponid == 28) SetPlayerArmour(playerid, Armour-10);//Uzi Deducts Armour/Kevlar
    if(weaponid == 23) SetPlayerHealth(playerid, HP-50);//Silenced Colt
	if(weaponid == 23) SetPlayerArmour(playerid, Armour-50);//Silenced Colt
    if(weaponid == 31) SetPlayerHealth(playerid, HP-35);//M4
	if(weaponid == 31) SetPlayerArmour(playerid, Armour-35);//M4
    if(weaponid == 30) SetPlayerHealth(playerid, HP-40);//AK
	if(weaponid == 30) SetPlayerArmour(playerid, Armour-40);//AK
    if(weaponid == 29) SetPlayerHealth(playerid, HP-18);//MP5
	if(weaponid == 29) SetPlayerArmour(playerid, Armour-18);//MP5
    if(weaponid == 34) SetPlayerHealth(playerid, HP-300);//SniperRifle
	if(weaponid == 34) SetPlayerArmour(playerid, Armour-300);//SniperRifle
    if(weaponid == 33) SetPlayerHealth(playerid, HP-35);//Country Rifle
	if(weaponid == 33) SetPlayerArmour(playerid, Armour-35);//Country Rifle
    if(weaponid == 25) SetPlayerArmour(playerid, Armour-100);//12 Guage Pump Action Remington Shotgun
	if(weaponid == 25) SetPlayerHealth(playerid, HP-100);//12 Guage Pump Action Remington Shotgun
    if(weaponid == 27) SetPlayerArmour(playerid, Armour-70);//SPAZ-12
	if(weaponid == 27) SetPlayerHealth(playerid, HP-70);//SPAZ-12
	return 1;
}

public OnPlayerUpdate(playerid)
{
    new Float: playersHealth;
    GetPlayerHealth(playerid, playersHealth);
    if(playersHealth <= 10 && playersHealth= 0)
	{
       SendClientMessage(playerid, -1, "You are critically injured. You may /acceptdeath or wait for a medic to ressussatate you.");
       PlayAnimation(playerid,"SWEET","Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0);
       Injured[playerid] = 1;
    }
}

public OnPlayerGiveDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
	if(!IsPlayerConnected(playerid)) return 0;
    if(!IsPlayerConnected(issuerid)) return 0;
    if(issuerid != INVALID_PLAYER_ID && bodypart == 9 )
    {
        SetPlayerHealth(playerid, 10.0);
		SetPlayerArmour(playerid, 0.0);
    }
    if(Injured[damagedid] == 1)
    {
        SetPlayerChatBubble(damagedid, (( THIS PLAYER IS INJURED )), RED, 100.0, 4343344); //or just make a 3d text
	}
    return 1;
}
This is the current code that I have, and I get these errors.
Quote:

C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : warning 211: possibly unintended assignment
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : error 022: must be lvalue (non-constant)
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : warning 215: expression has no effect
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : error 001: expected token: ";", but found ")"
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : error 029: invalid expression, assumed zero
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : fatal error 107: too many error messages on one line

If anybody can make this EXACTLY how I wanted it to be, with all the little systems, you will be repped.
The "OnPlayerTakeDamage" part works fine, ignore that, I'm concentrating on the Health Detection/Injury System.

Quote:

Now, I understand the code and all, BUT. I'm not sure whether to insert it into OnPlayerTakeDamage or OnPlayerGiveDamage. I would think that it goes into GiveDamage, but anyway. I still need the text displaying above and the animation. Also, you won't be able to get out of this animation until your health is 0.
Talking about a medic reviving you, here's the stock that I have for it.
Код:
if(!(PlayerInfo[playerid][pMember] >= 7 && PlayerInfo[playerid][pMember] <= 8))
Maybe add it to a strcmp command. The script that I use uses strcmp although I'd much prefer it ZCMD, anyways.

Reply
#8

In my opinion, making a system like this based on health blows. I would just try something with death in general. Here are examples from my working script:

Код:
enum PlayerStatistics
{
    IsDead,
    Dead,
}
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    Player[playerid][LastWorld] = GetPlayerVirtualWorld(playerid);
    Player[playerid][LastInterior] = GetPlayerInterior(playerid);

    Player[playerid][LastX] = x;  //saves players position for spawning
    Player[playerid][LastY] = y; 
    Player[playerid][LastZ] = z;

    Player[playerid][IsDead] = 1;
}
Код:
public OnPlayerSpawn(playerid)
{
     if(Player[playerid][IsDead] == 1)
     {
          SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
 	  SetPlayerCameraPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
 	  SetPlayerInterior(playerid, Player[playerid][LastInterior]);
 	  SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]);

          format(string, sizeof(string), "(( Has been brutally wounded, /damages %d for more info. ))", playerid);
  	  SetPlayerChatBubble(playerid, string, ADM, 30.0, 600000); 
 
          // bunch of other shit, anims & etc 
     }
}
Код:
public OnPlayerUpdate(playerid)
{
    if(Player[playerid][IsDead] == 1)
    {
         ApplyAnimation(playerid, // ur anim
    }
}
You don't have to add TogglePlayerControllable on spawn while dead because having this under OnPlayerUpdate will just repeat the anim and they can't get up but still move their camera.

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
     if(Player[damagedid][IsDead] == 1) 
     {
	TogglePlayerControllable(damagedid, false);
	Player[damagedid][IsDead] = 0;
	Player[damagedid][Dead] = 1;
        SetPlayerChatBubble(damagedid, "(( PLAYER IS DEAD ))", ADM, 30.0, 1220001);
     }
}
Just my opinion & a base for you to start if you'd like.
Reply
#9

Quote:

C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : warning 211: possibly unintended assignment
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : error 022: must be lvalue (non-constant)
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : warning 215: expression has no effect
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : error 001: expected token: ";", but found ")"
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : error 029: invalid expression, assumed zero
C:\Users\Lex-PC\Desktop\CGRP\filterscripts\DamageInjurySystem.p wn(77) : fatal error 107: too many error messages on one line

line 77 = if(playersHealth <= 10 && playersHealth= 0)

You forgot the space.

Change it to != 0
Reply
#10

@Arthur Kane, Looks great, I'll give it a try.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)