strins() being weird
#1

Function:

pawn Код:
stock my_ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[])
{
    strins(caption, "{B800C6}", 0, 8);
    strins(info, "{FFFFFF}", 0, 8);
    ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
    return 1;
}

#if defined _ALS_ShowPlayerDialog
    #undef ShowPlayerDialog
#else
    #define _ALS_ShowPlayerDialog
#endif
#define ShowPlayerDialog my_ShowPlayerDialog
Code:

pawn Код:
new lstring[256];
format(lstring, sizeof(lstring), "This name ({FFFF82}%s{FFFFFF}) is registered. You must login to continue.\nIf this is your account, please enter the password you chose when registering below.\nIf not, please quit and reconnect with a different name.", pName[playerid]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", lstring, "Login", "Quit");
The purpose of this is to add the embedded colors to 'caption' and 'info' automatically, so they can easily be changed. I will also be adding more stuff to the my_ShowPlayerDialog function later on, so it IS needed.

Result: http://www.imagebam.com/image/0f41e8170467716

Question: Why are the buttons weird?
Reply
#2

nevermind
Reply
#3

You can't do that as there's not enough memory allocated to insert that part into there (so you're actually inserting "illegal" memory). You will have to create a new variable and format it in there.
Reply
#4

That means I have to create 2048+64 cells. I don't really want to do that. Isn't there another way?
Reply
#5

Sure there is:
pawn Код:
#define ShowPlayerDialogEx(%0,%1,%2,%3,%4,%5,%6) \
    ShowPlayerDialog((%0), (%1), (%2), "{B800C6}" %3, "{FFFFFF}" %4, (%5), (%6))
Reply
#6

Quote:

C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : warning 215: expression has no effect
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : warning 215: expression has no effect
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : warning 215: expression has no effect
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : error 001: expected token: ";", but found ")"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\NewServer.pwn(99) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Line 99:

pawn Код:
new lstring[256];
        format(lstring, sizeof(lstring), "This name ({FFFF82}%s{FFFFFF}) is registered. You must login to continue.\nIf this is your account, please enter the password you chose when registering below.\nIf not, please quit and reconnect with a different name.", pName[playerid]);
        ShowPlayerDialogEx(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", lstring, "Login", "Quit");
(The ShowPlayerDialogEx function)


Can you make it replace ShowPlayerDialog, so I don't need 'Ex'?
Reply
#7

Well my macro will only work for constant strings. I guess you'll have to use the string variable and format it there. Just use static string variable.
Reply
#8

But what I'm saying is, I don't want to have to create a 2048 and 64 cell string to manipulate the string in. There MUST be a way
Reply
#9

Sorry, not that I know of. If you're using constant strings use my macro, otherwise just create a global one. 2048 isn't that bad.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)