[Ayuda] No repetir comando por X tiempo
#1

Hola gente, como se hace para que este NPC efectue la animacion una sola vez y que no la haga por unos 15 segundos?
pawn Код:
SetTimer("SyncNPC", 500, 1); // Este timer lo necesito en 500 para que me detecte ni bien
                            //este al lado del NPC, que efectue la animacion indediatamente


forward SyncNPC();
public SyncNPC()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
    for(new npc=0; npc<MAX_PLAYERS; npc++)
    {
        if(IsPlayerNPC(npc))
        {
                new Float:Xnpc, Float:Ynpc, Float:Znpc;
                GetPlayerPos(npc, Xnpc, Ynpc, Znpc);
                if(IsPlayerInRangeOfPoint(i, 5.0, Xnpc, Ynpc, Znpc))
                {
                    new npcname[MAX_PLAYER_NAME];
                    GetPlayerName(npc, npcname, sizeof(npcname));
                    if(!strcmp(npcname, "Army1", true))
                    {
                        TogglePlayerControllable(npc, 1);
                        ApplyAnimation(npc, "PED", "IDLE_chat", 4.1, 0, 1, 1, 1, 1, 1);
                    }
                }
        }
    }
    }
    }
}



Agregado: Sabia que lo habia visto por algun lado pero no recordaba.. La solucion estaba a unos 5 posts abajo de este.. Disculpen - Solucionado

pawn Код:
forward SyncNPC();
public SyncNPC()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            for(new npc=0; npc<MAX_PLAYERS; npc++)
                {
                    if(IsPlayerNPC(npc))
                        {
                             new Float:Xnpc, Float:Ynpc, Float:Znpc;
                             GetPlayerPos(npc, Xnpc, Ynpc, Znpc);
                             if(IsPlayerInRangeOfPoint(i, 5.0, Xnpc, Ynpc, Znpc))
                                {
                                    new npcname[MAX_PLAYER_NAME];
                                    GetPlayerName(npc, npcname, sizeof(npcname));
                                    if(!strcmp(npcname, "Army1", true))
                                    {
                                        if(GetTickCount() - GetPVarInt(npc, "AnimCheck") < 15000)
                                        {
                                            return 1;
                                        }
                                        else
                                        {
                                            TogglePlayerControllable(npc, 1);
                                            ApplyAnimation(npc, "PED", "IDLE_chat", 4.1, 0, 1, 1, 1, 1, 1);
                                            SetPVarInt(npc, "AnimCheck", GetTickCount() );
                                            return 1;
                                        }
                                    }
                                 }
                        }
                }
         }
    }
    return 1;
}
Reply
#2

Prefiero usar gettime XD
Reply
#3

No crees que hacer 250 mil repeticiones es algo exagerado?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)