08.01.2014, 14:52
(
Последний раз редактировалось Alexbav; 08.01.2014 в 17:07.
)
Bom vou ser breve, tou com um bug no code, nгo consigo arrumar de geito nenhum
IMGS
CODE:
Code de comprar:
IMGS
CODE:
pawn Код:
if(newstate == 2)
{
id = LoadedInfo[Vehicles];
new playername[MAX_PLAYER_NAME];
new Query[255];
GetPlayerName(playerid,playername,sizeof(playername));
VehicleInfo[id][Price] = cache_get_field_content_int(0, "price");
new vehicleid = GetPlayerVehicleID(playerid);
format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE model='%d' ORDER BY id DESC",id); // Formats the query for "mysql_query"
mysql_query(mysql,Query); // Querys the "Query" Variable.
mysql_store_result(); // Stores the result from Query
if(strmatch(VehicleInfo[vehicleid][Owner], GetName(playerid)))
{
new String[256];
format(String,sizeof(String), "Bem vindo novamente %s ao seu carro !", VehicleInfo[vehicleid][Owner]);
SendClientMessage(playerid,-1,String);
}
else
{
sscanf(Query, "p<|>e<is[25]iiffffii>", VehicleInfo[id]);
format(Query, sizeof(Query), "SELECT * FROM `vehicles`"); // 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]iiffffii>", VehicleInfo[vehicleid]); // Pretty neat ehh? [ ID, OWNER, MODEL, PRICE, POS X, POS Y, POS Z, POS A ]
}
new Titulo[256],Info[256];
format(Titulo, sizeof(Titulo), "Sistema de compra de Veiculos");
format(Info, sizeof(Info), "Olб %s vocк quer comprar esse Veiculo ?\n\n\nPreзo: %d\nDono: %s\nModelo: %d",playername,VehicleInfo[vehicleid][Price],VehicleInfo[vehicleid][Owner],VehicleInfo[vehicleid][Model]);
ShowPlayerDialog(playerid, DialogShopCar, DIALOG_STYLE_MSGBOX,Titulo, Info, "Sim", "Nгo");
}
}
pawn Код:
switch(dialogid)
{
case DialogShopCar:
{
id = LoadedInfo[Vehicles];
if(!response) return RemovePlayerFromVehicle(playerid);
{
VehiclePrice = cache_get_field_content_int(0, "price");
if(GetPlayerMoney(playerid) >= VehiclePrice)
{
new query[1024];
GetPlayerName(playerid, Nome,sizeof(Nome));
format(query,sizeof(query),"UPDATE `vehicles` SET `owner`='%s',`purchased`='true' WHERE `price`='%d'",Nome,VehiclePrice);//formatamos a string com o que devemos salvar
mysql_function_query(mysql,query, false, "", "");
GivePlayerMoney(playerid,-VehiclePrice);
}
else
{
new Titulo[256],Info[256];
format(Titulo,sizeof(Titulo), "Vehicle System");
format(Info, sizeof(Info), "Desculpe %s vocк nгo tem\n%d para comprar o veiculo",Nome,VehiclePrice);
ShowPlayerDialog(playerid,DialogShopError, DIALOG_STYLE_MSGBOX,Titulo, Info, "Ok", "");
RemovePlayerFromVehicle(playerid);
}
}
}