Problemas con checkpoint's....
#1

buenas a todos, alguien me puede decir por ke no me respunde la funcion cuando estoy en un checkpnoit, y por ke se buguean los sizes(modelo del checkpoint ) de los mismo, osea cuando voy a un checkpoint por primera vez aparece el size (modelo del checkpoint ) correctamente, pero cuando voy a otro se buguean todos y aparecen todos con el mismo size (modelo del checkpoint ) e aparecen correctamente a la vez.

los checkpoint tiene un limite o algo?.

aca un ejemplo de como coloke:

pawn Код:
//Global
    static VariableCP[17];

    //en OnFilterScriptInit
    VariableCP[0]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0);
    VariableCP[1]=CreateDynamicCP(..., 1.0, -1, -1, -1, 3.0);
    VariableCP[2]=CreateDynamicCP(..., 4.0, -1, -1, -1, 3.0);
    VariableCP[3]=CreateDynamicCP(..., 5.0, -1, -1, -1, 3.0);
    VariableCP[4]=CreateDynamicCP(..., 8.0, -1, -1, -1, 3.0);
    VariableCP[5]=CreateDynamicCP(..., 4.0, -1, -1, -1, 3.0);
    VariableCP[6]=CreateDynamicCP(..., 3.0, -1, -1, -1, 3.0);
    VariableCP[7]=CreateDynamicCP(..., 6.0, -1, -1, -1, 3.0);
    VariableCP[8]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[9]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[10]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[11]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[12]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[13]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[14]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[15]=CreateDynamicCP(..., 2.0, -1, -1, -1, 3.0); // ---
    VariableCP[16]=CreateDynamicCP(..., 10.0, -1, -1, -1, 3.0);

    //en OnPlayerKeyStateChange
    if(pressed(KEY_HANDBRAKE) && GetPlayerState(playerid)==PLAYER_STATE_ONFOOT) {
        for(new index=8; index<16; index++) { //Funciona...
            printf("paso bucle Ferfecto: %d", index); //Funciona...
            if(!IsPlayerInDynamicCP(playerid, VariableCP[index])) continue; //Funciona...
            printf("paso !IsPlayerInDynamicCP Ferfecto: %d", index); //Funciona...
            if(IsPlayerInDynamicCP(playerid, VariableCP[index])) { //Aca No pasa y eso ke estoy en Los CP
                printf("paso Funcion: %d", index);
                //FUNCION
            }
        }
    }
Desde ya muchas Gracias.
Saludos.

Reply
#2

La ъltima comprobaciуn no es necesaria.

pawn Код:
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
    //Bucle por todos los posibles jugadores
   
    //Condiciуn: si no esta conectado 'playerid', continue a la siguiente repeticiуn
    if(!IsPlayerConnected(playerid)) continue;
   
    //Aquн en adelante se ejecutarб si 'playerid' esta conectado (la condiciуn anterior)
   
    if(IsPlayerConnected(playerid))
    {
        //Si 'playerid' esta conectado
    }
   
    //Segundo 'if' es innecesario, ya que ese cуdigo solo se ejecutarб si el jugador esta conectado
}
Reply
#3

Quote:
Originally Posted by DesingMyCry
Посмотреть сообщение
La ъltima comprobaciуn no es necesaria.

pawn Код:
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
    //Bucle por todos los posibles jugadores
   
    //Condiciуn: si no esta conectado 'playerid', continue a la siguiente repeticiуn
    if(!IsPlayerConnected(playerid)) continue;
   
    //Aquн en adelante se ejecutarб si 'playerid' esta conectado (la condiciуn anterior)
   
    if(IsPlayerConnected(playerid))
    {
        //Si 'playerid' esta conectado
    }
   
    //Segundo 'if' es innecesario, ya que ese cуdigo solo se ejecutarб si el jugador esta conectado
}
ya lo se lo pongo nada mas por precaucion nada mas no creo .
pero ni sikiera asi responde .
Reply
#4

No tiene lуgica, dices que no funciona como quieres, te dije lo que era y me dices que aun asi no responde pero sin embargo colocas en el cуdigo que antes de eso funciona perfectamente. Cito.

pawn Код:
if(pressed(KEY_HANDBRAKE) && GetPlayerState(playerid)==PLAYER_STATE_ONFOOT) {
        for(new index=8; index<16; index++) {
            if(!IsPlayerInDynamicCP(playerid, VariableCP[index])) continue;

            printf("paso !IsPlayerInDynamicCP Ferfecto: %d", index); //Dices que esta te funciona perfectamente

            if(IsPlayerInDynamicCP(playerid, VariableCP[index])) { //Pero esta no, por lo que esta condiciуn era la del problema
                printf("paso Funcion: %d", index);
                //FUNCION
            }
        }
    }
Reply
#5

Quote:
Originally Posted by DesingMyCry
Посмотреть сообщение
No tiene lуgica, dices que no funciona como quieres, te dije lo que era y me dices que aun asi no responde pero sin embargo colocas en el cуdigo que antes de eso funciona perfectamente. Cito.

pawn Код:
if(pressed(KEY_HANDBRAKE) && GetPlayerState(playerid)==PLAYER_STATE_ONFOOT) {
        for(new index=8; index<16; index++) {
            if(!IsPlayerInDynamicCP(playerid, VariableCP[index])) continue;

            printf("paso !IsPlayerInDynamicCP Ferfecto: %d", index); //Dices que esta te funciona perfectamente

            if(IsPlayerInDynamicCP(playerid, VariableCP[index])) { //Pero esta no, por lo que esta condiciуn era la del problema
                printf("paso Funcion: %d", index);
                //FUNCION
            }
        }
    }
acabo de verificar otra vez y vi mal xD, no pasa el IsPlayerInDynamicCP en el checkpiont fuera al presiona la tecla me sale el printf ke esta debajo del bucle.

Log..

[00:14:27] paso bucle Ferfecto: 8
[00:14:27] paso bucle Ferfecto: 9
[00:14:27] paso bucle Ferfecto: 10
[00:14:27] paso bucle Ferfecto: 11
[00:14:27] paso bucle Ferfecto: 12
[00:14:27] paso bucle Ferfecto: 13
[00:14:27] paso bucle Ferfecto: 14
[00:14:27] paso bucle Ferfecto: 15
Reply
#6

La funciуn "IsPlayerInDynamicCP" no te funciona en ese cуdigo, deberбs crear una propia para comprobar si esta en el checkpoint o nу.
Reply
#7

Quote:
Originally Posted by DesingMyCry
Посмотреть сообщение
La funciуn "IsPlayerInDynamicCP" no te funciona en ese cуdigo, deberбs crear una propia para comprobar si esta en el checkpoint o nу.
orientame un poco porfavor :S .
Reply
#8

Es simplemente crear una variable contenedora para cada jugador que diga el ID del ъltimo checkpoint en el que entrу (sin salir).

pawn Код:
new checkpointID[MAX_PLAYERS];
Esa variable contendrб el ID. Ahora debemos setear la informaciуn cuando se conecta para prevenir bugs.

pawn Код:
public OnPlayerConnected(playerid)
{
    checkpointID[playerid] = -1;
    return 1;
}
Ahora debemos establecer el ID del checkpoint en el que entrу.

pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    checkpointID[playerid] = checkpointid;

    return 1;
}
Si sale del checkpoint se establecerб a ninguno.

pawn Код:
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    checkpointID[playerid] = -1;
    return 1;
}
Y finalmente creamos la funciуn para saber si esta en un checkpoint o nу.

pawn Код:
stock /*bool:*/EstaEnCheckpoint(jugadorid, checkpointid)
{
    return ((checkpointID[jugadorid] == checkpointid)  ? (/*true*/1) : (/*false*/0));
}
O bien puedes hacer la funciуn, directamente una macro (ten en cuenta que las macros funcionan el doble de rбpido que las funciones convencionales).

pawn Код:
#define EstaEnCheckpoint(%0,%1) ((checkpointID[%0] == %1)  ? (/*true*/1) : (/*false*/0))
Reply
#9

Gracias, funciono, mirando otros script ke tenia con el mismo objectivo vi ke me funciono de esa manera, osea obteniendo el id de esa manera .

Muchas Gracias :
Salucionado .
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)