Portal SAMP
[Ajuda] Concessonaria MySQL não cria o veículo - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Concessonaria MySQL não cria o veículo (/showthread.php?tid=4844)

Páginas: 1 2


Concessonaria MySQL não cria o veículo - Enila182 - 17/07/2024

Olá tudo bem?
Então recentemente fiz a conversão do meu servidor de dini para MySQL
e quando crio veículos ele salva e tals, mas quando reinicio o servidor os veículos não são criado novamente.


OnGameModeInt:
Código:
for(new carror = 0; carror < MAX_CARROS; carror++) {
        CarregarCarros(carror);
    }


Código:
function:CarregarCarros(vehid) {
    VehInfo[vehid][vORM] = orm_create("concessionaria", Conexao);
    VehInfo[vehid][VehID] = vehid;
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordX], "CordX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordY], "CordY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordZ], "CordZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo], "Angulo");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtX], "rtX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtY], "rtY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtZ], "rtZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo1], "Angulo1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Modelo], "Modelo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor1], "Cor1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor2], "Cor2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono], "TDono");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono2], "TDono2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Preco], "Preco");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Destrancado], "Destrancado");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Farol], "Farol");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Capo], "Capo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Motor], "Motor");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Alarme], "Alarme");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Portas], "Portas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][PMalas], "PMalas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Litros], "Litros");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Problema], "Problema");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Contasveiculo], "Contasveiculo");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono], 24, "Dono");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono2], 24, "Dono2");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][vNome], 24, "Nome");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Placa], 24, "Placa");

    orm_setkey(VehInfo[vehid][vORM], "VehID");
    orm_select(VehInfo[vehid][vORM], "GerarV2", "i", indid);
    return 1;
}
    
function:GerarV2(vehid) {
    if(orm_errno(VehInfo[vehid][vORM]) != ERROR_NO_DATA) {
        if(VehInfo[vehid][Modelo] != 0) {
            new carroid;
            SetVehicleNumberPlate(carroid = CreateVehicle(VehInfo[carror][Modelo],
            VehInfo[carror][CordX],
            VehInfo[carror][CordY],
            VehInfo[carror][CordZ],
            VehInfo[carror][Angulo],
            VehInfo[carror][vCor1],
            VehInfo[carror][vCor2], false),
            VehInfo[carror][Placa]);
            VehInfo[carror][Carro] = carroid;
            CarregCar(carroid);
            CarregarCarros(carroid);
            proximocarro++;
        }
    }
}



CMD de criar veículo caso precise:
Código:
CMD:ccar(playerid, params[]) {
    if(IsPlayerAdmin(playerid)|| pAdmin[playerid] == 5) {
        new carid, Float:ang, preco, cor1, cor2, string[200];
        if(sscanf(params, "dddd", carid, preco, cor1, cor2)) return SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite: /ccar [id] [preço] [cor1] [cor2]");
        if(carid >= 400 && carid <= 611) {
            if(IsPlayerInAnyVehicle(playerid)) {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X, Y, Z);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
//                if(VehInfo[proximocarro][VehID] == 0) {
                new Query[400];
                mysql_format(Conexao, Query, sizeof(Query), "INSERT INTO `concessionaria`(`VehID`, `Modelo`, `CordX`, `CordY`, `CordZ`, `Angulo`, `Cor1`, `Cor2`, `Preco`, `rtX`, `rtY`, `rtZ`, `Angulo1`) VALUES ('%d', '%d',     '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", proximocarro, carid, X, Y, Z, ang, cor1, cor2, preco, X, Y, Z, ang);
                mysql_tquery(Conexao, Query);
//                }
                SetTimerEx("CriarVeiculo2", 5000, false, "dffffdd", carid, X, Y, Z, ang, cor1, cor2);
                format(string, sizeof(string), "| INFO | Você colocou um veículo a venda.");
                SendClientMessage(playerid, 0xB0FF30AA, string);
                format(string, sizeof(string), "| INFO | Saia do local onde você colocou o veículo!");
                SendClientMessage(playerid, ERRO_BVR, string);
                return 1;
            } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Você não está em um veículo.");
            return 1;
        } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Veículo inválido!");
        return 1;
    } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Você não tem permissão!");
    return 1;
}



