if(dialogid == DIALOG_SETTINGSMAIN)
{
if(response)
{
new toggleOnOff[3];
switch (listitem) {
new bool:togglemate = true;
new toggletext[3];
if (togglemate = true)
{
format(output[], len, const format[], ...)
}
case 0:
{
ShowPlayerDialog(playerid, DIALOG_SETTINGSSUB, DIALOG_STYLE_TABLIST_HEADERS, "Player Settings - Toggle", "Toggle\tStatus\n\
---General---\n\
PHONE\tOFF\n\
Newbie Chat\tOFF\n\
News\tOFF\n\
OOC Chat\tOFF\n\
Whispers\tOFF\n\
Private Radio(/PR)\tOFF\n\
Hunger Meter\tOFF\n\
Famed\tOFF\n\
VIP\tOFF\n\
---GROUPS---\n\
Dept\tOFF\n\
International\tOFF\n\
OOC Group (/g)\tOFF\n\
Radio\tOFF\n\
BUG Chat\tOFF\n\
Biz Radio\tOFF\n\
Point Messages\tOFF\n", "Select", "Close");
}
}
}
}
// OnDialogResponse
if (dialogid == DIALOG_SETTINGSMAIN)
{
if (response)
{
switch (listitem)
{
case 0:
{
phoneVar = !phoneVar;
}
case 1:
{
newbieChatVar = !newbieChatVar;
}
// etc
}
// other possible code here, like ShowPlayerDialog
}
return 1;
}

