Dialog string
#1

I need help, i dont know what to search for so.

I have a dialog lets say like this:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Tog", "Join Msgs - On \nGlobal Chat - Off", "Tog", "Cancel");
Joining msgs is a player variable that is 0 or 1 if enabled, same with global chat.
But is there a way to set the string in textdraw with 'on' or 'off' according to the joiningmsgs var?
So when i click on 'Join msgs' it will show the same dialog again but with 'Join Msgs - Off'.
Reply
#2

Yes. Use
PHP код:
if([Player variable] == 1)
{
     
ShowPlayerDialog(...);// if it's ON
}
else
{
     
ShowPlayerDialog(...);// if it's OFF

Reply
#3

that could work, but the challenge is that there is many variables in the same dialog.
Join Msgs, Global Chat etc... So if im gonna use that way, it will be a hell alot of if, else if, else if...
Reply
#4

[MG]Dimi, it couldn't get any worse than that.

What you need is quite simple.
pawn Код:
// I'll just assume your variable names are something like this:
new dialogLine[128];
dialogLine = "Join messages - ";
strcat(dialogLine, (JoinMSGs == true) ? ("on\n") : ("off\n"));

if(GlobalChat == true)
    strcat(dialogLine, "Global chat - on\n");
else
    strcat(dialogLine, "Global chat - off\n");

// Show the dialog...
And so on...

If the first lines seem confusing to you, it can also be perfectly done like this:
pawn Код:
// I'll just assume your variable names are something like this:
new dialogLine[128];
if(JoinMSGs == true)
    strcat(dialogLine, "Join messages - on\n");
else
    strcat(dialogLine, "Join messages - off\n");

if(GlobalChat == true)
    strcat(dialogLine, "Global chat - on\n");
else
    strcat(dialogLine, "Global chat - off\n");

// Show the dialog
Reply
#5

Well maybe you could format a lot of messages in one. Like this:
PHP код:
if(variable1format(option1,sizeof(option1),...);
if(!
variable1format(option1,sizeof(option1),...);
....
format(text,sizoef(text),"%s\n%s\n...",option1,option2...);
ShowPlayerDialog(playerid,dialog,iddialog_style,cation[],text/*here is last msg we formatted*/,...); 
Reply
#6

Thanks all! I used ******'s one, cuz it was the easiest one
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)