Hola gente
#1

Hola quisiera saber como puedo hacer romdom point

usando
Quote:

SetPlayerCheckpoint

vale al inicio del fs estarб el cp en una cierta post se activara un timer y harб que se cambie de posiciуn y asн sucesivamente como hacerlo.

Ojo no quiero hacer un modo de juego asi como SetPlayerRaceCheckpoint

si no que abra 2 equiтs y lucharan por tener el mayor tiempo posible en ese cp y cuando acabe el timer tengan que ir a apoderarse del otro cp y asi
Reply
#2

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimer("CambiarLugar", 5000, 1);
return 1;
}

forward CambiarLugar(playerid);
public CambiarLugar(playerid)
{
    new RandomCheckpoint = random(7); // El nъmero 7 es la cantidad de Checkpoint's random.
        switch(RandomCheckpoint )
        {
            case 0: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
            case 1: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
            case 2: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
            case 3: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
            case 4: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
            case 5: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
            case 6: SetPlayerCheckpoint(playerid, PosZ, PosY, PosZ);
        }
return 1;
}
Algo asн?.
Reply
#3

Si algo asн no es lo preciso pero me dio una idea +rep
Reply
#4

Colocar ese timer en OnPlayerSpawn harб que se cree cada vez que un jugador spawnee, causarб muchos problemas y lentitud del servidor.

pawn Код:
#include <a_samp>

#define checkpointCambiar 60000 //Milisegundos que cambiarб de posiciуn el checkpoint
#define checkpointTamano 10.0 //Tamaсo de los checkpoints
new Float:checkpointPos[][3] =
{

};
new checkpointTiempo[2]; // 0 = uso de SetTimer; 1 = tiempo faltante
new checkpointID; //Checkpoint actual
forward checkpointCallback();
#define checkpointFaltante() checkpointTiempo[1] //Obtener el tiempo que falta para cambiar el checkpoint
stock checkpointInicio()
{
    //Cambiar de posiciуn un checkpoint
   
    //Obtener un checkpoint al azar
    checkpointID = random(sizeof(checkpointPos));
   
    //Mostramos el nuevo checkpoint a todos los jugadores
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
        SetPlayerCheckpoint(playerid, checkpointPos[checkpointID][0], checkpointPos[checkpointID][1], checkpointPos[checkpointID][2], checkpointTamano);

    //Establecemos el tiempo que falta para que cambie de posiciуn el checkpoint
    checkpointTiempo[1] = checkpointCambiar/1000;

    //Hacemos correr el timer para verificar si ya es tiempo de cambiar de posiciуn el checkpoint
    KillTimer(checkpointTiempo[0]);
    checkpointTiempo[0] = SetTimer("checkpointCallback", 1000, true);
   
    return 1;
}

public OnGameModeInit()
{
    //Iniciar el sistema
    checkpointInicio();
   
    return 1;
}

public OnPlayerConnect(playerid)
{
    //Mostramos el checkpoint actual
    SetPlayerCheckpoint(playerid, checkpointPos[checkpointID][0], checkpointPos[checkpointID][1], checkpointPos[checkpointID][2], checkpointTamano);

    return 1;
}

public checkpointCallback()
{
    //Restamos 1 segundo al tiempo faltante
    checkpointTiempo[1]--;
   
    if(checkpointTiempo[1] <= 0)
    {
        //Llegу a cero el contador de tiempo
       
        //Cambiar el checkpoint de lugar
        checkpointInicio();
    }
   
    return 1;
}
Ahн una forma mas entretenida de hacerlo.

La variable que contiene las posiciones de los checkpoints es.


pawn Код:
new Float:checkpointPos[][3] =
{

};
Para agregar checkpoints solo debes agregar las posiciones Y, X y Z con el formato {X, Y, Z}.

pawn Код:
native checkpointInicio(); //Cambia la posiciуn del checkpoint
native checkpointFaltante(); //Obtiene el tiempo faltante para que se cambie nuevamente
Definidos importantes.
pawn Код:
#define checkpointCambiar 60000 //Milisegundos que demorarб en cambiar de posiciуn el checkpoint
#define checkpointTamano 10.0 //Tamaсo de los checkpoints
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)