Why doesn't this work?
#1

Was messing around trying to make a working bleeding script so that when a players health is lower than 45 they will gradually lose health. No errors in the script but when I went into the game and went under 45 health nothing happend.

This is like my first time scripting PAWN so I don't know what's wrong with it. I may be adding a whole heap of shit that isn't necassary so please correct me where I went wrong and such.

Код:
#include <a_samp>
#if defined FILTERSCRIPT
#define COLOR_RED 0xAA3333AA

new Injured[MAX_PLAYERS];

public OnFilterScriptInit()
{
	SetTimer("Bleeding",25000,1); // Bleeding every 25 seconds
	return 1;
}

forward Injured(playerid);
public Injured(playerid)
{
	if(health <= 45)
	{
	Injured[playerid]=1
	}
	return 1;
}

forward Bleeding(playerid);
public Bleeding(playerid)
{
	if Injured[playerid]=1
	{
	new Float:health;
	GetPlayerHealth(playerid, health);
	SetPlayerHealth(playerid, health-10)
	{
	else if Injured[playerid]=0
	}
 }
	return 1;
}

forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
	new Float:health;
	GetPlayerHealth(playerid, health);
	{
	if(health <= 45)
	{
	Injured[playerid]=1
	{
	else if(health >= 45)
	{
	Injured[playerid]=0
	}
   }
  }
 }
	return 1;
}

#endif
Thanks in advance.
Reply
#2

Have fun with Injured people

pawn Код:
#include <a_samp>
#define COLOR_RED 0xAA3333AA

new Injured[MAX_PLAYERS];
forward Bleeding(playerid);
forward InjuredCheck(playerid);

public OnFilterScriptInit()
{
    SetTimer("Bleeding",25000,1); // Bleeding every 25 seconds
    SetTimer("InjuredCheck",24000,1); //Check every 24 second if the player is injured..
    return 1;
}


public InjuredCheck(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
   
    if(health < 46)
    {
    Injured[playerid]=1;
    }
    else
    {
    if(health > 46)
    {
    Injured[playerid]=0;
    }
    }
    return 1;
}

public Bleeding(playerid)
{
    if (Injured[playerid] == 1)
    {
    SetPlayerHealth(playerid,-10);
    }
    return 1;
}
Reply
#3

Thanks, appreciate it.
Reply
#4

Quote:
Originally Posted by VonKnox
Посмотреть сообщение
Thanks, appreciate it.
Finally i've thing about it a little, and the only way to work exactly (Remove 10points of HP every 25 seconds, if the player have life <= 45 is this one:

pawn Код:
#include <a_samp>
#define COLOR_RED 0xAA3333AA

forward InjuredCheck(playerid);

public OnFilterScriptInit()
{
    SetTimer("InjuredCheck",25000,1); //Check every 25 second if the player is injured and make him bleed..
    return 1;
}

public InjuredCheck(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
   
    if(health < 46)
    {
    GivePlayerHealth(playerid,-10);
    }
    return 1;
}

//GivePlayerHealth Fuction (thanks to aircombat)
stock GivePlayerHealth(playerid,Float:Health)
{
new Float:health; GetPlayerHealth(playerid,health);
SetPlayerHealth(playerid,health+Health);
}
So try this for the final result.
Reply
#5

Thanks again!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)