SA-MP Forums Archive
[HELP] Anim on Spawn - 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: [HELP] Anim on Spawn (/showthread.php?tid=515523)



[HELP] Anim on Spawn - vannesenn - 26.05.2014

Hi guys,
I have big problem. When I spawned, spawn animation didn't work, but when I spawned 2nd time, spawn animation work.

How I can fix this problem?


Код:
public SetPlayerSpawn(playerid, bool:stil)
{
	if(stil == false) //UKOLIKO JE NORMALNO IZASO IZ IGRE I NEMA KUCU/RENT
	{
    //  TogglePlayerControllable(playerid, false);

		for(new spawn_id = false; spawn_id < sizeof(Spawn); spawn_id++)
		{
		    printf("Loopano %d puta", spawn_id);
		
	        if(Spawn[spawn_id][sEnble] == false)
	        {
	            new enble = random(4);
	            if(enble == 0 || enble == 2 /*OVO NADALJE KASNIJE OBRISI*/|| enble == 1 || enble == 3) //UKOLIKO JE SERVER ODLUCIO DA CE SPAWNATI IGRACA
	            {
				    SetPlayerPos(playerid, Spawn[spawn_id][sPosX], Spawn[spawn_id][sPosY], Spawn[spawn_id][sPosZ]);
				    SetPlayerFacingAngle(playerid, Spawn[spawn_id][sPosRX]);
				    SetPlayerInterior(playerid, Spawn[spawn_id][sInt]);
		    		SetPlayerVirtualWorld(playerid, Spawn[spawn_id][sVirtualWorld]);
		    		
		    		SetTimerEx("Spawn_Action", 1000, false, "id", playerid, spawn_id);
		    		return 1;
				}
				return 1;
			}
		}
 		return 1;
	}
	return 1;
}

public Spawn_Action(playerid, spawn_id)
{
	SetPlayerCameraPos(playerid, Spawn[spawn_id][sCamPos1X], Spawn[spawn_id][sCamPos1Y], Spawn[spawn_id][sCamPos1Z]);
	SetPlayerCameraLookAt(playerid, Spawn[spawn_id][sCamLAPos1X], Spawn[spawn_id][sCamLAPos1Y], Spawn[spawn_id][sCamLAPos1Z]);

	ApplyAnimation(playerid, Spawn[spawn_id][sAnimLib], Spawn[spawn_id][sAnimName], 4.1, Spawn[spawn_id][sAnimLoop], Spawn[spawn_id][sAnimLockX], Spawn[spawn_id][sAnimLockY], Spawn[spawn_id][sAnimFreeze], Spawn[spawn_id][sAnimTimer], Spawn[spawn_id][sAnimSync]);

    printf("Spawn %d", spawn_id);

	Spawn[spawn_id][sEnble] = true;

	if(Spawn[spawn_id][sCamMove] == true) // UKOLIKO JE POSTAVLJENO DA SE KAMERA MICE
	{
	    SetTimerEx("Spawn_Cam_Ready", Spawn[spawn_id][sCamWaitTime], false, "id", playerid, spawn_id);
	}
	return SetTimerEx("Vracanje_Kamere", Spawn[spawn_id][sAnimTrajanje], false, "id", playerid, spawn_id);
}



Re: [HELP] Anim on Spawn - PawnOX - 26.05.2014

Just a NOTE:

OnPlayerSpawn- is when player RESPAWNS

Try to use OnPlayerStateChange


Re: [HELP] Anim on Spawn - Riddick94 - 26.05.2014

You probably didn't refresh your animation library. Seems like you're having a table in your gamemode, which has animation libraries and names in there.

Simply, when player spawns (or whenever before. I am doing it in Login & Register callback), apply this:
pawn Код:
ApplyAnimation(playerid, "YOUR_ANIMATION_LIBRARY", "null", 0.0, 0, 0, 0, 0, 0);
Do NOT add all the libraries to refresh, because it will lag the player when you will try to. Personal experience:
https://www.youtube.com/watch?v=YaHnXZL7F14

edit://
Quote:
Originally Posted by PawnOX
Посмотреть сообщение
Just a NOTE:

OnPlayerSpawn- is when player RESPAWNS

Try to use OnPlayerStateChange
Since when?


Re: [HELP] Anim on Spawn - vannesenn - 26.05.2014

Lib is DEALER and anim is DEALER_IDLE_01

EDIT: I don't understand how to fix



Re: [HELP] Anim on Spawn - Riddick94 - 26.05.2014

When your function is being called?
pawn Код:
SetPlayerSpawn(playerid, bool:stil)
Is it OnPlayerSpawn callback? If so, simply before that, add the line I have gave you, simply use it like this:
pawn Код:
ApplyAnimation(playerid, "DEALER", "null", 0.0, 0, 0, 0, 0, 0);

// Your function here.
But I wouldn't add refresh of the animations in spawn, unless you make boolean variable that checks if animations has been refreshed already or not. If you have OnPlayerLogin callback or anything like that, add that line in there, it will fix it.


Re: [HELP] Anim on Spawn - vannesenn - 26.05.2014

Thanks, I fixed

Lock