[Ayuda] їPorque no funciona esto?
#1

Hola, estoy haciendo un sistema de niveles basandome en el score del jugador y la cosa es que hice esto:

pawn Код:
if(GetPlayerScore(playerid) <= 0 ) { JugadorLVL[playerid] = 0; }
    else if(GetPlayerScore(playerid) <= 10) JugadorLVL[playerid] = 1;
    else if(GetPlayerScore(playerid) <= 20) JugadorLVL[playerid] = 2;
    else if(GetPlayerScore(playerid) <= 30) JugadorLVL[playerid] = 4;
dentro de un callback que se actualiza automaticamente.

Lo que intento hacer es que si por ejemplo el jugador tiene un score mayor a 10 le sete el nivel a 1, y si el jugador tiene un score mayor a 20 le setee lvl 4, etc.

Guardo los datos en MySQL y todo se guarda bien ya que he intentado hacerlo asi:

pawn Код:
if(GetPlayerScore(playerid) == 0 ) { JugadorLVL[playerid] = 0; }
    else if(GetPlayerScore(playerid) == 10) JugadorLVL[playerid] = 1;
    else if(GetPlayerScore(playerid) == 20) JugadorLVL[playerid] = 2;
    else if(GetPlayerScore(playerid) == 30) JugadorLVL[playerid] = 4;
Y ahi si se setea y guarda el LVL del jugador.
Pero la cosa es que solo se setearia si el jugador tubiece un score igual a ese, y que el callback se actualice justo al mismo momento que el jugador tenga ese score :S.

Muchas gracias, The Scope
Reply
#2

Asi seria algo mas optimizado

pawn Код:
switch(GetPlayerScore[playerid])
    {
        case 0: JugadorLVL[playerid] = 0;
        case 10: JugadorLVL[playerid] = 1;
        case 20: JugadorLVL[playerid] = 2;
        case 30: JugadorLVL[playerid] = 3;
    }
Reply
#3

Quote:
Originally Posted by Jose_grana
Посмотреть сообщение
Asi seria algo mas optimizado

pawn Код:
switch(GetPlayerScore[playerid])
    {
        case 0: JugadorLVL[playerid] = 0;
        case 10: JugadorLVL[playerid] = 1;
        case 20: JugadorLVL[playerid] = 2;
        case 30: JugadorLVL[playerid] = 3;
    }
Pero si lo hago de esta manera si por ejemplo le seteo el score de un jugador a 31 no le tomara como LVL 3 verdad?

Gracias por responder
Reply
#4

pawn Код:
switch(GetPlayerScore[playerid])
    {
        case 0..9: JugadorLVL[playerid] = 0;
        case 10..19: JugadorLVL[playerid] = 1;
        case 20..29: JugadorLVL[playerid] = 2;
        case 30..39: JugadorLVL[playerid] = 3;
    }
Reply
#5

Quote:
Originally Posted by WCrimson
Посмотреть сообщение
pawn Код:
switch(GetPlayerScore[playerid])
    {
        case 0..9: JugadorLVL[playerid] = 0;
        case 10..19: JugadorLVL[playerid] = 1;
        case 20..29: JugadorLVL[playerid] = 2;
        case 30..39: JugadorLVL[playerid] = 3;
    }
Muchas gracias
Reply
#6

pawn Код:
JugadorLVL[playerid] = GetPlayerScore(playerid)/10;

// Test de que funciona.
main()
{
    new JugadorLVL[MAX_PLAYERS], playerid = 0;
    for(new i = 0; i < 100; i++)
    {
        JugadorLVL[playerid] = i/10;
        printf("%i", JugadorLVL[playerid]);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)