RE: Concessonaria MySQL não cria o veículo - Vel - 17/07/2024

`carror` não deveria ser `vehid` em `GerarV2`?


RE: Concessonaria MySQL não cria o veículo - Enila182 - 17/07/2024

vou testar aqui 1 min

(17/07/2024 21:04)Vel Escreveu: `carror` não deveria ser `vehid` em `GerarV2`?

meu código ficou assim:
Código:
function:CarregarCarros(vehid) {
    VehInfo[vehid][vORM] = orm_create("concessionaria", Conexao);
    VehInfo[vehid][VehID] = vehid;
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordX], "CordX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordY], "CordY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordZ], "CordZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo], "Angulo");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtX], "rtX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtY], "rtY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtZ], "rtZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo1], "Angulo1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Modelo], "Modelo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor1], "Cor1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor2], "Cor2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono], "TDono");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono2], "TDono2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Preco], "Preco");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Destrancado], "Destrancado");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Farol], "Farol");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Capo], "Capo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Motor], "Motor");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Alarme], "Alarme");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Portas], "Portas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][PMalas], "PMalas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Litros], "Litros");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Problema], "Problema");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Contasveiculo], "Contasveiculo");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono], 24, "Dono");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono2], 24, "Dono2");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][vNome], 24, "Nome");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Placa], 24, "Placa");

    orm_setkey(VehInfo[vehid][vORM], "VehID");
    orm_select(VehInfo[vehid][vORM], "GerarV2", "i", vehid);
    return 1;
}
    
function:GerarV2(vehid) {
    if(orm_errno(VehInfo[vehid][vORM]) != ERROR_NO_DATA) {
        if(VehInfo[vehid][Modelo] != 0) {
            new carroid;
            SetVehicleNumberPlate(carroid = CreateVehicle(VehInfo[vehid][Modelo],
            VehInfo[vehid][CordX],
            VehInfo[vehid][CordY],
            VehInfo[vehid][CordZ],
            VehInfo[vehid][Angulo],
            VehInfo[vehid][vCor1],
            VehInfo[vehid][vCor2], false),
            VehInfo[vehid][Placa]);
            VehInfo[vehid][Carro] = carroid;
            CarregCar(vehid);
            CarregarCarros(vehid);
            proximocarro++;
        }
    }
}
mesmo assim não deu certo.


RE: Concessonaria MySQL não cria o veículo - Cifra Modder - 18/07/2024

(17/07/2024 20:05)Enila182 Escreveu: Olá tudo bem?
Então recentemente fiz a conversão do meu servidor de dini para MySQL
e quando crio veículos ele salva e tals, mas quando reinicio o servidor os veículos não são criado novamente.


OnGameModeInt:
Código:
for(new carror = 0; carror < MAX_CARROS; carror++) {
        CarregarCarros(carror);
    }


Código:
function:CarregarCarros(vehid) {
    VehInfo[vehid][vORM] = orm_create("concessionaria", Conexao);
    VehInfo[vehid][VehID] = vehid;
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordX], "CordX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordY], "CordY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordZ], "CordZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo], "Angulo");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtX], "rtX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtY], "rtY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtZ], "rtZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo1], "Angulo1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Modelo], "Modelo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor1], "Cor1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor2], "Cor2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono], "TDono");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono2], "TDono2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Preco], "Preco");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Destrancado], "Destrancado");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Farol], "Farol");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Capo], "Capo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Motor], "Motor");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Alarme], "Alarme");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Portas], "Portas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][PMalas], "PMalas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Litros], "Litros");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Problema], "Problema");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Contasveiculo], "Contasveiculo");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono], 24, "Dono");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono2], 24, "Dono2");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][vNome], 24, "Nome");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Placa], 24, "Placa");

    orm_setkey(VehInfo[vehid][vORM], "VehID");
    orm_select(VehInfo[vehid][vORM], "GerarV2", "i", indid);
    return 1;
}
    
function:GerarV2(vehid) {
    if(orm_errno(VehInfo[vehid][vORM]) != ERROR_NO_DATA) {
        if(VehInfo[vehid][Modelo] != 0) {
            new carroid;
            SetVehicleNumberPlate(carroid = CreateVehicle(VehInfo[carror][Modelo],
            VehInfo[carror][CordX],
            VehInfo[carror][CordY],
            VehInfo[carror][CordZ],
            VehInfo[carror][Angulo],
            VehInfo[carror][vCor1],
            VehInfo[carror][vCor2], false),
            VehInfo[carror][Placa]);
            VehInfo[carror][Carro] = carroid;
            CarregCar(carroid);
            CarregarCarros(carroid);
            proximocarro++;
        }
    }
}



CMD de criar veículo caso precise:
Código:
CMD:ccar(playerid, params[]) {
    if(IsPlayerAdmin(playerid)|| pAdmin[playerid] == 5) {
        new carid, Float:ang, preco, cor1, cor2, string[200];
        if(sscanf(params, "dddd", carid, preco, cor1, cor2)) return SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite: /ccar [id] [preço] [cor1] [cor2]");
        if(carid >= 400 && carid <= 611) {
            if(IsPlayerInAnyVehicle(playerid)) {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X, Y, Z);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
//                if(VehInfo[proximocarro][VehID] == 0) {
                new Query[400];
                mysql_format(Conexao, Query, sizeof(Query), "INSERT INTO `concessionaria`(`VehID`, `Modelo`, `CordX`, `CordY`, `CordZ`, `Angulo`, `Cor1`, `Cor2`, `Preco`, `rtX`, `rtY`, `rtZ`, `Angulo1`) VALUES ('%d', '%d',     '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", proximocarro, carid, X, Y, Z, ang, cor1, cor2, preco, X, Y, Z, ang);
                mysql_tquery(Conexao, Query);
//                }
                SetTimerEx("CriarVeiculo2", 5000, false, "dffffdd", carid, X, Y, Z, ang, cor1, cor2);
                format(string, sizeof(string), "| INFO | Você colocou um veículo a venda.");
                SendClientMessage(playerid, 0xB0FF30AA, string);
                format(string, sizeof(string), "| INFO | Saia do local onde você colocou o veículo!");
                SendClientMessage(playerid, ERRO_BVR, string);
                return 1;
            } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Você não está em um veículo.");
            return 1;
        } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Veículo inválido!");
        return 1;
    } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Você não tem permissão!");
    return 1;
}

Verifique se "orm_errno(VehInfo[vehid][vORM])" está retornando "ERROR_NO_DATA"

E compartilhe o "CriarVeiculo2" aqui se for possível.


RE: Concessonaria MySQL não cria o veículo - Enila182 - 18/07/2024

(18/07/2024 01:35)Cifra Modder Escreveu: Verifique se "orm_errno(VehInfo[vehid][vORM])" está retornando "ERROR_NO_DATA"

E compartilhe o "CriarVeiculo2" aqui se for possível.

Código:
public CriarVeiculo2(m, Float:x, Float:y, Float:z, Float:r, c, d)
{
    VehInfo[proximocarro][Carro] = CreateVehicle(m, x, y, z, r, c, d, -1, 1);
    proximocarro ++;
    return 1;
}

Sobre isso
Citar:Verifique se "orm_errno(VehInfo[vehid][vORM]) está retornando "ERROR_NO_DATA
como verifica?


RE: Concessonaria MySQL não cria o veículo - Enila182 - 18/07/2024

Boa tarde, eu pago no pix pra quem conseguir resolver! rs


RE: Concessonaria MySQL não cria o veículo - Enila182 - 20/07/2024

Alguém?


RE: Concessonaria MySQL não cria o veículo - strelo - 21/07/2024

Primeiro, vamos verificar se estamos carregando corretamente os dados dos veículos do banco de dados no OnGameModeInit e recriando os veículos em função disso. Vou ajustar seu código para garantir que os dados sejam carregados e os veículos recriados corretamente.

Aqui está o código atualizado:

OnGameModeInit:

Código PHP:
public OnGameModeInit() {
    for (new carror 0carror MAX_CARROScarror++) {
        CarregarCarros(carror);
    }
    return 1;



Função CarregarCarros:

Código PHP:
function CarregarCarros(vehid) {
    VehInfo[vehid][vORM] = orm_create("concessionaria"Conexao);
    VehInfo[vehid][VehID] = vehid;
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordX], "CordX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordY], "CordY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordZ], "CordZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo], "Angulo");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtX], "rtX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtY], "rtY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtZ], "rtZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo1], "Angulo1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Modelo], "Modelo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor1], "Cor1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor2], "Cor2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono], "TDono");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono2], "TDono2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Preco], "Preco");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Destrancado], "Destrancado");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Farol], "Farol");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Capo], "Capo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Motor], "Motor");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Alarme], "Alarme");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Portas], "Portas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][PMalas], "PMalas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Litros], "Litros");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Problema], "Problema");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Contasveiculo], "Contasveiculo");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono], 24"Dono");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono2], 24"Dono2");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][vNome], 24"Nome");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Placa], 24"Placa");

    orm_setkey(VehInfo[vehid][vORM], "VehID");
    orm_select(VehInfo[vehid][vORM], "GerarV2""i"vehid);
    return 1;



Função GerarV2:

Código PHP:
function GerarV2(vehid) {
    if (orm_errno(VehInfo[vehid][vORM]) != ERROR_NO_DATA) {
        if (VehInfo[vehid][Modelo] != 0) {
            new carroid;
            carroid CreateVehicle(VehInfo[vehid][Modelo],
                                    VehInfo[vehid][CordX],
                                    VehInfo[vehid][CordY],
                                    VehInfo[vehid][CordZ],
                                    VehInfo[vehid][Angulo],
                                    VehInfo[vehid][vCor1],
                                    VehInfo[vehid][vCor2],
                                    false);
            SetVehicleNumberPlate(carroidVehInfo[vehid][Placa]);
            VehInfo[vehid][Carro] = carroid;
        }
    }



CMD de criar veículo:
Código PHP:
CMD:ccar(playeridparams[]) {
    if (IsPlayerAdmin(playerid) || pAdmin[playerid] == 5) {
        new caridFloat:angprecocor1cor2string[200];
        if (sscanf(params"dddd"caridprecocor1cor2)) {
            return SendClientMessage(playeridERRO_BVR"| ERRO | Digite: /ccar [id] [preço] [cor1] [cor2]");
        }
        if (carid >= 400 && carid <= 611) {
            if (IsPlayerInAnyVehicle(playerid)) {
                new Float:XFloat:YFloat:Z;
                GetPlayerPos(playeridXYZ);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
                
                
new Query[400];
                mysql_format(ConexaoQuerysizeof(Query), "INSERT INTO `concessionaria`(`VehID`, `Modelo`, `CordX`, `CordY`, `CordZ`, `Angulo`, `Cor1`, `Cor2`, `Preco`, `rtX`, `rtY`, `rtZ`, `Angulo1`) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%f', '%f', '%f', '%f')"proximocarrocaridXYZangcor1cor2precoXYZang);
                mysql_tquery(ConexaoQuery);
                
                SetTimerEx
("CriarVeiculo2"5000false"dffffdd"caridXYZangcor1cor2);
                
                format
(stringsizeof(string), "| INFO | Você colocou um veículo à venda.");
                SendClientMessage(playerid0xB0FF30AAstring);
                format(stringsizeof(string), "| INFO | Saia do local onde você colocou o veículo!");
                SendClientMessage(playeridERRO_BVRstring);
                return 1;
            } else {
                SendClientMessage(playeridERRO_BVR"| ERRO | Você não está em um veículo.");
            }
        } else {
            SendClientMessage(playeridERRO_BVR"| ERRO | Veículo inválido!");
        }
    } else {
        SendClientMessage(playeridERRO_BVR"| ERRO | Você não tem permissão!");
    }
    return 1;


Certifique-se de que a função CarregarCarros esteja corretamente chamando GerarV2 com o ID correto do veículo, e que o ORM esteja corretamente configurado para carregar os dados do banco de dados. Se continuar tendo problemas, verifique se os dados estão realmente sendo salvos no banco de dados e se o ORM está funcionando corretamente.


RE: Concessonaria MySQL não cria o veículo - Enila182 - 21/07/2024

(21/07/2024 14:25)strelo Escreveu: Primeiro, vamos verificar se estamos carregando corretamente os dados dos veículos do banco de dados no OnGameModeInit e recriando os veículos em função disso. Vou ajustar seu código para garantir que os dados sejam carregados e os veículos recriados corretamente.

Aqui está o código atualizado:

OnGameModeInit:

Código PHP:
public OnGameModeInit() {
    for (new carror 0carror MAX_CARROScarror++) {
        CarregarCarros(carror);
    }
    return 1;



Função CarregarCarros:

Código PHP:
function CarregarCarros(vehid) {
    VehInfo[vehid][vORM] = orm_create("concessionaria"Conexao);
    VehInfo[vehid][VehID] = vehid;
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordX], "CordX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordY], "CordY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordZ], "CordZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo], "Angulo");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtX], "rtX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtY], "rtY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtZ], "rtZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo1], "Angulo1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Modelo], "Modelo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor1], "Cor1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor2], "Cor2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono], "TDono");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono2], "TDono2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Preco], "Preco");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Destrancado], "Destrancado");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Farol], "Farol");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Capo], "Capo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Motor], "Motor");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Alarme], "Alarme");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Portas], "Portas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][PMalas], "PMalas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Litros], "Litros");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Problema], "Problema");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Contasveiculo], "Contasveiculo");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono], 24"Dono");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono2], 24"Dono2");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][vNome], 24"Nome");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Placa], 24"Placa");

    orm_setkey(VehInfo[vehid][vORM], "VehID");
    orm_select(VehInfo[vehid][vORM], "GerarV2""i"vehid);
    return 1;



