Issue with making player loosing health over time by 10
#1

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.
Reply
#2

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!");
            }
}
Reply
#3

What's the point of this totally useless loop?
Reply
#4

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.
Reply
#5

It doesn't have any reason. It's pointless.
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)