Count always stay 0
#1

why 'Count' always stay 0?

pawn Код:
// Chicken Attack
    if(Chicken[playerid]){
    MSG(playerid,C_GREEN,"[Chicken] ъчу бдцмзд");
    new Count;
    PetAttacked[playerid] = true;
    SetTimerEx("PetAtkDealy", 6000, false, "i", playerid);
    for(new i=0; i<MAX_PLAYERS; i++){
    GetPlayerPos(playerid,pX,pY,pZ);
    if(IsPlayerInRangeOfPoint(i,7,pX,pY,pZ) && i != playerid){
    GivePlayerHealth(i,-70);
    new Float:iHealth;
    GetPlayerHealth(i,iHealth);
    if(iHealth <=0){Count++; DOF2_SetInt(pFile(i),"Deaths",DOF2_GetInt(pFile(i),"Deaths")+1);}
    MSG(i,C_RED,"[Chicken] -70 Health");}}
    DOF2_SetInt(pFile(playerid),"Kills",DOF2_GetInt(pFile(playerid),"Kills")+Count);
    DOF2_SetInt(pFile(playerid),"TotalKills",DOF2_GetInt(pFile(playerid),"TotalKills")+Count);
    format(String,sizeof(String),"Count: %i",Count);
    MSG(playerid,C_RED,String);}
Reply
#2

GetPlayerHealth will return the previous health the player had as it hasn't updated it yet. So get the health, subtract and check:
pawn Код:
new Float:iHealth;
GetPlayerHealth(i,iHealth);
GivePlayerHealth(i,-70.0);
if(iHealth - 70.0 <= 0.0)
{
    Count++;
    DOF2_SetInt(pFile(i),"Deaths",DOF2_GetInt(pFile(i),"Deaths")+1);
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
GetPlayerHealth will return the previous health the player had as it hasn't updated it yet. So get the health, subtract and check:
pawn Код:
new Float:iHealth;
GetPlayerHealth(i,iHealth);
GivePlayerHealth(i,-70.0);
if(iHealth - 70.0 <= 0.0)
{
    Count++;
    DOF2_SetInt(pFile(i),"Deaths",DOF2_GetInt(pFile(i),"Deaths")+1);
}
:* <3
Reply


Forum Jump:


Users browsing this thread: