Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //System Hungry By David Sean
- #include <a_samp>
- //Hungry Systems
- #define FILTERSCRIPT
- //Includes
- #include <a_samp>
- #undef MAX_PLAYERS //
- #define MAX_PLAYERS 50 //Change this to your player slot amount
- #define N2E_TIME 600000//Edit this value to change the timer, now = 10 mins
- #define LOOSING_HP 21 //The HP the player will lose You can set it |
- #define COLOR_YELLOW 0xDABB3EAA
- //Forwards
- forward NeedToEat(playerid);
- //Arrays
- new FirstSpawn[MAX_PLAYERS];
- new Float:CurHealth[MAX_PLAYERS];
- new Text:HealthBar[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- for(new i; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- OnPlayerConnect(i);
- }
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new i; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- TextDrawDestroy(HealthBar[i]);
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- HealthBar[playerid] = TextDrawCreate(549.000000,52.000000,"..........");
- TextDrawAlignment(HealthBar[playerid],1);
- TextDrawBackgroundColor(HealthBar[playerid],0x00ff00ff);
- TextDrawFont(HealthBar[playerid],3);
- TextDrawLetterSize(HealthBar[playerid],0.569999,2.549999);
- TextDrawColor(HealthBar[playerid],0x00ff0033);
- TextDrawSetOutline(HealthBar[playerid],1);
- TextDrawSetProportional(HealthBar[playerid],1);
- TextDrawSetShadow(HealthBar[playerid],1);
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- TextDrawDestroy(HealthBar[playerid]);
- return 1;
- }
- public OnPlayerDeath(playerid)
- {
- TextDrawHideForPlayer(playerid,HealthBar[playerid]);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawSetString(HealthBar[playerid],"..........");
- TextDrawShowForPlayer(playerid,HealthBar[playerid]);
- FirstSpawn[playerid] += 1;
- new Float:health;
- GetPlayerHealth(playerid, health);
- CurHealth[playerid] = health;
- if(FirstSpawn[playerid] == 1) SetTimerEx("Hungry",N2E_TIME,1,"i",playerid);
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- new Float:Health;
- GetPlayerHealth(playerid,Health);
- if(Health >= 90)
- {
- TextDrawSetString(HealthBar[playerid],"..........");
- return 1;
- }
- if(Health >= 80)
- {
- TextDrawSetString(HealthBar[playerid],".........");
- return 1;
- }
- if(Health >= 70)
- {
- TextDrawSetString(HealthBar[playerid],"........");
- return 1;
- }
- if(Health >= 60)
- {
- TextDrawSetString(HealthBar[playerid],".......");
- return 1;
- }
- if(Health >= 50)
- {
- TextDrawSetString(HealthBar[playerid],"......");
- return 1;
- }
- if(Health >= 40)
- {
- TextDrawSetString(HealthBar[playerid],".....");
- return 1;
- }
- if(Health >= 30)
- {
- TextDrawSetString(HealthBar[playerid],"....");
- return 1;
- }
- if(Health >= 20)
- {
- TextDrawSetString(HealthBar[playerid],"...");
- return 1;
- }
- if(Health >= 10)
- {
- TextDrawSetString(HealthBar[playerid],"..");
- return 1;
- }
- if(Health > 0)
- {
- TextDrawSetString(HealthBar[playerid],".");
- return 1;
- }
- return 1;
- }
- //========================================================================
- public NeedToEat(playerid)
- {
- new Float:health;
- GetPlayerHealth(playerid, health);
- if(CurHealth[playerid] >= health)
- {
- SendClientMessage(playerid,COLOR_YELLOW,"You is start to Hungry, You need to eat");
- SetPlayerHealth(playerid,health-LOOSING_HP);
- CurHealth[playerid] = health;
- }
- else
- {
- CurHealth[playerid] = health;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment