SA-MP Forums Archive
Issue with making player loosing health over time by 10 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Issue with making player loosing health over time by 10 (/showthread.php?tid=401685)



Issue with making player loosing health over time by 10 - tuuker - 23.12.2012

pawn Код:
if(UserStats[playerid][Hunger] == 0) {
            for(new i = 1; i <= 1; i++) {
                new Float:GetHealth,Float:HealthAnswer,Float:pHealth;
                GetHealth = GetPlayerHealth(playerid,pHealth);
                HealthAnswer = GetHealth -= 10;
                SetPlayerHealth(playerid,HealthAnswer);
                SendClientMessage(playerid,COLOR_RED,"You are loosing health, you need to eat something!");
            }
        }
Seems kinda logic to me but for some reason it sets player health to 0.
First off I'm giving GetHealth variable an value GetPlayerHealth so i can get player health and subtract it by 10.
Later on I'm setting player health what's equal to HealthAnswer, so it should be from player health subtract 10 and subtract that from current player health. Still it sets player health to 0 once this Timer is called.


Re: Issue with making player loosing health over time by 10 - Randy More - 23.12.2012

All you want is to make the player lose 10 points of his health?

pawn Код:
if(UserStats[playerid][Hunger] == 0) {
            for(new i = 1; i <= 1; i++) {
                new Float:pHealth;
                GetPlayerHealth(playerid, pHealth);
                SetPlayerHealth(playerid, pHealth-10);
                SendClientMessage(playerid,COLOR_RED,"You are loosing health, you need to eat something!");
            }
}



Re: Issue with making player loosing health over time by 10 - Vince - 23.12.2012

What's the point of this totally useless loop?


Re: Issue with making player loosing health over time by 10 - tuuker - 23.12.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
What's the point of this totally useless loop?
You haven't seen whole script it's just very small piece of it. It has its reasons.


Re: Issue with making player loosing health over time by 10 - MP2 - 23.12.2012

It doesn't have any reason. It's pointless.


Re: Issue with making player loosing health over time by 10 - tuuker - 23.12.2012

Okay thanks, timer i made before wasn't returning after first call its function so i had to make loop for it so every time timer got called it ran this loop 1 time to start my function but i re made it and works perfectly fine.