[HELP] Anim on Spawn
#1

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);
}
Reply
#2

Just a NOTE:

OnPlayerSpawn- is when player RESPAWNS

Try to use OnPlayerStateChange
Reply
#3

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?
Reply
#4

Lib is DEALER and anim is DEALER_IDLE_01

EDIT: I don't understand how to fix
Reply
#5

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.
Reply
#6

Thanks, I fixed

Lock
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)