[FilterScript] Health Regeneration (COD Style)!
#1

Okay so as I was strolling along the forum today I came across a pretty fun idea for TDM,DM, and all other servers related to COD(or not). Okay so, I had this idea of making the screen fade bloody red for a few short milliseconds and after, the player's health get regenerated in 5 seconds(define in script) by +10(define in script). It's as close as you can get to COD because of the way the screen fades in and then back out.

Don't flame in this topic as I have been away for quite some time and thought It'd be a nice idea to make this for people wanting a better Experience with COD-Based servers(or similar). It's a very simple script, so please, bare with me.

Code:
#include <a_samp>
#include <j_fader_v2>

#define healthSecs (5) // Health will gain every 5 seconds. Change it if you want!
#define healthGain (10.0) // How much health will the player get after he waited the desired seconds.

new fadeTimer[MAX_PLAYERS], healTimer[MAX_PLAYERS];

public OnFilterScriptInit()
{
  FadeInit();
  return 1;
}

public OnFilterScriptExit()
{
  FadeExit();
  return 1;
}

public OnPlayerConnect(playerid)
{
    FadePlayerConnect(playerid);
    fadeTimer[playerid] = SetTimerEx("healthFade", 100, true, "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
  FadePlayerDisconnect(playerid);
  return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    KillTimer(fadeTimer[playerid]);
    return 1;
}

// Somewhere in your script (not in a callback / function)
forward healthFade(playerid);
public healthFade(playerid)
{
    new Float: pHealth;
    GetPlayerHealth(playerid, pHealth);
    if (pHealth <= 20)
    {
        FadeColorForPlayer(playerid, 255, 0, 0, 0, 255, 0, 0, 255, 25, 1000);
        healTimer[playerid] = SetTimerEx("healUser", healthGain * 1000, true, "i", playerid);
    }
    if (pHealth > 20)
    {
        KillTimer(fadeTimer[playerid]);
        KillTimer(healTimer[playerid] );
    }
    return 1;
}

// Somewhere in your script (not in a callback / function)
forward healUser(playerid);
public healUser(playerid)
{
    new Float: pHealth;
    GetPlayerHealth(playerid, pHealth);
    SetPlayerHealth(playerid, pHealth + healthGain);
    return 1;
}
You will also need the Screen-Fader FS made by Joe Staff here:
https://sampforum.blast.hk/showthread.php?tid=124091

Note: If you get a "Warning 213: Tag Mismatch", ignore it for now; It will not harm the script.

Please leave any comments or feedback regarding the code. thanks .
Reply
#2

No Pic Or Vid
Reply
#3

Pics!,dude
Reply
#4

Quote:
Originally Posted by misho1
View Post
No Pic Or Vid
I'm working on it.

Quote:
Originally Posted by iWind
View Post
Pics!,dude
I'll be posting the pics/vid up shortly.

Quote:
Originally Posted by Marsigne
View Post
I like the script, very good
Thanks !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)