Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Namjestiti:
- Kada igrac kupi hranu GiveGlad(playerid, glad);
- Kada ide na wc: GiveWC(playerid, wc);
- */
- #include <a_samp>
- #include <zcmd>
- #define STARTING_GLAD 100
- #define STARTING_WC 100
- forward GladWCCheck(); // Funkcija koja igracim askida 1 glad i 1 wc
- new PlayerText:GladWCText[MAX_PLAYERS];
- public OnGameModeInit() {
- SetTimer("GladWCCheck", 60000, 1); //Namjetmao timer za svakih minutu da skida igracima po 1 glad i wc
- AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- return 1; }
- public OnPlayerConnect(playerid) {
- SetPVarInt(playerid, "glad", STARTING_GLAD); // Govori igraecvu glad
- SetPVarInt(playerid, "wc", STARTING_WC); // Govori igracev wc
- SetPVarInt(playerid, "showinggw", 0); // Govori dali prikazuje text za glad i wc
- //--------------------------------------------------
- GladWCText[playerid] = CreatePlayerTextDraw(playerid,497,100,"~y~Glad~w~: 100%~n~~y~WC:~w~ 100%");
- PlayerTextDrawLetterSize(playerid,GladWCText[playerid],0.349999,1.600000);
- PlayerTextDrawAlignment(playerid,GladWCText[playerid],0);
- PlayerTextDrawBackgroundColor(playerid,GladWCText[playerid],0x000000FF);
- PlayerTextDrawFont(playerid,GladWCText[playerid],2);
- PlayerTextDrawUseBox(playerid,GladWCText[playerid],0);
- PlayerTextDrawSetOutline(playerid,GladWCText[playerid],1);
- PlayerTextDrawSetProportional(playerid,GladWCText[playerid],1);
- PlayerTextDrawSetShadow(playerid,GladWCText[playerid],0);
- //--------------------------------------------------
- return 1; }
- public OnPlayerSpawn(playerid) {
- //Prikazujemo igracu wc/glad text ukoliko mu se ne prikazuje
- if(GetPVarInt(playerid, "showinggw") == 0) {
- SetPVarInt(playerid, "showinggw", 1);
- UpdateGladWCText(playerid);
- PlayerTextDrawShow(playerid, GladWCText[playerid]); }
- return 1; }
- public GladWCCheck() {
- for(new i=0;i<MAX_PLAYERS;i++) {
- if(IsPlayerConnected(i)) {
- new Float:phealth; GetPlayerHealth(i, phealth);
- GiveGlad(i, -1);
- if(GetPVarInt(i, "glad") < 0) { SetPVarInt(i, "glad", 0); SetPlayerHealth(i, phealth-1); }
- GiveWC(i, -1);
- if(GetPVarInt(i, "wc") < 0) { SetPVarInt(i, "wc", 0); SetPlayerHealth(i, phealth-1); }
- UpdateGladWCText(i); } }
- return 1; }
- stock GiveGlad(playerid, glad) {
- SetPVarInt(playerid, "glad", GetPVarInt(playerid, "glad")+glad);
- return 1; }
- stock GiveWC(playerid, wc) {
- SetPVarInt(playerid, "wc", GetPVarInt(playerid, "wc")+wc);
- return 1; }
- stock UpdateGladWCText(playerid) {
- if(!IsPlayerConnected(playerid)) { return 1; }
- new str[128];
- format(str, sizeof(str), "~y~Glad~w~: %d%~n~~y~WC:~w~ %d%", GetPVarInt(playerid, "glad"), GetPVarInt(playerid, "wc"));
- PlayerTextDrawSetString(playerid, GladWCText[playerid], str);
- return 1; }
- //----------------------------------------------------------------------------//
- CMD:test(playerid, params[])
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:phealth; GetPlayerHealth(playerid, phealth);
- GiveGlad(playerid, +1);
- if(GetPVarInt(playerid, "glad") < 0) { SetPVarInt(playerid, "glad", 0); SetPlayerHealth(playerid, phealth-5); }
- GiveWC(playerid, +1);
- if(GetPVarInt(playerid, "wc") < 0) { SetPVarInt(playerid, "wc", 0); SetPlayerHealth(playerid, phealth-5); }
- UpdateGladWCText(playerid);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement