SA-MP Forums Archive
[AYUDA]Rejas automaticas - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [AYUDA]Rejas automaticas (/showthread.php?tid=230957)



[AYUDA]Rejas automaticas - murdoxix - 24.02.2011

Les cuento, yo tenia una reja de L.S.P.D. que se abrнa con comando (/go) y cerraba sola a los 7 segundos, pero encontrй un tutorial para hacerla automбtica (abre cuando te acercas y cierra cuando te alejas) pero a veces funciona perfecto y a veces no :/, osea aveces abre a veces no. No se por que :S, les dejo el cуdigo.
pawn Код:
#include <a_samp>
#define FILTERSCRIPT
new Puerta;
forward PuertaCheck();
//=============================================================//
public OnFilterScriptInit()
{
    SetTimer("PuertaCheck", 1000, 1);
    Puerta =  CreateObject(971,1589.053344,-1638.123168,14.122960,0.000000,0.000000,180);
    return 1;
}
//=============================================================//
public PuertaCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++)
   {
        if(IsPlayerConnected(i)){
            if(IsPlayerInRangeOfPoint(i, 12.5, 1589.053344,-1638.123168,14.122960)){   // Rango del jugador para que abra
                MoveObject(Puerta, 1599.053344,-1638.123168,14.122960, 1.5); //Puerta abierta
            }
            else
         {
                MoveObject(Puerta, 1589.053344,-1638.123168,14.122960, 1.5);    //Puerta Cerrada
            }
        }

    }
}
Bueno, por favor ayъdenme y GRACIAS!


Respuesta: [AYUDA]Rejas automaticas - leaNN! - 24.02.2011

pawn Код:
#include <a_samp>
#define FILTERSCRIPT
new Puerta;
forward PuertaCheck();
forward Cerrar();
//=============================================================//
public OnFilterScriptInit()
{
    SetTimer("PuertaCheck", 1000, 1);
    Puerta =  CreateObject(971,1589.053344,-1638.123168,14.122960,0.000000,0.000000,180);
    return 1;
}
//=============================================================//
public PuertaCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++)
   {
        if(IsPlayerConnected(i)){
            if(IsPlayerInRangeOfPoint(i, 12.5, 1589.053344,-1638.123168,14.122960)){   // Rango del jugador para que abra
                MoveObject(Puerta, 1599.053344,-1638.123168,14.122960, 1.5); //Puerta abierta
                SetTimer("Cerrar", 5000, false);
            }

        }

    }
}

public Cerrar()
{
    MoveObject(Puerta, 1589.053344,-1638.123168,14.122960, 1.5);
    return 1;
}
Prueba asi.


Re: [AYUDA]Rejas automaticas - murdoxix - 24.02.2011

Lo pruebo y te dijo! GRACIAS