Why doesn't this work? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why doesn't this work? (
/showthread.php?tid=177697)
Why doesn't this work? -
VonKnox - 19.09.2010
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.
Re: Why doesn't this work? -
nepstep - 19.09.2010
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;
}
Re: Why doesn't this work? -
VonKnox - 19.09.2010
Thanks, appreciate it.
Re: Why doesn't this work? -
nepstep - 19.09.2010
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.
Re: Why doesn't this work? -
VonKnox - 19.09.2010
Thanks again!