Função GerarV2:

Código PHP:
function GerarV2(vehid) {
    if (orm_errno(VehInfo[vehid][vORM]) != ERROR_NO_DATA) {
        if (VehInfo[vehid][Modelo] != 0) {
            new carroid;
            carroid CreateVehicle(VehInfo[vehid][Modelo],
                                    VehInfo[vehid][CordX],
                                    VehInfo[vehid][CordY],
                                    VehInfo[vehid][CordZ],
                                    VehInfo[vehid][Angulo],
                                    VehInfo[vehid][vCor1],
                                    VehInfo[vehid][vCor2],
                                    false);
            SetVehicleNumberPlate(carroidVehInfo[vehid][Placa]);
            VehInfo[vehid][Carro] = carroid;
        }
    }



CMD de criar veículo:
Código PHP:
CMD:ccar(playeridparams[]) {
    if (IsPlayerAdmin(playerid) || pAdmin[playerid] == 5) {
        new caridFloat:angprecocor1cor2string[200];
        if (sscanf(params"dddd"caridprecocor1cor2)) {
            return SendClientMessage(playeridERRO_BVR"| ERRO | Digite: /ccar [id] [preço] [cor1] [cor2]");
        }
        if (carid >= 400 && carid <= 611) {
            if (IsPlayerInAnyVehicle(playerid)) {
                new Float:XFloat:YFloat:Z;
                GetPlayerPos(playeridXYZ);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
                
                
new Query[400];
                mysql_format(ConexaoQuerysizeof(Query), "INSERT INTO `concessionaria`(`VehID`, `Modelo`, `CordX`, `CordY`, `CordZ`, `Angulo`, `Cor1`, `Cor2`, `Preco`, `rtX`, `rtY`, `rtZ`, `Angulo1`) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%f', '%f', '%f', '%f')"proximocarrocaridXYZangcor1cor2precoXYZang);
                mysql_tquery(ConexaoQuery);
                
                SetTimerEx
("CriarVeiculo2"5000false"dffffdd"caridXYZangcor1cor2);
                
                format
(stringsizeof(string), "| INFO | Você colocou um veículo à venda.");
                SendClientMessage(playerid0xB0FF30AAstring);
                format(stringsizeof(string), "| INFO | Saia do local onde você colocou o veículo!");
                SendClientMessage(playeridERRO_BVRstring);
                return 1;
            } else {
                SendClientMessage(playeridERRO_BVR"| ERRO | Você não está em um veículo.");
            }
        } else {
            SendClientMessage(playeridERRO_BVR"| ERRO | Veículo inválido!");
        }
    } else {
        SendClientMessage(playeridERRO_BVR"| ERRO | Você não tem permissão!");
    }
    return 1;


Certifique-se de que a função CarregarCarros esteja corretamente chamando GerarV2 com o ID correto do veículo, e que o ORM esteja corretamente configurado para carregar os dados do banco de dados. Se continuar tendo problemas, verifique se os dados estão realmente sendo salvos no banco de dados e se o ORM está funcionando corretamente.


Olá substitui tudo o que você indicou ai, e continuo tento problemas.

Os dados estão sendo salvo no banco de dados. 
https://imgur.com/a/LLM3oBN

Não sei como verificar o ORM se está funcionando bem. pois eu utilizava dini como salvamento e eu paguei pro um programador passar pra MySQL e esse programador por falta de tempo não está mexendo mais com scripts.

Você não consegue fazer um orçamento sobre isso não? quanto cobra pra corrigur esse problema. Só falta isso pra poder lançar o servidor. e tou tentando consertar faz 10 dias já.


RE: Concessonaria MySQL não cria o veículo - strelo - 21/07/2024

Para verificar se o ORM está funcionando corretamente, você pode adicionar algumas mensagens de debug no código. Por exemplo, logo após a linha orm_select(VehInfo[vehid][vORM], "GerarV2", "i", vehid); na função CarregarCarros, adicione:

Código PHP:
printf("Selecionando veículo ID %d\n"vehid); 


E na função GerarV2, adicione:

Código PHP:
printf("Erro do ORM para veículo ID %d: %d\n"vehidorm_errno(VehInfo[vehid][vORM])); 


Verifique se a função CreateVehicle está realmente criando os veículos e se não há erros nessa função.
Vou adicionar algumas mensagens de debug no código para ajudar a identificar o problema:



Código PHP:
public OnGameModeInit() {
    for (new carror 0carror MAX_CARROScarror++) {
        CarregarCarros(carror);
    }
    return 1;


function 
CarregarCarros(vehid) {
    VehInfo[vehid][vORM] = orm_create("concessionaria"Conexao);
    VehInfo[vehid][VehID] = vehid;
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordX], "CordX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordY], "CordY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][CordZ], "CordZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo], "Angulo");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtX], "rtX");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtY], "rtY");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][rtZ], "rtZ");
    orm_addvar_float(VehInfo[vehid][vORM], VehInfo[vehid][Angulo1], "Angulo1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Modelo], "Modelo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor1], "Cor1");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][vCor2], "Cor2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono], "TDono");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][TDono2], "TDono2");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Preco], "Preco");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Destrancado], "Destrancado");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Farol], "Farol");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Capo], "Capo");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Motor], "Motor");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Alarme], "Alarme");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Portas], "Portas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][PMalas], "PMalas");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Litros], "Litros");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Problema], "Problema");
    orm_addvar_int(VehInfo[vehid][vORM], VehInfo[vehid][Contasveiculo], "Contasveiculo");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono], 24"Dono");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Dono2], 24"Dono2");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][vNome], 24"Nome");
    orm_addvar_string(VehInfo[vehid][vORM], VehInfo[vehid][Placa], 24"Placa");

    orm_setkey(VehInfo[vehid][vORM], "VehID");
    orm_select(VehInfo[vehid][vORM], "GerarV2""i"vehid);

    printf("Selecionando veículo ID %d\n"vehid);

    return 1;


function 
GerarV2(vehid) {
    if (orm_errno(VehInfo[vehid][vORM]) != ERROR_NO_DATA) {
        printf("Erro do ORM para veículo ID %d: %d\n"vehidorm_errno(VehInfo[vehid][vORM]));
        if (VehInfo[vehid][Modelo] != 0) {
            new carroid;
            carroid CreateVehicle(VehInfo[vehid][Modelo],
                                    VehInfo[vehid][CordX],
                                    VehInfo[vehid][CordY],
                                    VehInfo[vehid][CordZ],
                                    VehInfo[vehid][Angulo],
                                    VehInfo[vehid][vCor1],
                                    VehInfo[vehid][vCor2],
                                    false);
            SetVehicleNumberPlate(carroidVehInfo[vehid][Placa]);
            VehInfo[vehid][Carro] = carroid;
            printf("Veículo ID %d criado com sucesso. Modelo: %d\n"vehidVehInfo[vehid][Modelo]);
        }
    } else {
        printf("Nenhum dado encontrado para o veículo ID %d\n"vehid);
    }



Com essas mensagens de debug, você poderá verificar no console se os dados estão sendo carregados corretamente e se os veículos estão sendo criados.