SA-MP Forums Archive
Auto Crack - 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: Auto Crack (/showthread.php?tid=394228)



Auto Crack - sanplayer - 21.11.2012

Hello SA-MP

I have put this piece of code in my script, But In my head it's saying this is wrong, I'm forgetfull at the moment and I forgot how I would make this work.

Here is the code:

pawn Код:
new Float:health;
    if(health >= 10)
    {
        new string[128];
        GetPlayerHealth(playerid, health);
        ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
        SendClientMessageEx(playerid, COLOR_GREEN, "Your health was detected at 10%, You have automatically been put into cracked");
        format(string, sizeof(string), "* %s has fell to the floor in pain!", GetPlayerNameEx(playerid));
        ProxDetector(30.0, giveplayerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        format(string, sizeof(string), "* Groans (( %s ))", GetPlayerNameEx(playerid));
        ProxDetector(30.0, giveplayerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
I have put this under "OnPlayerUpdate(playerid)"


Re: Auto Crack - sanplayer - 21.11.2012

Help?


AW: Auto Crack - Skimmer - 21.11.2012

Put the function
pawn Код:
GetPlayerHealth(playerid, health);
above if-query


Re: Auto Crack - ikkentim - 21.11.2012

you are showing the following code
Код:
1.new Float:health;
2.    if(health >= 10)
3.    {
4.        new string[128];
5.        GetPlayerHealth(playerid, health);
6.
7.    }
At line 1 you are initalizing the variable 'health'. The value will be automatically set to 0.00.
At line 2 you are checking if 'health' is higher or equal to 10. This will always be false, since 'health' is 0.00.
At line 5 you are receiving the players health and saving it in 'health'. This is however inside the if statement. so this won't work.

What you will need to do is to put line 5 between line 1 and 2.