SA-MP Forums Archive
Animation freeze - 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: Animation freeze (/showthread.php?tid=586095)



Animation freeze - Denying - 19.08.2015

Hey there,

I will get right to the point.
I have this piece of code:

Код:
public Paralysis(playerid)
{
	if(pInfo[playerid][Paralyzed] == 0)
	{
    	SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" You have drank a bottle of poisoned water, you are paralyzed.");
		SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" The paralysis will wear off in 4 minutes.");

        if(!IsPlayerInAnyVehicle(playerid))
        {
			ApplyAnimation(playerid, "PED", "FLOOR_hit", 4.1, 0, 1, 1, 1, 1, 1);
			ApplyAnimation(playerid, "PED", "FLOOR_hit", 4.1, 0, 1, 1, 1, 1, 1);
		}
		//TogglePlayerControllable(playerid, 0);
		
		pInfo[playerid][Paralyzed] = 1;
		
		SetTimerEx("Paralysis", 240000, false, "i", playerid);
	}
	else
	{
	    pInfo[playerid][Paralyzed] = 0;
	    
	    TogglePlayerControllable(playerid, 1);

	    if(IsPlayerInAnyVehicle(playerid))
	    {
	        new vehID, seatID;

	        vehID = GetPlayerVehicleID(playerid);
	        seatID = GetPlayerVehicleSeat(playerid);
	        
	        ClearAnimations(playerid, 1);
	        
	        PutPlayerInVehicle(playerid, vehID, seatID);
	    }
	    
		ClearAnimations(playerid, 1);
		
		SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" You are slowly regaining feeling all over your body.");
	}

	return 1;
}
Been messing with the code for a while now. I have freeze in ApplyAnimation set to 1 yet the player does not freeze.
It's probably a tiny thing I did wrong, I just never got to use ApplyAnimation before.

I just want it to freeze the player, while on the floor (which is the animation)

Thanks in advance.

Important note: It does reach the ApplyAnimation code. It performs the animation, I just don't freeze.

EDIT: Uploaded the code to pastebin too, it's much cleaner there.

http://pastebin.com/gVadxvAF


Re: Animation freeze - Inn0cent - 19.08.2015

//TogglePlayerControllable(playerid, 0);
Am remove the comments ? "//"


Re: Animation freeze - Denying - 19.08.2015

ApplyAnimation has a freeze parameter. Using TogglePlayerControllable seems to remove the animation and make the player stand in place.

The freeze parameter doesn't seem to work. Is it because it's bugged in general or am I doing something wrong?


Re: Animation freeze - Inn0cent - 19.08.2015

Where you testing it, on foot or in vehicle.


Re: Animation freeze - Denying - 19.08.2015

On foot. As I said, the animation performs, I just don't freeze.


Re: Animation freeze - Threshold - 19.08.2015

pawn Код:
public Paralysis(playerid)
{
    if(pInfo[playerid][Paralyzed] == 0)
    {
        SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" You have drank a bottle of poisoned water, you are paralyzed.");
        SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" The paralysis will wear off in 4 minutes.");

        if(!IsPlayerInAnyVehicle(playerid)) ApplyAnimation(playerid, "PED", "FLOOR_hit", 4.1, 0, 1, 1, 1, 0, 1);

        pInfo[playerid][Paralyzed] = 1;
        SetTimerEx("Paralysis", 240000, false, "i", playerid);
    }
    else if(pInfo[playerid][Paralyzed] == 1)
    {
        pInfo[playerid][Paralyzed] = 0;
        if(IsPlayerInAnyVehicle(playerid))
        {
            ClearAnimations(playerid, 1);
            PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), GetPlayerVehicleSeat(playerid));
        }
        else ClearAnimations(playerid, 1);
        SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" You are slowly regaining feeling all over your body.");
    }
    return 1;
}
You shouldn't need to load the animation twice. For preloading animation libraries, search for the function 'PreloadAnimLib' and apply that under OnPlayerSpawn instead of doing it every time you want to use an animation. As for the issues you're having with the freezing not being applied, it's probably due to the animation being played twice or the timer on the animation being set to 1 millisecond. Try the code I just gave and see if it fixes anything and let me know the results.


Re: Animation freeze - Denying - 19.08.2015

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
public Paralysis(playerid)
{
    if(pInfo[playerid][Paralyzed] == 0)
    {
        SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" You have drank a bottle of poisoned water, you are paralyzed.");
        SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" The paralysis will wear off in 4 minutes.");

        if(!IsPlayerInAnyVehicle(playerid)) ApplyAnimation(playerid, "PED", "FLOOR_hit", 4.1, 0, 1, 1, 1, 0, 1);

        pInfo[playerid][Paralyzed] = 1;
        SetTimerEx("Paralysis", 240000, false, "i", playerid);
    }
    else if(pInfo[playerid][Paralyzed] == 1)
    {
        pInfo[playerid][Paralyzed] = 0;
        if(IsPlayerInAnyVehicle(playerid))
        {
            ClearAnimations(playerid, 1);
            PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), GetPlayerVehicleSeat(playerid));
        }
        else ClearAnimations(playerid, 1);
        SendClientMessage(playerid, COLOR_INFO, "(Info):"INFO" You are slowly regaining feeling all over your body.");
    }
    return 1;
}
You shouldn't need to load the animation twice. For preloading animation libraries, search for the function 'PreloadAnimLib' and apply that under OnPlayerSpawn instead of doing it every time you want to use an animation. As for the issues you're having with the freezing not being applied, it's probably due to the animation being played twice or the timer on the animation being set to 1 millisecond. Try the code I just gave and see if it fixes anything and let me know the results.
It works now. I actually tried messing with the timer, but didn't try to put it as zero since 0 is meant for looping.
Thanks by the way!

And I'm now using PreloadAnimLib. Did not know of its existence.