27.10.2013, 21:20
(
Последний раз редактировалось Cerealguy; 28.10.2013 в 01:11.
)
Hello friends, I have followed all the tutorial and everything is dynamic perfectly and I did, I did that instead of adding the houses was done manually with a command / createhouse, the problem is as I do so that when I create a store house either continue using sqlite or use data other than for y_ini house, help please
sorry no speak much english
Код:
new DB:database, DBResult:queryresult, fquery[300]; #define MAX_HOUSES 300 #define MAX_HOUSES_PER_PLAYER 2 #define databasename "housedb.db" #define DEFAULT_HOUSE_NAME "No-Title" // The default name when a house is created/sold #define DEFAULT_HOUSE_NAME_OWNER "No-Owner" // house title default #define DIALOG_HOUSE_CONFIG 14750 #define DIALOG_CHANGE_HOUSE_TITLE 15750 //************************************************************// enum hinfo { owner[24], Hname[100], costprice, Float:EnterPos[3], Float:TelePos[3], interiors, Text3D:textid, checkpointidx[2] }; new HouseInformation[MAX_HOUSES][hinfo]; new houseid = -1; new InHouse[MAX_PLAYERS], InHouseCP[MAX_PLAYERS]; CMD:h(playerid, params[]) { if(isnull(params)) { SendClientMessage(playerid,COLOR_YELLOW,"Usage:{FFFFFF} /h [BUY] [SELL]"); return 1; } if(!strcmp(params, "buy", true)) { if(InHouseCP[playerid] == -1) return SendClientMessage(playerid, 0xFF0000, "You are not in any house checkpoints!"); if(HouseInformation[InHouseCP[playerid]][owner][0] != 0) return SendClientMessage(playerid, 0xFF0000, "This house has a owner"); if(GetPlayerMonez(playerid) < HouseInformation[InHouseCP[playerid]][costprice]) return SendClientMessage(playerid, 0xFF0000, "You don't have enough money!"); //Player has a lack of cash! new PlayerName[24]; GetPlayerName(playerid, PlayerName, 24); format(fquery, sizeof(fquery), "SELECT `houseowner` FROM `HOUSEINFO` WHERE `houseowner` = '%s'", PlayerName); //Formats the SELECT query format(fquery, sizeof(fquery), "SELECT `houseowner` FROM `HOUSEINFO` WHERE `housename` = '%s'", DEFAULT_HOUSE_NAME); //Formats the SELECT query queryresult = db_query(database, fquery); //Query result variable has been used to query the string above. if(db_num_rows(queryresult) == MAX_HOUSES_PER_PLAYER) return SendClientMessage(playerid, 0xFF0000, "You already have the max amount of houses"); //If the player has the max houses db_free_result(queryresult); //This is the point where the player can buy the house SetOwner(HouseInformation[InHouseCP[playerid]][Hname], PlayerName, Comma(HouseInformation[InHouseCP[playerid]][costprice]), InHouseCP[playerid]); //SetOwner(HouseName[], ownername[], houseids) SetPlayerPos(playerid, HouseInformation[InHouseCP[playerid]][TelePos][0], HouseInformation[InHouseCP[playerid]][TelePos][1], HouseInformation[InHouseCP[playerid]][TelePos][2]); //Sets players position where InHouseCP[playerid] = houseid. SetPlayerInterior(playerid, HouseInformation[InHouseCP[playerid]][interiors]); //Sets players interior SetPlayerVirtualWorld(playerid, 15500000 + InHouseCP[playerid]); //Sets the virtual world GivePlayerMonez(playerid, - HouseInformation[InHouseCP[playerid]][costprice]); GameTextForPlayer(playerid, "House ~r~Purchased!", 3000, 3); //Tells them they have purchased a house } if(!strcmp(params, "sell", true)) { if(InHouse[playerid] == -1) return SendClientMessage(playerid, 0xFF0000, "You have to be inside your house to sell it!"); new Pname[24]; GetPlayerName(playerid, Pname, 24); if(strcmp(HouseInformation[InHouse[playerid]][owner], Pname) != 0) return SendClientMessage(playerid, 0xFF0000, "This is not your house!"); //This is the point where the player can sell the house DeleteOwner(HouseInformation[InHouse[playerid]][Hname], InHouse[playerid]); //DeleteOwner(HouseName[], houseids) SetPlayerPos(playerid, HouseInformation[InHouse[playerid]][EnterPos][0], HouseInformation[InHouse[playerid]][EnterPos][1], HouseInformation[InHouse[playerid]][EnterPos][2]); SetPlayerInterior(playerid, 0); //Sets the player back to interior 0 (Outside) SetPlayerVirtualWorld(playerid, 0); //Sets the players Virtual world to 0. GivePlayerMonez(playerid, HouseInformation[InHouseCP[playerid]][costprice]); InHouseCP[playerid] = InHouse[playerid]; GameTextForPlayer(playerid, "House ~g~sold!", 3000, 3); //Tells them they have sold a house } return 1; } CMD:createhouse(playerid, params[]) { new Float:EnterX, Float:EnterY, Float:EnterZ; new price; if(sscanf(params,"d",price)) { SendClientMessage(playerid,COLOR_YELLOW,"Usage:{FFFFFF} /createhouse [price]"); return 1; } GetPlayerPos(playerid, EnterX, EnterY, EnterZ); format(HouseInformation[houseid][Hname], 100, "%s", DEFAULT_HOUSE_NAME); HouseInformation[houseid][costprice] = price; HouseInformation[houseid][EnterPos][0] = EnterX; HouseInformation[houseid][EnterPos][1] = EnterY; HouseInformation[houseid][EnterPos][2] = EnterZ; HouseInformation[houseid][TelePos][0] = 271.884979; HouseInformation[houseid][TelePos][1] = 306.631988; HouseInformation[houseid][TelePos][2] = 999.148437; HouseInformation[houseid][interiors] = 2; format(fquery, sizeof(fquery), "SELECT houseowner FROM HOUSEINFO WHERE housename = '%s'", DEFAULT_HOUSE_NAME); //Formats the SELECT query format(fquery, sizeof(fquery), "SELECT houseowner FROM HOUSEINFO WHERE houseprice = '%d'", price); //Formats the SELECT query queryresult = db_query(database, fquery); //Query result variable has been used to query the string above. if(db_num_rows(queryresult) != 0) db_get_field_assoc(queryresult, "houseowner", HouseInformation[houseid][owner], 24); //Fetches the field information db_free_result(queryresult); HouseInformation[houseid][checkpointidx][0] = CreateDynamicCP(EnterX, EnterY, EnterZ, 1.0); //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size); HouseInformation[houseid][checkpointidx][1] = CreateDynamicCP(271.884979, 306.631988, 999.148437, 1.0, 15500000+houseid, 2); //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid, interiorid); if(!HouseInformation[houseid][owner][0]) format(fquery, sizeof(fquery), "House Name: %s \n House Owner: %s \n House Price: $%s", DEFAULT_HOUSE_NAME, DEFAULT_HOUSE_NAME_OWNER, Comma(HouseInformation[houseid][costprice])); HouseInformation[houseid][textid] = CreateDynamic3DTextLabel(fquery, 0xFFFFFF, EnterX, EnterY, EnterZ + 0.5, 15.0); //CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0); houseid ++; //We go to the next free slot in our variable. return 1; } stock SetOwner(HouseName[], ownername[], price[], houseids) { format(fquery, sizeof(fquery), "INSERT INTO `HOUSEINFO` (`housename`, `houseowner`, `houseprice`) VALUES('%s', '%s', '%s')", HouseName, ownername, price); db_query(database, fquery); //Queries the SQLite database. format(HouseInformation[houseids][owner], 24, "%s", ownername); format(fquery, sizeof(fquery), "House Name: %s \n House Owner: %s \n House Price: $%s", HouseName, HouseInformation[houseids][owner], price); UpdateDynamic3DTextLabelText(HouseInformation[houseids][textid], 0xFFFFFF, fquery); //Updates the text label. return 1; } stock DeleteOwner(HouseName[], houseids) { format(HouseInformation[houseids][owner], 24, "%s", "\0"); format(fquery, sizeof(fquery), "DELETE FROM `HOUSEINFO` WHERE `housename` = '%s'", HouseName); db_query(database, fquery); //Queries the SQLite database. format(fquery, sizeof(fquery), "House Name: %s \n House Owner: %s \n House Price: $%s", HouseName, DEFAULT_HOUSE_NAME_OWNER, Comma(HouseInformation[houseids][costprice])); UpdateDynamic3DTextLabelText(HouseInformation[houseids][textid], 0xFFFFFF, fquery); //Updates the text label. return 1; } In OnGameModeInt database = db_open(databasename); db_free_result(db_query(database, "CREATE TABLE IF NOT EXISTS `HOUSEINFO` (housename varchar(51), houseowner varchar(25), houseprice varchar(25))"));