open.mp forum
[Pawn] Help - Split MySQL - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Help - Split MySQL (/showthread.php?tid=1330)



Help - Split MySQL - wearLy - 2020-11-10

Everything goes well, except in the vehicle and accessory loops.







Code:
[color=#24292e][size=x-small][font=SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace]// MySQL:

g_MysqlRaceCheck[playerid];



// create orm instance and register all needed variables

new ORM: ormid = PlayerInfo[playerid][ORM_ID] = orm_create("player", mySQL_Server);



orm_addvar_int(ormid, PlayerInfo[playerid][pID], "id");

orm_addvar_string(ormid, PlayerName[playerid], MAX_PLAYER_NAME, "nome");

orm_addvar_string(ormid, PlayerInfo[playerid][pKey], 65, "senha");

orm_addvar_int(ormid, PlayerInfo[playerid][pLevel], "level");

orm_addvar_int(ormid, PlayerInfo[playerid][pExp], "respeitos");

orm_addvar_int(ormid, PlayerInfo[playerid][pConnectTime], "horas_jogadas");

orm_addvar_int(ormid, PlayerInfo[playerid][pCash], "dinheiro");

orm_addvar_int(ormid, PlayerInfo[playerid][pConta], "dinheiro_banco");

orm_addvar_int(ormid, PlayerInfo[playerid][pOuros], "ouros");

orm_addvar_int(ormid, PlayerInfo[playerid][pCashVip], "cash");

orm_addvar_int(ormid, PlayerInfo[playerid][pKills], "assassinatos");

orm_addvar_int(ormid, PlayerInfo[playerid][pDeaths], "mortes");

orm_addvar_int(ormid, PlayerInfo[playerid][pSkin], "skin");

orm_addvar_int(ormid, PlayerInfo[playerid][pPayDay], "timer_payday");

orm_addvar_int(ormid, PlayerInfo[playerid][pPegouVIP], "vip_pegou");



new string_save[355];

new string_read[18][60];

new string[50];

for(new carro; carro < MAX_PLAYER_CARROS; carro)

{

// Veiculo informa??es

format(string, sizeof string, "veiculo_%d", carro);

orm_addvar_string(ormid, string_save, sizeof (string_save), string);



split(string_save, string_read, '|');



PlayerConce[playerid][carro][conce_valid]? = strval(string_read[0]);

PlayerConce[playerid][carro][conce_model]? = strval(string_read[1]);

PlayerConce[playerid][carro][conce_pos][0] = floatstr(string_read[2]);

PlayerConce[playerid][carro][conce_pos][1] = floatstr(string_read[3]);

PlayerConce[playerid][carro][conce_pos][2] = floatstr(string_read[4]);

PlayerConce[playerid][carro][conce_pos][3] = floatstr(string_read[5]);

PlayerConce[playerid][carro][conce_health] = floatstr(string_read[6]);

PlayerConce[playerid][carro][conce_color][0] = strval(string_read[7]);

PlayerConce[playerid][carro][conce_color][1] = strval(string_read[8]);

PlayerConce[playerid][carro][conce_preco] = strval(string_read[9]);

PlayerConce[playerid][carro][conce_gasolina] = strval(string_read[10]);

PlayerConce[playerid][carro][conce_estacionado] = strval(string_read[11]);

PlayerConce[playerid][carro][conce_seguro] = strval(string_read[12]);

PlayerConce[playerid][carro][conce_alarme]? = strval(string_read[13]);

PlayerConce[playerid][carro][conce_date] = strval(string_read[14]);

PlayerConce[playerid][carro][conce_despesas] = strval(string_read[15]);

format(PlayerConce[playerid][carro][conce_placa], 25, string_read[16]);

format(PlayerConce[playerid][carro][conce_textol], 75, string_read[17]);



// Tunning

format(string, sizeof string, "tune_%d", carro);

orm_addvar_string(ormid, string_save, 258, string);



split(string_save, string_read, '|');



for(new component; component != 15; component) {

PlayerConce[playerid][carro][conce_tune][component] = strval(string_read[component]);

}

}

for(new index; index != MAX_PLAYER_ATTACHED_OBJECTS; index)

{

// Acessorios Informa??es

format(string, sizeof string, "itens_%d", index);

orm_addvar_string(ormid, string_save, sizeof(string_save), string);



split(string_save, string_read, '|');



format(acessorioInfo[playerid][index][acessorioNome], 75, string_read[1]);

acessorioInfo[playerid][index][acessorioValid]? = strval(string_read[0]);

acessorioInfo[playerid][index][acessorioModelo] = strval(string_read[2]);

acessorioInfo[playerid][index][acessorioBone] = strval(string_read[3]);

// Coordenadas

acessorioInfo[playerid][index][acessorioPos][0] = floatstr(string_read[4]);

acessorioInfo[playerid][index][acessorioPos][1] = floatstr(string_read[5]);

acessorioInfo[playerid][index][acessorioPos][2] = floatstr(string_read[6]);

// Rota??o

acessorioInfo[playerid][index][acessorioRot][0] = floatstr(string_read[7]);

acessorioInfo[playerid][index][acessorioRot][1] = floatstr(string_read[8]);

acessorioInfo[playerid][index][acessorioRot][2] = floatstr(string_read[9]);

// Tamanho

acessorioInfo[playerid][index][acessorioTam][0] = floatstr(string_read[10]);

acessorioInfo[playerid][index][acessorioTam][1] = floatstr(string_read[11]);

acessorioInfo[playerid][index][acessorioTam][2] = floatstr(string_read[12]);

}



orm_setkey(ormid, "nome");



// tell the orm system to load all data, assign it to our variables and call our callback when ready

orm_load(ormid, "OnPlayerLoginCheck", "dd", playerid, g_MysqlRaceCheck[playerid]);[/font][/size][/color]