ShowPropertyEditingDialog(playerid, propertyid) { SetPVarInt(playerid, "EditingProperty", propertyid); new string[512]; strcat(string, "Please choose an option\n"); strcat(string, "Set the exterior position at your current position\n"); strcat(string, "Set the interior position at your current position\n"); strcat(string, "Set the property interior ID\n"); strcat(string, va_return("Set the owner ID{b3b3b3}(currently %d){eeeeee}\n", Property_GetOwnerSQLID(propertyid))); strcat(string, va_return("Set the type {b3b3b3}(currently %d - %s){eeeeee}\n", Property_GetType(propertyid), Property_GetTypeName(Property_GetType(propertyid)))); strcat(string, va_return("Set the description {b3b3b3}(currently %s){eeeeee}\n", Property_GetDescription(propertyid))); strcat(string, va_return("Set the address {b3b3b3}(currently %s){eeeeee}\n", Property_GetAddress(propertyid))); strcat(string, va_return("Set the price {b3b3b3}(currently $%s)", MoneyFormat(Property_GetPrice(propertyid)))); Dialog_ShowCallback(playerid, using public OnPlayerEditProperty, DIALOG_STYLE_TABLIST_HEADERS, va_return("Editing Property ID %d", propertyid), string, "Next", "Back"); return 1; } forward OnPlayerEditProperty(playerid, dialogidEx, responseEx, listitemEx, string:inputtextEx[]); public OnPlayerEditProperty(playerid, dialogidEx, responseEx, listitemEx, string:inputtextEx[]) { if(!responseEx) { return 0; } new propertyid = GetPVarInt(playerid, "EditingProperty"); switch(listitemEx) { case 0: // set the exterior position { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem, inputtext if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); new Float:x, Float:y, Float:z, Float:a; new int = GetPlayerInterior(playerid); new vw = GetPlayerVirtualWorld(playerid); GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); foreach(new i : Player) if(GetCurrentProperty(i) == propertyid) { if(i != playerid) SendAdminWarningF(i, "%s has changed the exterior position for this property.", ReturnPlayerRPName(playerid)); } Property_SetExtPos(propertyid, vw, int, x, y, z, a); SendAdminWarningF(playerid, "You've set the exterior position for this property. (ID %D)", propertyid); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_MSGBOX, "Set the exterior position at your current position", "{b3b3b3}Are you sure?", "Yes", "No"); } case 1: // set the interior position { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem, inputtext if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); new Float:x, Float:y, Float:z, Float:a; new int = GetPlayerInterior(playerid); GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); foreach(new i : Player) if(GetCurrentProperty(i) == propertyid) { if(i != playerid) SendAdminWarningF(i, "%s has changed the interior position for this property.", ReturnPlayerRPName(playerid)); SetPlayerPos(i, x, y, z); SetPlayerFacingAngle(i, a); SetPlayerInterior(i, int); SetCameraBehindPlayer(i); } Property_SetIntPos(propertyid, int, x, y, z, a); SendAdminWarningF(playerid, "You've set the interior position for this property. (ID %d)", propertyid); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_MSGBOX, "Set the interior position at your current position", "{b3b3b3}Are you sure?", "Yes", "No"); } case 2: // Set the property interior ID { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); new interiorid; if(sscanf(inputtext, "i", interiorid) || !IsValidInterior(interiorid)) { SendErrorMessage(playerid, "You specified an invalid interior ID."); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 2, inputtextEx); } new Float:x, Float:y, Float:z, Float:a; new int = Interior_GetInterior(interiorid); Interior_GetPosition(interiorid, x, y, z, a); foreach(new i : Player) if(GetCurrentProperty(i) == propertyid) { if(i != playerid) SendAdminWarningF(i, "%s has changed the interior for this property.", ReturnPlayerRPName(playerid)); SetPlayerPos(i, x, y, z); SetPlayerFacingAngle(i, a); SetPlayerInterior(i, int); SetCameraBehindPlayer(i); } Property_SetIntPos(propertyid, int, x, y, z, a); OnPlayerEditProperty(playerid, dialogidEx, responseEx, 2, inputtextEx); SendAdminWarningF(playerid, "You've set Property ID %d interior to %d.", propertyid, interiorid); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_INPUT, "Set the property interior ID", "{b3b3b3}Type the new property interior ID", "Ok", "Back"); } case 3: // Set the owner (to be updated) { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem, inputtext if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); OnPlayerEditProperty(playerid, dialogidEx, responseEx, 3, inputtextEx); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_INPUT, "Set the property owner", "{b3b3b3}Type the new owner name (or ID if they're online)", "Ok", "Back"); } case 4: // Set the type { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); new type; if(sscanf(inputtext, "i", type) || (!IsHouseTypeValid(type) && !IsBusinessTypeValid(type) && !IsEntranceTypeValid(type))) { SendErrorMessage(playerid, "That property type is not defined yet."); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 4, inputtextEx); } Property_SetType(propertyid, type); SendAdminWarningF(playerid, "You've set Property ID %d type to %d - %s.", propertyid, type, Property_GetTypeName(type)); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_INPUT, "Set the property type", "{b3b3b3}Type the new property type", "Ok", "Back"); } case 5: // Set the description { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); if(isnull(inputtext) || IsNumeric(inputtext)) { SendErrorMessage(playerid, "You specified an invalid description."); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 5, inputtextEx); } if(strlen(inputtext) > MAX_PROP_DESCRIPTION - 1) { SendErrorMessageF(playerid, "Invalid description length, it must be below %d characters.", MAX_PROP_DESCRIPTION - 1); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 5, inputtextEx); } Property_SetDescription(propertyid, inputtext); SendAdminWarningF(playerid, "You've set Property ID %d description to %s.", propertyid, inputtext); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_INPUT, "Set the description", "{b3b3b3}Type the new description", "Ok", "Back"); } case 6: // Set the address { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); if(isnull(inputtext) || IsNumeric(inputtext)) { SendErrorMessage(playerid, "You specified an invalid address."); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 6, inputtextEx); } if(strlen(inputtext) > MAX_PROP_ADDRESS - 1) { SendErrorMessageF(playerid, "Invalid address length, it must be below %d characters.", MAX_PROP_ADDRESS - 1); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 6, inputtextEx); } Property_SetAddress(propertyid, inputtext); SendAdminWarningF(playerid, "You've set Property ID %d address to %s.", propertyid, inputtext); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_INPUT, "Set the address", "{b3b3b3}Type the new address", "Ok", "Back"); } case 7: // Set the price { inline _response(response, listitem, string:inputtext[]) { #pragma unused listitem if(!response) return ShowPropertyEditingDialog(playerid, propertyid); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property ID."); if(isnull(inputtext) || !IsNumeric(inputtext) || strval(inputtext) < 0) { SendErrorMessage(playerid, "You specified an invalid price."); return OnPlayerEditProperty(playerid, dialogidEx, responseEx, 7, inputtextEx); } new price = strval(inputtext); Property_SetPrice(propertyid, price); SendAdminWarningF(playerid, "You've set Property ID %d price to $%s.", propertyid, MoneyFormat(price)); } Dialog_ShowCallback(playerid, using inline _response, DIALOG_STYLE_INPUT, "Set the price", "{b3b3b3}Type the new price", "Ok", "Back"); } } return 1; } CMD:editproperty(playerid, params[]) { new propertyid; if(isnull(params)) { propertyid = GetCurrentProperty(playerid); if(propertyid == INVALID_PROPERTY_ID) { propertyid = GetNearbyProperty(playerid); if(propertyid == INVALID_PROPERTY_ID) return SendErrorMessage(playerid, "You need to be at one of the properties to edit it. (or type /editproperty id)"); } } else { if(sscanf(params, "i", propertyid)) return SendSyntaxMessage(playerid, "/editproperty (id)"); if(!IsValidProperty(propertyid)) return SendErrorMessage(playerid, "You specified an invalid property."); } ShowPropertyEditingDialog(playerid, propertyid); return 1; }