Ayuda con cons
#1

Estoy haciendo un sistema de usuario para un servidor rol estoy usando orm, resulta que el primer registro lo inserta correctamente y no se por que le coloca el id 0. Entonces, el segundo registro no me lo inserta, lo que me hace creer es que orm_create() retorna el id 0; pero la doc no dice mucho al respecto.. їQue se me esta escapando?

aqui el codigo para ver si ustedes pueden ver en que estoy fallando.. (colocado en orden de ejecucion.)

Код:
public OnPlayerRequestClass(playerid, classid){
    QueryPlayerData(playerid);
    return 1;
}

stock QueryPlayerData(playerid){

    GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
    new ORM:orm_id = Player[playerid][ORM_ID] = orm_create("players");

    orm_addvar_int(orm_id, Player[playerid][ID], "id");
    orm_addvar_string(orm_id, Player[playerid][Name], MAX_PLAYER_NAME, "name");
    orm_addvar_string(orm_id, Player[playerid][Pass], MAX_PASSWORD_LEN, "password");
    orm_addvar_int(orm_id, Player[playerid][Money], "money");
    orm_addvar_int(orm_id, Player[playerid][Skin], "skin");
    orm_addvar_float(orm_id, Player[playerid][PosX], "pos_x");
    orm_addvar_float(orm_id, Player[playerid][PosY], "pos_y");
    orm_addvar_float(orm_id, Player[playerid][PosZ], "pos_z");
    orm_addvar_float(orm_id, Player[playerid][PosA], "pos_a");
    orm_addvar_float(orm_id, Player[playerid][Healt], "healt");
    orm_addvar_float(orm_id, Player[playerid][Armour], "armour");

    orm_setkey(orm_id, "name");
    orm_select(orm_id, "OnLoadPlayerData", "d", playerid);

}

forward OnLoadPlayerData(playerid);
public OnLoadPlayerData(playerid){
    orm_setkey(Player[playerid][ORM_ID], "id");
    switch( orm_errno(Player[playerid][ORM_ID]) ){
        case ERROR_OK:{
            // login
        }
        case ERROR_NO_DATA:{
            ShowRegisterDialog(playerid);
        }
    }
    return 1;
}

stock ShowRegisterDialog(playerid){
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Nuevo", "Info", "registro", "Cancelar");
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    switch(dialogid){
        case DIALOG_LOGIN:{
            if(!response) return Kick(playerid);

        }
        case DIALOG_REGISTER:{
            if(!response) return Kick(playerid);
            if( strlen(inputtext) >= MIN_PASSWORD_LEN ){
                new pass[MAX_PASSWORD_LEN];
                format(pass, MAX_PASSWORD_LEN, "%s", inputtext);

                Player[playerid][Pass] = pass;
                Player[playerid][Skin] = 2;
                Player[playerid][Money] = 1500;
                Player[playerid][Healt] = 100;
                Player[playerid][Armour] = 20;
                Player[playerid][PosX] = 1484.0287;
                Player[playerid][PosY] = -1748.3702;
                Player[playerid][PosZ] = 15.4453;
                Player[playerid][PosA] = 0;

                orm_insert(Player[playerid][ORM_ID], "OnPlayerRegister", "b", playerid);
                
            }else{

            }
        }
    }
    return 1;
}
Reply
#2

Lo solucionй!! tenia mi campo "id" sin el "auto_increment"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)