GetPlayerAnimationIndex help
#1

Alright, another noobie question from me! I have this code I found on the wiki:

pawn Код:
forward CheckHealth(playerid);
public CheckHealth(playerid)
{
    new Float:fHealth;
    GetPlayerHealth(playerid, Float:fHealth);
    if(fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
    {

        if(GetPlayerAnimationIndex(playerid) != 1666 && GetTickCount() < (lastupdate[playerid]+2000) && fHealth > GetPVarFloat(playerid, "faPlayerHealth"))
        {
            SendClientMessageToAll(-1, "HACKS");
        }
        else
        {
            //player lost health  && GetPlayerInterior(playerid) == 0
        }
        SetPVarFloat(playerid, "faPlayerHealth", fHealth);
       
    }
    return 1;
}
This part: "if(GetPlayerAnimationIndex(playerid) != 1666" is supposed to check if player has vending machine use animation. But it still proceeds the code, what am I doing wrong? I don't want to remove them machines.
Reply
#2

Hmm, try this:

pawn Код:
forward CheckHealth(playerid);
public CheckHealth(playerid)
{
    new Float:fHealth;
    GetPlayerHealth(playerid, fHealth);
    if(fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
    {
        if(GetPlayerAnimationIndex(playerid) != 1666 && GetTickCount() < (lastupdate[playerid]+2000) && fHealth > GetPVarFloat(playerid, "faPlayerHealth")) return SendClientMessageToAll(-1, "HACKS");
        else
        {
            //player lost health  && GetPlayerInterior(playerid) == 0
        }
        SetPVarFloat(playerid, "faPlayerHealth", fHealth);
    }
  return 1;
}
Also search for ' SetTimerEx("CheckHealth" ' and tell me how fast the timer executes..?
Reply
#3

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
Hmm, try this:

Also search for ' SetTimerEx("CheckHealth" ' and tell me how fast the timer executes..?
It makes the "SetPVarFloat(playerid, "faPlayerHealth", fHealth);" line unreachable and keeps spamming the detection. The timer is 500 ms.

EDIT: I think I found a solution: if(GetPlayerAnimationIndex(playerid) == 1666) return SetPVarFloat(playerid, "faPlayerHealth", 100.0);
EDIT2: No, shit wont work, lol
EDIT3: I removed "SetPVarFloat" line that's supposed to set it from my health and made this CMD for debugging:
Код:
CMD:getvar(playerid, params[])
{
    new string[256];
    format(string, sizeof(string), "var is %f", GetPVarFloat(playerid, "faPlayerHealth"));
    SendClientMessage(playerid, -1, string);
    return 1;
}
And it doesn't get set with "if(GetPlayerAnimationIndex(playerid) == 1666) return SetPVarFloat(playerid, "faPlayerHealth", 100.0);" while it works fine with:
Код:
CMD:setvar(playerid, params[])
{
    new Float:crap;
    crap = 100.0;
    SetPVarFloat(playerid, "faPlayerHealth", crap);
    SendClientMessage(playerid, -1, "var set to 100.0");
    return 1;
}
EDIT4: And THIS worked:
Код:
if(GetPlayerAnimationIndex(playerid))
    {
    	new animlib[32];
        new animname[32];
        new msg[128];
        GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
        if(!strcmp(animname, "VEND_USE", true)) {SetPVarFloat(playerid, "faPlayerHealth", 100.0);}
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)