Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. /*
  2. Namjestiti:
  3. Kada igrac kupi hranu GiveGlad(playerid, glad);
  4.  
  5. Kada ide na wc: GiveWC(playerid, wc);
  6. */
  7.  
  8. #include <a_samp>
  9. #include <zcmd>
  10.  
  11. #define STARTING_GLAD 100
  12. #define STARTING_WC 100
  13.  
  14. forward GladWCCheck(); // Funkcija koja igracim askida 1 glad i 1 wc
  15.  
  16. new PlayerText:GladWCText[MAX_PLAYERS];
  17.  
  18. public OnGameModeInit() {
  19. SetTimer("GladWCCheck", 60000, 1); //Namjetmao timer za svakih minutu da skida igracima po 1 glad i wc
  20. AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  21. return 1; }
  22.  
  23. public OnPlayerConnect(playerid) {
  24. SetPVarInt(playerid, "glad", STARTING_GLAD); // Govori igraecvu glad
  25. SetPVarInt(playerid, "wc", STARTING_WC); // Govori igracev wc
  26. SetPVarInt(playerid, "showinggw", 0); // Govori dali prikazuje text za glad i wc
  27. //--------------------------------------------------
  28. GladWCText[playerid] = CreatePlayerTextDraw(playerid,497,100,"~y~Glad~w~: 100%~n~~y~WC:~w~ 100%");
  29. PlayerTextDrawLetterSize(playerid,GladWCText[playerid],0.349999,1.600000);
  30. PlayerTextDrawAlignment(playerid,GladWCText[playerid],0);
  31. PlayerTextDrawBackgroundColor(playerid,GladWCText[playerid],0x000000FF);
  32. PlayerTextDrawFont(playerid,GladWCText[playerid],2);
  33. PlayerTextDrawUseBox(playerid,GladWCText[playerid],0);
  34. PlayerTextDrawSetOutline(playerid,GladWCText[playerid],1);
  35. PlayerTextDrawSetProportional(playerid,GladWCText[playerid],1);
  36. PlayerTextDrawSetShadow(playerid,GladWCText[playerid],0);
  37. //--------------------------------------------------
  38. return 1; }
  39.  
  40. public OnPlayerSpawn(playerid) {
  41. //Prikazujemo igracu wc/glad text ukoliko mu se ne prikazuje
  42. if(GetPVarInt(playerid, "showinggw") == 0) {
  43. SetPVarInt(playerid, "showinggw", 1);
  44. UpdateGladWCText(playerid);
  45. PlayerTextDrawShow(playerid, GladWCText[playerid]); }
  46. return 1; }
  47.  
  48. public GladWCCheck() {
  49. for(new i=0;i<MAX_PLAYERS;i++) {
  50. if(IsPlayerConnected(i)) {
  51. new Float:phealth; GetPlayerHealth(i, phealth);
  52. GiveGlad(i, -1);
  53. if(GetPVarInt(i, "glad") < 0) { SetPVarInt(i, "glad", 0); SetPlayerHealth(i, phealth-1); }
  54. GiveWC(i, -1);
  55. if(GetPVarInt(i, "wc") < 0) { SetPVarInt(i, "wc", 0); SetPlayerHealth(i, phealth-1); }
  56. UpdateGladWCText(i); } }
  57. return 1; }
  58.  
  59. stock GiveGlad(playerid, glad) {
  60. SetPVarInt(playerid, "glad", GetPVarInt(playerid, "glad")+glad);
  61. return 1; }
  62.  
  63. stock GiveWC(playerid, wc) {
  64. SetPVarInt(playerid, "wc", GetPVarInt(playerid, "wc")+wc);
  65. return 1; }
  66.  
  67. stock UpdateGladWCText(playerid) {
  68. if(!IsPlayerConnected(playerid)) { return 1; }
  69. new str[128];
  70. format(str, sizeof(str), "~y~Glad~w~: %d%~n~~y~WC:~w~ %d%", GetPVarInt(playerid, "glad"), GetPVarInt(playerid, "wc"));
  71. PlayerTextDrawSetString(playerid, GladWCText[playerid], str);
  72. return 1; }
  73. //----------------------------------------------------------------------------//
  74. CMD:test(playerid, params[])
  75. {
  76. if(IsPlayerConnected(playerid))
  77. {
  78. new Float:phealth; GetPlayerHealth(playerid, phealth);
  79. GiveGlad(playerid, +1);
  80. if(GetPVarInt(playerid, "glad") < 0) { SetPVarInt(playerid, "glad", 0); SetPlayerHealth(playerid, phealth-5); }
  81. GiveWC(playerid, +1);
  82. if(GetPVarInt(playerid, "wc") < 0) { SetPVarInt(playerid, "wc", 0); SetPlayerHealth(playerid, phealth-5); }
  83. UpdateGladWCText(playerid);
  84. }
  85. return 1;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement