Can someone help me?
#1

Hello I have this BASIC anti health hack.

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

forward Hacking();

public OnPlayerUpdate(playerid)
{
    new Float:fHealth;

    GetPlayerHealth(playerid, fHealth);

    if(fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
    {
        // Player health has changed since the last update -> server, so obviously thats the thing updated.
        // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

        if(fHealth > GetPVarFloat(playerid, "faPlayerHealth"))
        {
             SetTimer("Hacking", 2000, false);
             SendClientMessageToAll(0xDEEE20FF, "TEST");
        }
        else
        {
            /* He has lost health! */
        }

        SetPVarFloat(playerid, "faPlayerHealth", fHealth);
    }
}
It works perfectly but I hate that when someone spawns I get the message, What can I do?
Reply
#2

make a variable to check if the players spawned.
Reply
#3

Thats why im asking help cause I dont know how to make those things, I dont know how to use variables or timers, please help me.
Reply
#4

Use the OnPlayerSpawn callback and set their pvar to their health (which by default will be 100)
pawn Код:
public OnPlayerSpawn( playerid )
{
   SetPVarFloat( playerid, "faPlayerHealth", 100.0 );
   return 1;
}
Reply
#5

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

forward Hacking();

public OnPlayerUpdate(playerid)
{
    if(!IsPlayerSpawned(playerid)) return true;

    new Float:fHealth;

    GetPlayerHealth(playerid, fHealth);

    if(fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
    {
        // Player health has changed since the last update -> server, so obviously thats the thing updated.
        // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

        if(fHealth > GetPVarFloat(playerid, "faPlayerHealth"))
        {
             SetTimer("Hacking", 2000, false);
             SendClientMessageToAll(0xDEEE20FF, "TEST");
        }
        else
        {
            /* He has lost health! */
        }

        SetPVarFloat(playerid, "faPlayerHealth", fHealth);
    }
}

forward IsPlayerSpawned(playerid);
public IsPlayerSpawned(playerid)
{
    switch(GetPlayerState(playerid)) { case 1,2,3,8: return true; }
    return false;
}
Reply
#6

Any of those solve my script.

Grim's Script:
When player died it sent the message about 100 times.

iPLEOMAX's Script:
When I load the script and Kill myself I get about 7 times the message.

Please help.
Reply
#7

Hmm.. Try Removing '8' from this case:
pawn Код:
case 1,2,3: return true;
else, there should be a mistake from your part.
You can contact me through PM if you want.
Reply
#8

Still not working, Please someone help me
Reply
#9

pawn Код:
stock bool:IsSpawned(playerid)
{
    new pstate = GetPlayerState(playerid);
    if((pstate >= PLAYER_STATE_ONFOOT && pstate <= PLAYER_STATE_ENTER_VEHICLE_PASSENGER) || pstate == PLAYER_STATE_SPAWNED) return true;
    return false;
}
Checks if your spawned without variables. This is what I use.

Whats the point anyway of using player variables? They're un-efficient! Read ******'s post...

pawn Код:
new Float:Health[MAX_PLAYERS char];

new Float:HP; GetPlayerHealth(playerid, HP);
if(HP > Health{playerid}) { Health{playerid} = HP; }
I can't write code inside this tiny chatbox :S
Reply
#10

Ok, Lorec, Please add me to MSN:
alexobandocastellanos@hotmail.com
Help me there with my scripts and I will pay you, Add me now cause its 1:04am.
Reply
#11

No, I don't want to be paid for such things like this. If you're requesting help someone will eventually help you. Be patient.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)