#include <a_samp>
#include <ZCMD>
/* Debug
CMD:lol(playerid, params[]) {
ShowPlayerTogglesDialog(playerid);
return true;
}
#define DIALOG_SETTINGSSUB 1234
#define DIALOG_SETTINGSMAIN 1235
*/
//Let's structure our toggle options using an enum so its easier to add or remove things later
enum e_TOGGLES {
TOGGLE_PHONE,
TOGGLE_NEWBIE_CHAT,
TOGGLE_NEWS,
TOGGLE_OOC_CHAT,
TOGGLE_WHISPERS,
TOGGLE_PRIVATE_RADIO,
TOGGLE_HUNGER_METER,
TOGGLE_FAMED,
TOGGLE_VIP,
TOGGLE_DEPT,
TOGGLE_INTERNATIONAL,
TOGGLE_OOC_GROUP,
TOGGLE_RADIO,
TOGGLE_BUG_CHAT,
TOGGLE_BIZ_RADIO,
TOGGLE_POINT_MESSAGES
};
//The enum above is for scripting, this variable here is the name which players see in dialog
new ToggleLabels[e_TOGGLES][] = {
"Phone",
"Newbie Chat",
"News",
"OOC Chat",
"Whispers",
"Private Radio (/PR)",
"Hunger Meter",
"Famed",
"VIP",
"Dept",
"International",
"OOC Group",
"Radio",
"BUG Chat",
"Biz Radio",
"Point Messages"
};
//Each player needs to have their own toggle settings
new bool:PlayerToggleSettings[MAX_PLAYERS][e_TOGGLES];
//We make the dialog viewer a seperate function so as to keep code clean
stock ShowPlayerTogglesDialog(playerid) {
new
dialog_line[50],
dialog_text[400]
;
//Loop through all toggle options
for(new e_TOGGLES:i; i < e_TOGGLES; i++) {
//Add any headers if needed
if(i == TOGGLE_PHONE) strcat(dialog_text, "Toggle\tStatus\n---General---\n");
if(i == TOGGLE_DEPT) strcat(dialog_text, "---Groups---\n");
//Format each line with the player's toggle option and push it to the larger array
format(dialog_line, sizeof dialog_line, "%s\t%s\n", ToggleLabels[i], PlayerToggleSettings[playerid][i] ? ("{8FE3FF}ON") : ("{4A4C4D}OFF"));
strcat(dialog_text, dialog_line);
}
ShowPlayerDialog(playerid, DIALOG_SETTINGSSUB, DIALOG_STYLE_TABLIST_HEADERS, "Player Settings - Toggle", dialog_text, "Select", "Close");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_SETTINGSMAIN) {
if(response) {
switch(listitem) {
case 0: {
ShowPlayerTogglesDialog(playerid);
}
}
} else {
}
return true;
}
if(dialogid == DIALOG_SETTINGSSUB) {
if(response) {
switch(listitem) {
case 0,10: {
//Ignore the headers
ShowPlayerTogglesDialog(playerid);
}
default: {
//Fix the listitem offset caused by headers
new toggle_index = listitem - 1;
if(listitem > 10) toggle_index -= 1;
//Make sure the player is not sending fake listitems which will cause index errors
if(!(0 <= toggle_index < _:e_TOGGLES)) {
SendClientMessage(playerid, 0xFF0000FF, "Invalid toggle option.");
} else {
//Reverse the value of the toggle option of the player
PlayerToggleSettings[playerid][e_TOGGLES:toggle_index] = !PlayerToggleSettings[playerid][e_TOGGLES:toggle_index];
}
//Show them the updated dialog
ShowPlayerTogglesDialog(playerid);
}
}
} else {
//Show Settings Main
}
return true;
}
return false;
}
|
*Brushing off my pawn skills*
![]() Код:
#include <a_samp>
#include <ZCMD>
/* Debug
CMD:lol(playerid, params[]) {
ShowPlayerTogglesDialog(playerid);
return true;
}
#define DIALOG_SETTINGSSUB 1234
#define DIALOG_SETTINGSMAIN 1235
*/
//Let's structure our toggle options using an enum so its easier to add or remove things later
enum e_TOGGLES {
TOGGLE_PHONE,
TOGGLE_NEWBIE_CHAT,
TOGGLE_NEWS,
TOGGLE_OOC_CHAT,
TOGGLE_WHISPERS,
TOGGLE_PRIVATE_RADIO,
TOGGLE_HUNGER_METER,
TOGGLE_FAMED,
TOGGLE_VIP,
TOGGLE_DEPT,
TOGGLE_INTERNATIONAL,
TOGGLE_OOC_GROUP,
TOGGLE_RADIO,
TOGGLE_BUG_CHAT,
TOGGLE_BIZ_RADIO,
TOGGLE_POINT_MESSAGES
};
//The enum above is for scripting, this variable here is the name which players see in dialog
new ToggleLabels[e_TOGGLES][] = {
"Phone",
"Newbie Chat",
"News",
"OOC Chat",
"Whispers",
"Private Radio (/PR)",
"Hunger Meter",
"Famed",
"VIP",
"Dept",
"International",
"OOC Group",
"Radio",
"BUG Chat",
"Biz Radio",
"Point Messages"
};
//Each player needs to have their own toggle settings
new bool:PlayerToggleSettings[MAX_PLAYERS][e_TOGGLES];
//We make the dialog viewer a seperate function so as to keep code clean
stock ShowPlayerTogglesDialog(playerid) {
new
dialog_line[50],
dialog_text[400]
;
//Loop through all toggle options
for(new e_TOGGLES:i; i < e_TOGGLES; i++) {
//Add any headers if needed
if(i == TOGGLE_PHONE) strcat(dialog_text, "Toggle\tStatus\n---General---\n");
if(i == TOGGLE_DEPT) strcat(dialog_text, "---Groups---\n");
//Format each line with the player's toggle option and push it to the larger array
format(dialog_line, sizeof dialog_line, "%s\t%s\n", ToggleLabels[i], PlayerToggleSettings[playerid][i] ? ("{8FE3FF}ON") : ("{4A4C4D}OFF"));
strcat(dialog_text, dialog_line);
}
ShowPlayerDialog(playerid, DIALOG_SETTINGSSUB, DIALOG_STYLE_TABLIST_HEADERS, "Player Settings - Toggle", dialog_text, "Select", "Close");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_SETTINGSMAIN) {
if(response) {
switch(listitem) {
case 0: {
ShowPlayerTogglesDialog(playerid);
}
}
} else {
}
return true;
}
if(dialogid == DIALOG_SETTINGSSUB) {
if(response) {
switch(listitem) {
case 0,10: {
//Ignore the headers
ShowPlayerTogglesDialog(playerid);
}
default: {
//Fix the listitem offset caused by headers
new toggle_index = listitem - 1;
if(listitem > 10) toggle_index -= 1;
//Make sure the player is not sending fake listitems which will cause index errors
if(!(0 <= toggle_index < _:e_TOGGLES)) {
SendClientMessage(playerid, 0xFF0000FF, "Invalid toggle option.");
} else {
//Reverse the value of the toggle option of the player
PlayerToggleSettings[playerid][e_TOGGLES:toggle_index] = !PlayerToggleSettings[playerid][e_TOGGLES:toggle_index];
}
//Show them the updated dialog
ShowPlayerTogglesDialog(playerid);
}
}
} else {
//Show Settings Main
}
return true;
}
return false;
}
|