SA-MP Forums Archive
A little problem again... - 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: A little problem again... (/showthread.php?tid=313876)



A little problem again... - Da' J' - 27.01.2012

Ok, so it's the same code as before, but a different problem.

None of the commands ain't working. /getup OR /helpup. Also, it only allows you to go in auto-crack once, but after that is done, and you go again under 25HP, nothing happens. Not even the animation.

The script:
pawn Код:
#include <a_samp>

#define FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Auto-crack...");
    print("--------------------------------------\n");
    return 1;
}



public OnFilterScriptExit()
{
    return 1;
}

    enum crack2
    {
            bool: is_cracked,
            timer,
            c_down,
            bool:c_isover,
            Float:health
    };

    new crack[MAX_PLAYERS][crack2];

    forward Crack_Timer(playerid);
    forward Count_Down(playerid);

    public OnPlayerSpawn(playerid)
    {
            crack[playerid][is_cracked] = false;
            crack[playerid][c_isover] = false;
            crack[playerid][timer] = SetTimerEx("Crack_Timer",1500,true,"i",playerid);
            return 1;
    }

    public Crack_Timer(playerid)
    {
            GetPlayerHealth(playerid,crack[playerid][health]);
            if( (crack[playerid][health] <= 25) && (crack[playerid][is_cracked] == false) )
            {
                    crack[playerid][is_cracked] = true;
                    ApplyAnimation(playerid,"PED","KO_spin_L",2.8,0,1,1,1,0);
                    TogglePlayerControllable(playerid,false);
                    crack[playerid][c_down] = SetTimerEx("Count_Down", 5 * 60 * 1000, false, "i", playerid);
            }
            return 1;
    }

    public Count_Down(playerid)
    {
            if(crack[playerid][is_cracked] == true) {
            crack[playerid][c_isover] = true;
            KillTimer(crack[playerid][timer]);
            }
            return 1;
    }

    PlayerToPlayer(playerid,toplayerid)
    {
            new Float:pos[2][3];
            GetPlayerPos(playerid,pos[0][0],pos[0][1],pos[0][2]);
            GetPlayerPos(toplayerid,pos[1][0],pos[1][1],pos[1][2]);
            pos[0][0] -= pos[1][0];
            pos[0][1] -= pos[1][1];
            pos[0][2] -= pos[1][2];
            return floatround( floatsqroot( (floatpower(pos[0][0],2) + floatpower(pos[0][1],2) + floatpower(pos[0][2],2) ) ), floatround_round);
    }

    public OnPlayerCommandText(playerid, cmdtext[])
    {
            if(!strcmp(cmdtext,"/getup",true))
            {
                if( (crack[playerid][is_cracked] == true) && (crack[playerid][c_isover] == true))
                {
                    SendClientMessage(playerid, -1, "You got up!");
                    crack[playerid][is_cracked] = false;
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
                    TogglePlayerControllable(playerid,true);
                    KillTimer(crack[playerid][timer]);
                    KillTimer(crack[playerid][c_down]);
                    }
                return 1;
            }
            if(!strcmp(cmdtext,"/helpup",true,9))
            {
                if(!cmdtext[8]) SendClientMessage(playerid,-1,"USAGE: /helpup [ID]");
                else if (PlayerToPlayer(playerid,cmdtext[9]) >= 5) SendClientMessage(playerid,-1,"Player too far!");
                    else if( (crack[cmdtext[9]][is_cracked] == true) && (cmdtext[9] != playerid))
                    {
                        ApplyAnimation(playerid,"BOMBER","BOM_Plant",2.6,1,1,1,0,6800);
                        crack[cmdtext[9]][is_cracked] = false;
                        crack[cmdtext[9]][c_isover] = false;
                        KillTimer(crack[cmdtext[9]][timer]);
                        KillTimer(crack[cmdtext[9]][c_down]);
                        SetPlayerSpecialAction(cmdtext[9],SPECIAL_ACTION_NONE);
                    }
                return 1;
            }
            return 0;
}



Re: A little problem again... - TheArcher - 27.01.2012

Try to cut the code inside the commands and put them on OnPlayerUpdate so then set your HP to 25 or less and see if the code really work.


Re: A little problem again... - Da' J' - 27.01.2012

Like, how...? What you mean?


Re: A little problem again... - Da' J' - 28.01.2012

*Cough*