Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //Made By Bert
- #define COLOR_GREEN 0x00B000FF
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xFF4646FF
- new N2ETimer[MAX_PLAYERS];
- new IsHungry[MAX_PLAYERS];
- new Float:Health[MAX_PLAYERS];
- new Float:tmpHealth[MAX_PLAYERS];
- new N2ECount[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Hunger & need to eat filterscript ");
- print("--------------------------------------\n");
- SetTimer("TakeHealthDown", 2500, 1);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- KillTimer(N2ETimer[playerid]);
- IsHungry[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- N2ETimer[playerid] = SetTimerEx("NeedsToEat", 300000, 0, "i", playerid);
- IsHungry[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- KillTimer(N2ETimer[playerid]);
- IsHungry[playerid] = 0;
- return 1;
- }
- forward NeedsToEat(playerid);
- public NeedsToEat(playerid)
- {
- SendClientMessage(playerid, COLOR_ORANGE, "* You're starting to feel hungry!");
- IsHungry[playerid] = 1;
- N2ECount[playerid] = 0;
- GetPlayerHealth(playerid, Health[playerid]);
- if(Health[playerid] == 100.0)
- {
- Health[playerid] = 99.0;
- SetPlayerHealth(playerid, 99.0);
- }
- SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
- }
- forward NeedsToEat2(playerid);
- public NeedsToEat2(playerid)
- {
- if(IsHungry[playerid])
- {
- if(N2ECount[playerid] >= 0 && N2ECount[playerid] < 60)
- {
- GetPlayerHealth(playerid, tmpHealth[playerid]);
- if(tmpHealth[playerid] > Health[playerid])
- {
- SendClientMessage(playerid, COLOR_GREEN, "* You satisfied your tummy by eating or drinking!");
- IsHungry[playerid] = 0;
- N2ETimer[playerid] = SetTimerEx("NeedsToEat", 300000, 0, "i", playerid);
- }
- else
- {
- SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
- N2ECount[playerid] ++;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_ORANGE, "* You're starting to feel really week, hurry to get some food before you pass out!");
- IsHungry[playerid] = 2;
- }
- }
- }
- forward TakeHealthDown();
- public TakeHealthDown()
- {
- for(new i = 0; i < MAX_PLAYERS; i ++)
- {
- if(IsPlayerConnected(i) && IsHungry[i] == 2)
- {
- GetPlayerHealth(i, tmpHealth[i]);
- if(tmpHealth[i] > Health[i])
- {
- SendClientMessage(i, COLOR_GREEN, "* You satisfied your tummy by eating or drinking!");
- IsHungry[i] = 0;
- N2ETimer[i] = SetTimerEx("NeedsToEat", 300000, 0, "i", i);
- }
- GetPlayerHealth(i, Health[i]);
- SetPlayerHealth(i, tmpHealth[i] -1);
- if(tmpHealth[i] < 5)
- {
- SendClientMessage(i, COLOR_RED, "* You're starving from hunger! Run in terror!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment