Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Dynamic House System by Twine. aka Pascal.
- */
- /* =====> [ Includes ] <=====*/
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <streamer>
- #include <a_mysql>
- /* =====> [ Colors ] <=====*/
- #define COLOR_GREY 0xB4B4B4FF
- #define COLOR_RED 0xFF6347AA
- #define COLOR_DARKRED 0xB50000FF
- #define COLOR_BLUE 0x4B89C1FF
- #define COLOR_DARKBLUE 0x1E00FFFF
- #define COLOR_GREEN 0x67DE57FF
- #define COLOR_DARKGREEN 0x67A657FF
- #define COLOR_YELLOW 0xEBFF00FF
- #define COLOR_ORANGE 0xFF8022FF
- #define COLOR_BROWN 0xA44B13FF
- /* =====> [ Define's ] <=====*/
- #define MAX_HOUSE 100
- /* =====> [ Enum's ] <=====*/
- enum houseSystem {
- h_owner[MAX_PLAYER_NAME],
- h_interior,
- h_buyscore,
- h_buyprice,
- h_pickup,
- h_lock,
- h_checkout,
- Text3D:h_textlabel,
- Float:h_x,
- Float:h_y,
- Float:h_z,
- Float:i_x,
- Float:i_y,
- Float:i_z,
- db_id
- }
- /* =====> [ Enum - Variablen ] <=====*/
- new houseInfo[MAX_HOUSE][houseSystem];
- /* =====> [ Variablen ] <=====*/
- new handle;
- /* =====> [ MySQL ] <=====*/
- #define SQL_HOST "127.0.0.1"
- #define SQL_USER "root"
- #define SQL_PASS ""
- #define SQL_DB "housesystem"
- /* =====> [ Dialoge ] <=====*/
- enum {
- DIALOG_HOUSESCORE = 500,
- DIALOG_HOUSEPRICE,
- DIALOG_HOUSEINTX,
- DIALOG_HOUSEINTY,
- DIALOG_HOUSEINTZ,
- DIALOG_HOUSEINTERIOR,
- DIALOG_HOUSECONFIRM,
- DIALOG_CHECKOUT,
- DIALOG_ASETTINGS,
- DIALOG_AHOUSEINTX,
- DIALOG_AHOUSEINTY,
- DIALOG_AHOUSEINTZ,
- DIALOG_AHOUSEINTERIOR
- }
- /* =====> [ Forwards ] <=====*/
- forward LoadHouse();
- forward CreateHouse(id);
- /*
- ############################################################################################################################
- ############################################################################################################################
- ############################################################################################################################
- ############################################################################################################################
- ############################################################################################################################
- ############################################################################################################################
- ############################################################################################################################
- */
- public OnFilterScriptInit()
- {
- print("ยด\n######################################################");
- print("##### Dynamic House System by Twine. aka Pascal. #####");
- print("######################################################\n");
- DisableInteriorEnterExits();
- // MySQL
- handle = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
- // Load House
- new query[128];
- format(query, sizeof(query), "SELECT * FROM `houses`");
- mysql_function_query(handle, query, true, "LoadHouse", "");
- return 1;
- }
- public OnFilterScriptExit()
- {
- mysql_close(handle);
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- SaveHouse(i);
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- /* =====> [ Publics & Functions ] <===== */
- public LoadHouse()
- {
- new num_rows, num_fields, tmp_name[MAX_PLAYER_NAME];
- new id = GetFreeHouseID();
- cache_get_data(num_rows, num_fields, handle);
- for (new i = 0; i < num_rows; i++)
- {
- cache_get_field_content(i, "owner", tmp_name, handle);
- strmid(houseInfo[id][h_owner], tmp_name, 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- houseInfo[id][h_interior] = cache_get_field_content_int(i, "interior", handle);
- houseInfo[id][h_buyscore] = cache_get_field_content_int(i, "buyscore", handle);
- houseInfo[id][h_buyprice] = cache_get_field_content_int(i, "buyprice", handle);
- houseInfo[id][h_lock] = cache_get_field_content_int(i, "h_lock", handle);
- houseInfo[id][h_checkout] = cache_get_field_content_int(i, "checkout", handle);
- houseInfo[id][h_x] = cache_get_field_content_float(i, "h_x", handle);
- houseInfo[id][h_y] = cache_get_field_content_float(i, "h_y", handle);
- houseInfo[id][h_z] = cache_get_field_content_float(i, "h_z", handle);
- houseInfo[id][i_x] = cache_get_field_content_float(i, "i_x", handle);
- houseInfo[id][i_y] = cache_get_field_content_float(i, "i_y", handle);
- houseInfo[id][i_z] = cache_get_field_content_float(i, "i_z", handle);
- houseInfo[id][db_id] = cache_get_field_content_int(i, "id", handle);
- // Create Textlabel and Pickups with a new function
- UpdateHouse(id);
- }
- return 1;
- }
- public CreateHouse(id)
- {
- houseInfo[id][db_id] = cache_insert_id(handle);
- return 1;
- }
- // Functions
- stock PlayerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- stock GetFreeHouseID()
- {
- for (new i = 0; i < sizeof(houseInfo); i++)
- {
- if (houseInfo[i][db_id] == 0) {
- return i;
- }
- }
- return 0;
- }
- stock UpdateHouse(id)
- {
- new string[512];
- if (houseInfo[id][h_pickup] != -1) {
- DestroyDynamicPickup(houseInfo[id][h_pickup]);
- }
- if (houseInfo[id][h_textlabel] != Text3D:-1) {
- DestroyDynamic3DTextLabel(houseInfo[id][h_textlabel]);
- }
- if (strlen(houseInfo[id][h_owner]))
- {
- format(string, sizeof(string), "\
- {FF8567}HouseID: {FFFFFF}%i\n\
- {FF8567}Owner: {FFFFFF}%s\n\n\
- {FFFFFF}You can with {FF8567}\"/enter\" {FFFFFF}in this house",
- houseInfo[id][db_id],
- houseInfo[id][h_owner]);
- houseInfo[id][h_textlabel] = CreateDynamic3DTextLabel(string, -1, houseInfo[id][h_x], houseInfo[id][h_y], houseInfo[id][h_z], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 250.0);
- houseInfo[id][h_pickup] = CreateDynamicPickup(1272, 1, houseInfo[id][h_x], houseInfo[id][h_y], houseInfo[id][h_z], -1, -1, -1, 100.0);
- }
- else if (!strlen(houseInfo[id][h_owner]))
- {
- format(string, sizeof(string), "\
- {FF8567}HouseID: {FFFFFF}%i\n\
- {FF8567}Owner: {FFFFFF}- None -\n\
- {FF8567}Score: {FFFFFF}%i\n\
- {FF8567}Price: {FFFFFF}$%i\n\n\
- {FFFFFF}You can buy this house with {FF8567}/buyhouse",
- houseInfo[id][db_id],
- houseInfo[id][h_buyscore],
- houseInfo[id][h_buyprice]);
- houseInfo[id][h_textlabel] = CreateDynamic3DTextLabel(string, -1, houseInfo[id][h_x], houseInfo[id][h_y], houseInfo[id][h_z], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 250.0);
- houseInfo[id][h_pickup] = CreateDynamicPickup(1273, 1, houseInfo[id][h_x], houseInfo[id][h_y], houseInfo[id][h_z], -1, -1, -1, 100.0);
- }
- return 1;
- }
- stock IsPlayerHouseOwner(playerid)
- {
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) continue;
- if (!strlen(houseInfo[i][h_owner])) continue;
- if (!strcmp(PlayerName(playerid), houseInfo[i][h_owner], true)) {
- return true;
- }
- }
- return 0;
- }
- stock SaveHouse(id)
- {
- new query[364];
- format(query, sizeof(query), "UPDATE `houses` SET owner = '%s', interior = '%i', buyscore = '%i', buyprice = '%i', h_lock = '%i',\
- checkout = '%i', i_x = '%f', i_y = '%f', i_z = '%f' WHERE id = '%i'",
- houseInfo[id][h_owner],
- houseInfo[id][h_interior],
- houseInfo[id][h_buyscore],
- houseInfo[id][h_buyprice],
- houseInfo[id][h_lock],
- houseInfo[id][h_checkout],
- houseInfo[id][i_x],
- houseInfo[id][i_y],
- houseInfo[id][i_z],
- houseInfo[id][db_id]);
- mysql_function_query(handle, query, false, "", "");
- return 1;
- }
- /*
- ####################################################################################################
- ####################################################################################################
- ####################################################################################################
- ####################################################################################################
- ####################################################################################################
- */
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- /* =====> [ CMD - Commands ] <===== */
- CMD:createhouse(playerid, params[])
- {
- #pragma unused params
- new string[164], index = 0;
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- index++;
- }
- if (index >= MAX_HOUSE) {
- format(string, sizeof(string), "There are already %i houses", MAX_HOUSE);
- return SendClientMessage(playerid, COLOR_RED, string);
- }
- format(string, sizeof(string), "At what level should you buy this House?\nPlease select a level:");
- ShowPlayerDialog(playerid, DIALOG_HOUSESCORE, DIALOG_STYLE_INPUT, "Create house - score", string, "Next", "Cancel");
- return 1;
- }
- CMD:deletehouse(playerid, params[])
- {
- new string[164], query[128], hID;
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- if (sscanf(params, "i", hID)) {
- return SendClientMessage(playerid, COLOR_GREY, "[Command]: /deletehouse [houseID]");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] || houseInfo[i][db_id] != hID) {
- continue;
- }
- strmid(houseInfo[i][h_owner], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- houseInfo[i][h_interior] = 0;
- houseInfo[i][h_buyscore] = 0;
- houseInfo[i][h_buyprice] = 0;
- houseInfo[i][h_pickup] = -1;
- houseInfo[i][h_lock] = 0;
- houseInfo[i][h_checkout] = 0;
- houseInfo[i][h_textlabel] = Text3D:-1;
- houseInfo[i][h_x] = 0.0;
- houseInfo[i][h_y] = 0.0;
- houseInfo[i][h_z] = 0.0;
- houseInfo[i][i_x] = 0.0;
- houseInfo[i][i_y] = 0.0;
- houseInfo[i][i_z] = 0.0;
- if (houseInfo[i][h_pickup]) {
- DestroyDynamicPickup(houseInfo[i][h_pickup]);
- }
- if (houseInfo[i][h_textlabel]) {
- DestroyDynamic3DTextLabel(houseInfo[i][h_textlabel]);
- }
- }
- format(string, sizeof(string), "You have deleted the House with ID %i", hID);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(query, sizeof(query), "DELETE FROM `houses` WHERE id = '%i'", hID);
- mysql_function_query(handle, query, false, "", "");
- return 1;
- }
- CMD:buyhouse(playerid, params[])
- {
- new string[128];
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- if (IsPlayerHouseOwner(playerid) == 1) {
- return SendClientMessage(playerid, COLOR_RED, "You already have a house!");
- }
- if (strlen(houseInfo[i][h_owner])) {
- return SendClientMessage(playerid, COLOR_RED, "This house is sold!");
- }
- if (GetPlayerScore(playerid) < houseInfo[i][h_buyscore]) {
- return SendClientMessage(playerid, COLOR_GREY, "You have not the necessary score for the House!");
- }
- if (GetPlayerMoney(playerid) < houseInfo[i][h_buyprice]) {
- return SendClientMessage(playerid, COLOR_GREY, "You have not enough money!");
- }
- strmid(houseInfo[i][h_owner], PlayerName(playerid), 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- houseInfo[i][h_lock] = 1;
- houseInfo[i][h_checkout] = 0;
- format(string, sizeof(string), "You have successfully purchased the House for $%i", houseInfo[i][h_buyprice]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- UpdateHouse(i);
- SaveHouse(i);
- return 1;
- }
- }
- return 1;
- }
- CMD:checkout(playerid, params[])
- {
- new string[128];
- if (IsPlayerHouseOwner(playerid) == 0) {
- return SendClientMessage(playerid, COLOR_RED, "You have no house!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] || !strlen(houseInfo[i][h_owner])) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- if (strcmp(houseInfo[i][h_owner], PlayerName(playerid), true)) {
- return SendClientMessage(playerid, COLOR_RED, "This is not your house!");
- }
- SetPVarInt(playerid, "HouseID", i);
- format(string, sizeof(string), "House checkout: $%i", houseInfo[i][h_checkout]);
- ShowPlayerDialog(playerid, DIALOG_CHECKOUT, DIALOG_STYLE_INPUT, "House checkout", string, "Take off", "Pay in");
- return 1;
- }
- }
- return 1;
- }
- CMD:sellhouse(playerid, params[])
- {
- new string[128];
- if (IsPlayerHouseOwner(playerid) == 0) {
- return SendClientMessage(playerid, COLOR_RED, "You have no house!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] || !strlen(houseInfo[i][h_owner])) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- if (strcmp(houseInfo[i][h_owner], PlayerName(playerid), true)) {
- return SendClientMessage(playerid, COLOR_RED, "This is not your house!");
- }
- strmid(houseInfo[i][h_owner], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- houseInfo[i][h_lock] = 1;
- houseInfo[i][h_checkout] = 0;
- GivePlayerMoney(playerid, houseInfo[i][h_buyprice]/2);
- format(string, sizeof(string), "You sold the House successfully, you will receive $%i.", houseInfo[i][h_buyprice]/2);
- SendClientMessage(playerid, COLOR_BLUE, string);
- UpdateHouse(i);
- SaveHouse(i);
- return 1;
- }
- }
- return 1;
- }
- CMD:asellhouse(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] || !strlen(houseInfo[i][h_owner])) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- strmid(houseInfo[i][h_owner], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- houseInfo[i][h_lock] = 1;
- houseInfo[i][h_checkout] = 0;
- SendClientMessage(playerid, COLOR_BLUE, "You have successfully freed the House.");
- UpdateHouse(i);
- SaveHouse(i);
- return 1;
- }
- }
- return 1;
- }
- CMD:enter(playerid, params[])
- {
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] && !strlen(houseInfo[i][h_owner]) || houseInfo[i][h_x] == 0.0) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- if (houseInfo[i][h_lock] == 1) {
- return SendClientMessage(playerid, COLOR_RED, "This house is completed.");
- }
- SetPlayerPos(playerid, houseInfo[i][i_x], houseInfo[i][i_y], houseInfo[i][i_z]);
- SetPlayerInterior(playerid, houseInfo[i][h_interior]);
- SetPlayerVirtualWorld(playerid, i);
- return 1;
- }
- }
- return 1;
- }
- CMD:exit(playerid, params[])
- {
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] || GetPlayerVirtualWorld(playerid) != i) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][i_x], houseInfo[i][i_y], houseInfo[i][i_z]))
- {
- SetPlayerPos(playerid, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]);
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, 0);
- return 1;
- }
- }
- return 1;
- }
- CMD:lock(playerid, params[])
- {
- if (IsPlayerHouseOwner(playerid) == 0) {
- return SendClientMessage(playerid, COLOR_RED, "You have no house!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id] && !strlen(houseInfo[i][h_owner])) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- if (strcmp(houseInfo[i][h_owner], PlayerName(playerid), true)) {
- continue;
- }
- if (houseInfo[i][h_lock] == 1) {
- houseInfo[i][h_lock] = 0;
- GameTextForPlayer(playerid, "~g~Open", 3000, 4);
- }
- else if (houseInfo[i][h_lock] == 0) {
- houseInfo[i][h_lock] = 1;
- GameTextForPlayer(playerid, "~r~Closed", 3000, 4);
- }
- return 1;
- }
- }
- return 1;
- }
- CMD:asetprice(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- new price, string[128];
- if (sscanf(params, "i", price)) {
- return SendClientMessage(playerid, COLOR_GREY, "[Command]: /asetprice [new price]");
- }
- if (price < 0) {
- return SendClientMessage(playerid, COLOR_GREY, "The price must be greater than 0!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- houseInfo[i][h_buyprice] = price;
- format(string, sizeof(string), "You set the price to $%i.", price);
- SendClientMessage(playerid, COLOR_RED, string);
- UpdateHouse(i);
- SaveHouse(i);
- }
- }
- return 1;
- }
- CMD:asetscore(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- new score, string[128];
- if (sscanf(params, "i", score)) {
- return SendClientMessage(playerid, COLOR_GREY, "[Command]: /asetscore [new score]");
- }
- if (score < 0) {
- return SendClientMessage(playerid, COLOR_GREY, "The score must be greater than 0!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- houseInfo[i][h_buyscore] = score;
- format(string, sizeof(string), "You set the score to %i.", score);
- SendClientMessage(playerid, COLOR_RED, string);
- UpdateHouse(i);
- SaveHouse(i);
- }
- }
- return 1;
- }
- CMD:asetcheckout(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- new checkout, string[128];
- if (sscanf(params, "i", checkout)) {
- return SendClientMessage(playerid, COLOR_GREY, "[Command]: /asetcheckout [new checkout]");
- }
- if (checkout < 0) {
- return SendClientMessage(playerid, COLOR_GREY, "The checkout must be greater than 0!");
- }
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- houseInfo[i][h_checkout] = checkout;
- format(string, sizeof(string), "You set the checkout to $%i.", checkout);
- SendClientMessage(playerid, COLOR_RED, string);
- UpdateHouse(i);
- SaveHouse(i);
- }
- }
- return 1;
- }
- CMD:ahousesettings(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) {
- return SendClientMessage(playerid, COLOR_GREY, "You are no admin!");
- }
- new string[128];
- for (new i = 0; i < MAX_HOUSE; i++)
- {
- if (!houseInfo[i][db_id]) {
- continue;
- }
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z]))
- {
- SetPVarInt(playerid, "HouseID", i);
- format(string, sizeof(string), "InteriorX\nInteriorY\nInteriorZ\nInteriorID");
- ShowPlayerDialog(playerid, DIALOG_ASETTINGS, DIALOG_STYLE_LIST, "House settings", string, "Select", "Cancel");
- return 1;
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == DIALOG_HOUSESCORE)
- {
- new string[128];
- if (response)
- {
- SetPVarInt(playerid, "BuyScore", strval(inputtext));
- format(string, sizeof(string), "Score: %i\n\nAt what price should you buy this House?\nPlease select a price:",
- strval(inputtext));
- ShowPlayerDialog(playerid, DIALOG_HOUSEPRICE, DIALOG_STYLE_INPUT, "Create house - price", string, "Next", "Back");
- return 1;
- }
- return 1;
- }
- else if (dialogid == DIALOG_HOUSEPRICE)
- {
- new string[128];
- if (response)
- {
- SetPVarInt(playerid, "BuyPrice", strval(inputtext));
- format(string, sizeof(string), "Score: %i\nPrice: $%i\n\nPlease give it to the first coordinate (X) your interior:",
- GetPVarInt(playerid, "BuyScore"), strval(inputtext));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTX, DIALOG_STYLE_INPUT, "Create house - InteriorX", string, "Next", "Back");
- return 1;
- }
- format(string, sizeof(string), "At what level should you buy this House?\nPlease select a level:");
- ShowPlayerDialog(playerid, DIALOG_HOUSESCORE, DIALOG_STYLE_INPUT, "Create house - score", string, "Next", "Cancel");
- return 1;
- }
- else if (dialogid == DIALOG_HOUSEINTX)
- {
- new string[256];
- if (response)
- {
- SetPVarFloat(playerid, "hInteriorX", floatstr(inputtext));
- format(string, sizeof(string), "Score: %i\nPrice: $%i\nInteriorX: %f\n\nPlease give it to the second coordinate (Y) your interior:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), floatstr(inputtext));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTY, DIALOG_STYLE_INPUT, "Create house - InteriorY", string, "Next", "Back");
- return 1;
- }
- format(string, sizeof(string), "Score: %i\nAt what price should you buy this House?\nPlease select a price:",
- GetPVarInt(playerid, "BuyScore"));
- ShowPlayerDialog(playerid, DIALOG_HOUSEPRICE, DIALOG_STYLE_INPUT, "Create house - price", string, "Next", "Back");
- return 1;
- }
- else if (dialogid == DIALOG_HOUSEINTY)
- {
- new string[256];
- if (response)
- {
- SetPVarFloat(playerid, "hInteriorY", floatstr(inputtext));
- format(string, sizeof(string), "\
- Score: %i\n\
- Price: $%i\n\
- InteriorX: %f\n\
- InteriorY: %f\n\n\
- Please give it to the third coordinate (Z) your interior:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), GetPVarFloat(playerid, "hInteriorX"),
- floatstr(inputtext));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTZ, DIALOG_STYLE_INPUT, "Create house - InteriorZ", string, "Next", "Back");
- return 1;
- }
- format(string, sizeof(string), "Score: %i\nPrice: $%i\nPlease give it to the first coordinate (X) your interior:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTX, DIALOG_STYLE_INPUT, "Create house - InteriorX", string, "Next", "Back");
- return 1;
- }
- else if (dialogid == DIALOG_HOUSEINTZ)
- {
- new string[256];
- if (response)
- {
- SetPVarFloat(playerid, "hInteriorZ", floatstr(inputtext));
- format(string, sizeof(string), "\
- Score: %i\n\
- Price: $%i\n\
- InteriorX: %f\n\
- InteriorY: %f\n\
- InteriorZ: %f\n\n\
- Please enter the InteriorID:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), GetPVarFloat(playerid, "hInteriorX"),
- GetPVarFloat(playerid, "hInteriorY"), floatstr(inputtext));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTERIOR, DIALOG_STYLE_INPUT, "Create house - InteriorID", string, "Next", "Back");
- return 1;
- }
- format(string, sizeof(string), "Score: %i\nPrice: $%i\nInteriorX: %f\nPlease give it to the second coordinate (Y) your interior:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), GetPVarFloat(playerid, "hInteriorX"));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTY, DIALOG_STYLE_INPUT, "Create house - InteriorY", string, "Next", "Back");
- return 1;
- }
- else if (dialogid == DIALOG_HOUSEINTERIOR)
- {
- new string[256];
- if (response)
- {
- SetPVarInt(playerid, "hInterior", strval(inputtext));
- format(string, sizeof(string), "\
- Score: %i\n\
- Price: $%i\n\
- InteriorX: %f\n\
- InteriorY: %f\n\
- InteriorZ: %f\n\
- InteriorID: %i\n\n\
- Would you really build this House?",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), GetPVarFloat(playerid, "hInteriorX"),
- GetPVarFloat(playerid, "hInteriorY"), GetPVarFloat(playerid, "hInteriorZ"), strval(inputtext));
- ShowPlayerDialog(playerid, DIALOG_HOUSECONFIRM, DIALOG_STYLE_MSGBOX, "Create house", string, "Accept", "Back");
- return 1;
- }
- format(string, sizeof(string), "\
- Score: %i\n\
- Price: $%i\n\
- InteriorX: %f\n\
- InteriorY: %f\n\n\
- Please give it to the third coordinate (Z) your interior:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), GetPVarFloat(playerid, "hInteriorX"),
- GetPVarFloat(playerid, "hInteriorY"));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTZ, DIALOG_STYLE_INPUT, "Create house - InteriorZ", string, "Next", "Back");
- return 1;
- }
- else if (dialogid == DIALOG_HOUSECONFIRM)
- {
- new string[356];
- if (response)
- {
- new Float:px, Float:py, Float:pz, query[364];
- new id = GetFreeHouseID();
- GetPlayerPos(playerid, px, py, pz);
- for (new i = 0; i < MAX_HOUSE; i++) {
- if (!houseInfo[i][db_id]) continue;
- if (IsPlayerInRangeOfPoint(playerid, 2.0, houseInfo[i][h_x], houseInfo[i][h_y], houseInfo[i][h_z])) {
- return SendClientMessage(playerid, COLOR_GREY, "You can create no houses next to each other.");
- }
- }
- strmid(houseInfo[id][h_owner], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
- houseInfo[id][h_interior] = GetPVarInt(playerid, "hInterior");
- houseInfo[id][h_buyscore] = GetPVarInt(playerid, "BuyScore");
- houseInfo[id][h_buyprice] = GetPVarInt(playerid, "BuyPrice");
- houseInfo[id][h_lock] = 1;
- houseInfo[id][h_checkout] = 0;
- houseInfo[id][h_x] = px;
- houseInfo[id][h_y] = py;
- houseInfo[id][h_z] = pz;
- houseInfo[id][i_x] = GetPVarFloat(playerid, "hInteriorX");
- houseInfo[id][i_y] = GetPVarFloat(playerid, "hInteriorY");
- houseInfo[id][i_z] = GetPVarFloat(playerid, "hInteriorZ");
- format(query, sizeof(query), "INSERT INTO `houses` (interior, buyscore, buyprice, h_lock, checkout, h_x, h_y, h_z,\
- i_x, i_y, i_z) VALUES ('%i', '%i', '%i', '1', '0', '%f', '%f', '%f', '%f', '%f', '%f')",
- houseInfo[id][h_interior],
- houseInfo[id][h_buyscore],
- houseInfo[id][h_buyprice],
- houseInfo[id][h_x],
- houseInfo[id][h_y],
- houseInfo[id][h_z],
- houseInfo[id][i_x],
- houseInfo[id][i_y],
- houseInfo[id][i_z]);
- print(query);
- mysql_function_query(handle, query, true, "CreateHouse", "i", id);
- UpdateHouse(id);
- format(string, sizeof(string), "You have a House created successfully, HouseID: %i", houseInfo[id][db_id]);
- SendClientMessage(playerid, COLOR_RED, string);
- return 1;
- }
- format(string, sizeof(string), "\
- Score: %i\n\
- Price: $%i\n\
- InteriorX: %f\n\
- InteriorY: %f\n\
- InteriorZ: %f\n\n\
- Please enter the InteriorID:",
- GetPVarInt(playerid, "BuyScore"), GetPVarInt(playerid, "BuyPrice"), GetPVarFloat(playerid, "hInteriorX"),
- GetPVarFloat(playerid, "hInteriorY"), GetPVarFloat(playerid, "hInteriorZ"));
- ShowPlayerDialog(playerid, DIALOG_HOUSEINTERIOR, DIALOG_STYLE_INPUT, "Create house - InteriorID", string, "Next", "Back");
- return 1;
- }
- else if (dialogid == DIALOG_CHECKOUT)
- {
- new id = GetPVarInt(playerid, "HouseID");
- if (response)
- {
- if (houseInfo[id][h_checkout] < strval(inputtext)) {
- return SendClientMessage(playerid, COLOR_RED, "Your house checkout has not enough money");
- }
- houseInfo[id][h_checkout] -= strval(inputtext);
- GivePlayerMoney(playerid, strval(inputtext));
- }
- else if (!response)
- {
- if (GetPlayerMoney(playerid) < strval(inputtext)) {
- return SendClientMessage(playerid, COLOR_RED, "You have not enough money!");
- }
- houseInfo[id][h_checkout] += strval(inputtext);
- GivePlayerMoney(playerid, -strval(inputtext));
- }
- SaveHouse(id);
- return 1;
- }
- else if (dialogid == DIALOG_AHOUSEINTX)
- {
- if (response)
- {
- new string[128];
- new id = GetPVarInt(playerid, "HouseID");
- houseInfo[id][i_x] = floatstr(inputtext);
- format(string, sizeof(string), "InteriorX\nInteriorY\nInteriorZ\nInteriorID");
- ShowPlayerDialog(playerid, DIALOG_ASETTINGS, DIALOG_STYLE_LIST, "House settings", string, "Select", "Cancel");
- return 1;
- }
- return 1;
- }
- else if (dialogid == DIALOG_AHOUSEINTY)
- {
- if (response)
- {
- new string[128];
- new id = GetPVarInt(playerid, "HouseID");
- houseInfo[id][i_y] = floatstr(inputtext);
- format(string, sizeof(string), "InteriorX\nInteriorY\nInteriorZ\nInteriorID");
- ShowPlayerDialog(playerid, DIALOG_ASETTINGS, DIALOG_STYLE_LIST, "House settings", string, "Select", "Cancel");
- return 1;
- }
- return 1;
- }
- else if (dialogid == DIALOG_AHOUSEINTZ)
- {
- if (response)
- {
- new string[128];
- new id = GetPVarInt(playerid, "HouseID");
- houseInfo[id][i_z] = floatstr(inputtext);
- format(string, sizeof(string), "InteriorX\nInteriorY\nInteriorZ\nInteriorID");
- ShowPlayerDialog(playerid, DIALOG_ASETTINGS, DIALOG_STYLE_LIST, "House settings", string, "Select", "Cancel");
- return 1;
- }
- return 1;
- }
- else if (dialogid == DIALOG_AHOUSEINTERIOR)
- {
- if (response)
- {
- new string[128];
- new id = GetPVarInt(playerid, "HouseID");
- houseInfo[id][h_interior] = strval(inputtext);
- format(string, sizeof(string), "InteriorX\nInteriorY\nInteriorZ\nInteriorID");
- ShowPlayerDialog(playerid, DIALOG_ASETTINGS, DIALOG_STYLE_LIST, "House settings", string, "Select", "Cancel");
- return 1;
- }
- return 1;
- }
- else if (dialogid == DIALOG_ASETTINGS)
- {
- if (response)
- {
- new string[128];
- switch (listitem)
- {
- case 0:
- {
- format(string, sizeof(string), "Please give it to the first coordinate (X) your interior:");
- ShowPlayerDialog(playerid, DIALOG_AHOUSEINTX, DIALOG_STYLE_INPUT, "House settings - InteriorX", string, "Okay", "Cancel");
- }
- case 1:
- {
- format(string, sizeof(string), "Please give it to the second coordinate (Y) your interior:");
- ShowPlayerDialog(playerid, DIALOG_AHOUSEINTY, DIALOG_STYLE_INPUT, "House settings - InteriorY", string, "Okay", "Cancel"); }
- case 2:
- {
- format(string, sizeof(string), "Please give it to the third coordinate (Z) your interior:");
- ShowPlayerDialog(playerid, DIALOG_AHOUSEINTZ, DIALOG_STYLE_INPUT, "House settings - InteriorZ", string, "Okay", "Cancel");
- }
- case 3:
- {
- format(string, sizeof(string), "Please enter the InteriorID:");
- ShowPlayerDialog(playerid, DIALOG_AHOUSEINTERIOR, DIALOG_STYLE_INPUT, "House settings - InteriorID", string, "Okay", "Cancel");
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment