Pegar id na tabela veiculos mysql -
Alexbav - 12.01.2014
Bom eu queria saber como que eu pego o id na tabela dos veiculos no mysql mais eu nгo consigo de jeito nenhum


IMAGES:
CODE:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleColor(vehicleid, ColorOne, ColorTwo);
format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE id='%i'",VehicleInfo[id]); // Formats the query for "mysql_query"
mysql_query(mysql,Query); // Querys the "Query" Variable.
mysql_store_result(); // Stores the result from Query
while(mysql_fetch_row_format(Query,"|"))
{
sscanf(Query, "p<|>e<is[25]iiffffiii>", VehicleInfo[id]); // Pretty neat ehh? [ ID, OWNER, MODEL, PRICE, POS X, POS Y, POS Z, POS A ]
}
Re: Pegar id na tabela veiculos mysql -
Gii - 12.01.2014
Nгo entendi o propуsito disso, no exemplo abaixo fiz uma consulta para pegar o modelo.
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleColor(vehicleid, ColorOne, ColorTwo);
format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE id = '%i'", VehicleInfo[id]);
mysql_function_query(Conexao, Query, true, "getVehicleInformation", "d", playerid);
forward getVehicleInformation(playerid);
public getVehicleInformation(playerid) {
new linhas_c, colunas_c;
cache_get_data(linhas_c, colunas_c, Conexao);
if (linhas_c == 0 )
SendClientMessage(playerid, -1, "Nenhum resultado encontrado!");
else {
new result[25], model;
cache_get_field_content(0, "model", result, Conexao);
model = strval(result);
format (str, 25, "Modelo й %d", id);
SendClientMessage(playerid, -1, str);
}
return 1;
}
A formataзгo da Query fica com vocк!
Re: Pegar id na tabela veiculos mysql -
smiiir - 12.01.2014
Seria isso
pawn Код:
forward getID(playerid); // Topo
/* Seu Comando de Checar ID */
new idVeh = GetPlayerVehicleID(playerid), queryMySQL[70];
GetVehicle(idVeh, ColorOne, ColorTwo);
format(queryMySQL, 70, "SELECT * FROM vehicles WHERE id='%i'", Vehicleinfo[id]);
mysql_function_query(Conexao, queryMySQL, true, "getID", "i", playerid);
/* Callback de Checar ID */
public getID(playerid) {
new Rows, Field;
cache_get_data(Rows, Field, Conexao);
if(Row > 0) {
new idVeh, res[30], string[10];
cache_get_field_content(0, "id", res, Conexao), idVeh = strval(str);
format(string, 10, "ID: %i");
SendClientMessage(playerid, 1, string);
}
return true;
}
Nгo testei, caso tenha algum erro no compilador poste aqui.
Re: Pegar id na tabela veiculos mysql -
Alexbav - 12.01.2014
Quote:
Originally Posted by iSmirnoff
Seria isso
pawn Код:
forward getID(playerid); // Topo
/* Seu Comando de Checar ID */ new idVeh = GetPlayerVehicleID(playerid), queryMySQL[70]; GetVehicle(idVeh, ColorOne, ColorTwo); format(queryMySQL, 70, "SELECT * FROM vehicles WHERE id='%i'", Vehicleinfo[id]); mysql_function_query(Conexao, queryMySQL, true, "getID", "i", playerid);
/* Callback de Checar ID */ public getID(playerid) { new Rows, Field; cache_get_data(Rows, Field, Conexao); if(Row > 0) { new idVeh, res[30], string[10]; cache_get_field_content(0, "id", res, Conexao), idVeh = strval(str); format(string, 10, "ID: %i"); SendClientMessage(playerid, 1, string); } return true; }
Nгo testei, caso tenha algum erro no compilador poste aqui.
|
irei testar
Re: Pegar id na tabela veiculos mysql -
Alexbav - 12.01.2014
Quote:
Originally Posted by iSmirnoff
Seria isso
pawn Код:
forward getID(playerid); // Topo
/* Seu Comando de Checar ID */ new idVeh = GetPlayerVehicleID(playerid), queryMySQL[70]; GetVehicle(idVeh, ColorOne, ColorTwo); format(queryMySQL, 70, "SELECT * FROM vehicles WHERE id='%i'", Vehicleinfo[id]); mysql_function_query(Conexao, queryMySQL, true, "getID", "i", playerid);
/* Callback de Checar ID */ public getID(playerid) { new Rows, Field; cache_get_data(Rows, Field, Conexao); if(Row > 0) { new idVeh, res[30], string[10]; cache_get_field_content(0, "id", res, Conexao), idVeh = strval(str); format(string, 10, "ID: %i"); SendClientMessage(playerid, 1, string); } return true; }
Nгo testei, caso tenha algum erro no compilador poste aqui.
|
Quote:
Originally Posted by iCasTiel
Nгo entendi o propуsito disso, no exemplo abaixo fiz uma consulta para pegar o modelo.
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid); GetVehicleColor(vehicleid, ColorOne, ColorTwo); format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE id = '%i'", VehicleInfo[id]); mysql_function_query(Conexao, Query, true, "getVehicleInformation", "d", playerid);
forward getVehicleInformation(playerid); public getVehicleInformation(playerid) {
new linhas_c, colunas_c; cache_get_data(linhas_c, colunas_c, Conexao);
if (linhas_c == 0 ) SendClientMessage(playerid, -1, "Nenhum resultado encontrado!"); else { new result[25], model; cache_get_field_content(0, "model", result, Conexao); model = strval(result); format (str, 25, "Modelo й %d", id); SendClientMessage(playerid, -1, str); } return 1; }
A formataзгo da Query fica com vocк!
|
Nгo funcionou
Re: Pegar id na tabela veiculos mysql -
Alexbav - 12.01.2014
Quote:
Originally Posted by Alexbav
Nгo funcionou 
|
nгo era isso que eu queria , й porque eu fiz um sistema de compras de carros, esta funcionando so que quero pegar o id do veiculo para pegar a informaзгo contida no banco de dados
Re: Pegar id na tabela veiculos mysql -
Kmatsu - 13.01.2014
Manda a sua variavel 'VehicleInfo'
Pois eu acho que o 'id' que vocк quer ja ta sendo salvo nela (VehicleInfo[id][0])
Re: Pegar id na tabela veiculos mysql -
Alexbav - 13.01.2014
Quote:
Originally Posted by Alexbav
Nгo funcionou 
|
Quote:
Originally Posted by Kmatsu
Manda a sua variavel 'VehicleInfo'
Pois eu acho que o 'id' que vocк quer ja ta sendo salvo nela (VehicleInfo[id][0])
|
pawn Код:
enum vInfo // You could really name this anything.. Foo, pop, vehicle, vehicles whatever you like.
{
Id, // This is needed as SScanf loads the car variables through this Enum, i'll get back to that later.
Owner[25],
Model,
Price,
Float:Pos[posInfo], // Arrays ftw.
cColorOne,
cColorTwo,
Purchased[25],
}
new VehicleInfo[MAX_VEHICLES][vInfo]; // Remember this ? the define we just made.. Great ! you'r actually reading.
Pronto
Re: Pegar id na tabela veiculos mysql -
Kmatsu - 13.01.2014
Entгo й isso mesmo...
o 'id' que vocк quer ja ta ae na variavel 'VehicleInfo[ id veiculo ][Id]'
Re: Pegar id na tabela veiculos mysql -
Alexbav - 13.01.2014
vou ver aqui se consigo arrumar ja que ninguem me ajuda ^^