Strings in Dialogs
#1

I'm not quite sure how exactly I would put a string into a dialog. For example, I would like a dialog to say, "Welcome to the server (playername)", using ReturnPlayerName. Can someone show me an example of using a string in a dialog input/list?
Reply
#2

Just format a string and insert it, example on input
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/test", cmdtext, true) == 0)
    {
        new str[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(str, sizeof(str), "Welcome to the server %s.", pName);
        ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_INPUT, "Welcome!", str, "Accept", "Cancel"); // Or switch str with title, doesnt really matter
        return 1;
    }
    return 0;
}
EDIT: damn it..vb doesn't have warnings to see if anyone else posted before us -____-
Reply
#3

Alright, that makes sense. Can anyone show me an example for a list?

For example, I want to make an Inventory Dialog. And, if they have a cellphone, then it will add a line which is cellphone. If they don't have a cellphone, the line won't be there.
Reply
#4

OK, but what if I have a LOT of items to add to the list, and MANY combinations.. For example: A colt 45, cigarrete, cellphone, watch, radio

But for example the person only has a radio and watch, or only has a ciggarette and colt, or only a colt and radio.. Do I have to do a seperate format for EVERY possibility?
Reply
#5

Well, it depends what you would want the dialog to say. Like, if you wanted it to say:
pawn Код:
Colt 45 - 1
Cigarrete - 1
Cellphone - 0
// etc
Then maybe not. You could just format one string, and show in the dialog the returned value of the variable.
pawn Код:
format(string, sizeof(string), "Colt 45 - %d \n Cigarrete - %d \n Cellphone - %d \n Watch - %d \n Radio - %d", /*variables holding the players information here*/);
In the end, it depends on what you have the variables saving (0 and 1 or something else) and what you want to display.
Reply
#6

Do what Grim_ said.

Its much easier telling them 0 = if they don't have it, 1 = if they do have it.

It would be easier, and less of a problem to hide it from the str if they do not have it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)