blood.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //Will adjust this later - Fred
  2. //ATM functionality is dizziness with decreased HP as textdraw sprite: blood, didn't work with transparency
  3. //functions
  4. forward ShowBloodForPlayer(playerid, time, Float:loss);
  5. forward HideBloodForPlayer(playerid);
  6. forward IsPlayerBleeding(playerid);
  7. //callbacks
  8. forward OnPlayerBleeding(playerid, Float:loss);
  9. static timer[MAX_PLAYERS];
  10. //Check the status of the player
  11. public IsPlayerBleeding(playerid) {
  12. if( timer[playerid] ) return true;
  13. else return false;
  14. }
  15. new TimeRemaining[MAX_PLAYERS];
  16. //Enable the hurt effects for player, playerid
  17. public ShowBloodForPlayer(playerid, time, Float:loss) {
  18. TimeRemaining[playerid] = time*2;
  19. new drunktime = time*2*50;
  20. SetPlayerDrunkLevel(playerid, 2000 + drunktime );
  21. timer[playerid] = SetTimerEx("OnPlayerBleeding", 500, true, "if", playerid, loss);
  22. SetPlayerTime(playerid, 22, 0);
  23. SetPlayerWeather(playerid, 202);
  24. return 1;
  25. }
  26. //What to do when the player is under hurting effects
  27. public OnPlayerBleeding(playerid, Float:loss) {
  28. if( TimeRemaining[playerid] <= 0 || !IsPlayerConnected(playerid) ) {
  29. HideBloodForPlayer(playerid);
  30. RemovePlayerFire(playerid);
  31. KillTimer(timer[playerid]);
  32. }
  33. new Float:health;
  34. GetPlayerHealth(playerid, health);
  35. SetPlayerHealth(playerid, health - loss );
  36. TimeRemaining[playerid]--;
  37. return 1;
  38. }
  39. //Stop the hurting effects
  40. public HideBloodForPlayer(playerid) {
  41. SetPlayerWeather(playerid, g_WeatherID);
  42. new hour,minute,second;
  43. new day,month,year;
  44. gettime(hour,minute,second);
  45. getdate(year,month,day);
  46. hour = FixHour(hour);
  47. SetPlayerTime(playerid, hour, minute);
  48. KillTimer(timer[playerid]);
  49. return 1;
  50. }