[Ajuda] HELP SQL
#1

Alguйm poderia me ajudar a fazer esse cуdigo abaixo puxar outra funзгo da tabela cars por favor? a funзгo й carModel, й para falar qual o modelo do carro, eu nгo consegui fazer.
Код:
Dialog:MDCVehicle(playerid, response, listitem, inputtext[])
{
    if (GetFactionType(playerid) != FACTION_POLICE || !IsACruiser(GetPlayerVehicleID(playerid)))
    return 0;

    if(response)
    {
        new plate[64];
        new string[152];
        if(sscanf(inputtext, "s[64]", plate)) return Dialog_Show(playerid, MDCVehicle, DIALOG_STYLE_INPUT, "Mobile Data Computer - Procura de Placa", "PROCURA DE PLACA\n\nInsira a informaзгo da placa:", "Prosseguir", "Cancelar");

        new Query[150];
        mysql_format(g_iHandle, Query, sizeof(Query), "SELECT `character` FROM `characters` WHERE `ID` = (SELECT `carOwner` FROM cars WHERE carPlaca='%s' LIMIT 1)", plate);
        new Cache:handle = mysql_query(g_iHandle, Query);
       	if(cache_get_row_count(g_iHandle)){
        new user[25];
        cache_get_field_content(0, "character", user, g_iHandle);
        cache_delete(handle, g_iHandle);

		format(string, sizeof(string), "RESULTADO DE BUSCA\n\nPlaca do Veнculo: %s\nModelo do Veнculo: %s\nDono do Veнculo: %s", plate,"", user);
  		Dialog_Show(playerid, MDCResult, DIALOG_STYLE_MSGBOX, "Procurar Placa", string, "Cancelar", "");
        } else{
            SendErrorMessage(playerid, "PLACA NГO ENCONTRADA!");
        }
    }
    return 1;
}
REP+ pra quem ajudar.
Reply
#2

Код:
Dialog:MDCVehicle(playerid, response, listitem, inputtext[])
{
    if (GetFactionType(playerid) != FACTION_POLICE || !IsACruiser(GetPlayerVehicleID(playerid)))
    return 0;

    if(response)
    {
        new plate[64];
        new string[152];
        if(sscanf(inputtext, "s[64]", plate)) return Dialog_Show(playerid, MDCVehicle, DIALOG_STYLE_INPUT, "Mobile Data Computer - Procura de Placa", "PROCURA DE PLACA\n\nInsira a informaзгo da placa:", "Prosseguir", "Cancelar");

        new Query[150];
        mysql_format(g_iHandle, Query, sizeof(Query), "SELECT `character` AND `carModel` FROM `characters` WHERE `ID` = (SELECT `carOwner` FROM cars WHERE carPlaca='%s' LIMIT 1)", plate);
        new Cache:handle = mysql_query(g_iHandle, Query);
       	if(cache_get_row_count(g_iHandle)){
        new user[25], cmodel[30];
        cache_get_field_content(0, "character", user, g_iHandle);
		cache_get_field_content(0, "carModel", cmodel, g_iHandle);
        cache_delete(handle, g_iHandle);

		format(string, sizeof(string), "RESULTADO DE BUSCA\n\nPlaca do Veнculo: %s\nModelo do Veнculo: %s\nDono do Veнculo: %s", plate,"", cmodel, user);
  		Dialog_Show(playerid, MDCResult, DIALOG_STYLE_MSGBOX, "Procurar Placa", string, "Cancelar", "");
        } else{
            SendErrorMessage(playerid, "PLACA NГO ENCONTRADA!");
        }
    }
    return 1;
}
Reply
#3

Putz mano, valeu mesmo!
Reply
#4

Sу fiquei com dъvida com relaзгo а ordem dos dados mostrados no diбlogo e se carModel й um valor string ou inteiro... Enfim, qualquer coisa poste aн.
Reply
#5

Entгo.. fui testar o cуdigo agora e toda placa certa que eu digito fala que nгo foi encontrada, sendo que antes de vocк editar o cуdigo ele tava funcionando, mas sem a funзгo 'Dono do Veнculo'.

Й uma string, pois mostra o nome do veнculo.
Reply
#6

Eu fiz 3 alteraзхes apenas e nenhuma influкncia na busca:
Apenas adicionei mais uma tabela;
Criei a variбvel cmodel;
Adicionei a variбvel na funзгo output do diбlogo;

Resumindo, nгo hб interferкncia do comando SQL.

Faзa um debug e imprima no console se a placa estб saindo corretamente.

Caso persista, tente contar os rows com outra funзгo cache:
Substitua cache_get_row_count(g_iHandle)
por cache_num_rows()
Reply
#7

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Caso persista, tente contar os rows com outra funзгo cache:
Substitua cache_get_row_count(g_iHandle)
por cache_num_rows()
Quote:
Originally Posted by a_mysql
#define cache_num_rows cache_get_row_count
(facepalm)

PHP код:
Dialog:MDCVehicle(playeridresponselistiteminputtext[])
{
    if (
GetFactionType(playerid) != FACTION_POLICE || !IsACruiser(GetPlayerVehicleID(playerid)))
    return 
0;
    if(
response)
    {
        new 
plate[64];
        new 
string[152];
        if(
sscanf(inputtext"s[64]"plate)) return Dialog_Show(playeridMDCVehicleDIALOG_STYLE_INPUT"Mobile Data Computer - Procura de Placa""PROCURA DE PLACA\n\nInsira a informaзгo da placa:""Prosseguir""Cancelar");
        new 
Query[150];
        
mysql_format(g_iHandleQuerysizeof(Query), "SELECT `character`, `carModel` FROM `characters`, `cars` WHERE `ID` = (SELECT `carOwner` FROM cars WHERE carPlaca='%s' LIMIT 1)"plate);
        new 
Cache:handle mysql_query(g_iHandleQuery);
        if(
cache_get_row_count(g_iHandle)){
        new 
user[25], model[25];
        
cache_get_field_content(0"character"userg_iHandle);
        
cache_get_field_content(0"carMOdel"modelg_iHandle);
        
cache_delete(handleg_iHandle);
        
format(stringsizeof(string), "RESULTADO DE BUSCA\n\nPlaca do Veнculo: %s\nModelo do Veнculo: %s\nDono do Veнculo: %s"plate,modeluser);
          
Dialog_Show(playeridMDCResultDIALOG_STYLE_MSGBOX"Procurar Placa"string"Cancelar""");
        } else{
            
SendErrorMessage(playerid"PLACA NГO ENCONTRADA!");
        }
    }
    return 
1;

Neste mйtodo que eu fiz ta como se carModel fosse salvo como varchar.

-Vai skype
Reply
#8

Quote:
Originally Posted by Day_
Посмотреть сообщение
(facepalm)

PHP код:
Dialog:MDCVehicle(playeridresponselistiteminputtext[])
{
    if (
GetFactionType(playerid) != FACTION_POLICE || !IsACruiser(GetPlayerVehicleID(playerid)))
    return 
0;
    if(
response)
    {
        new 
plate[64];
        new 
string[152];
        if(
sscanf(inputtext"s[64]"plate)) return Dialog_Show(playeridMDCVehicleDIALOG_STYLE_INPUT"Mobile Data Computer - Procura de Placa""PROCURA DE PLACA\n\nInsira a informaзгo da placa:""Prosseguir""Cancelar");
        new 
Query[150];
        
mysql_format(g_iHandleQuerysizeof(Query), "SELECT `character`, `carModel` FROM `characters`, `cars` WHERE `ID` = (SELECT `carOwner` FROM cars WHERE carPlaca='%s' LIMIT 1)"plate);
        new 
Cache:handle mysql_query(g_iHandleQuery);
        if(
cache_get_row_count(g_iHandle)){
        new 
user[25], model[25];
        
cache_get_field_content(0"character"userg_iHandle);
        
cache_get_field_content(0"carMOdel"modelg_iHandle);
        
cache_delete(handleg_iHandle);
        
format(stringsizeof(string), "RESULTADO DE BUSCA\n\nPlaca do Veнculo: %s\nModelo do Veнculo: %s\nDono do Veнculo: %s"plate,modeluser);
          
Dialog_Show(playeridMDCResultDIALOG_STYLE_MSGBOX"Procurar Placa"string"Cancelar""");
        } else{
            
SendErrorMessage(playerid"PLACA NГO ENCONTRADA!");
        }
    }
    return 
1;

Neste mйtodo que eu fiz ta como se carModel fosse salvo como varchar.

-Vai skype
LOOL Nгo sabia que era sу um macro!

Eu achei bem estranho mesmo nгo ter funcionado, tbm usei como string, porйm faltou executar outra tabela :/ apenas adicionei a coluna...

Thx mano!
Reply
#9

Valeu por tentarem ajudar, irei testar aqui.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)