Adding %s to showplayerdialog..
#1

Title..

CMD:credits(playerid, params[])
{
new pname[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, pname,sizeof(pname));
format(str, sizeof(str), "Credits", pname);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, str, "Scripters: StuunG23\nMappers: StuunG23\nTesters: PedroX_, Syntec,Yannick, Ultrascripter\nSpecial Thanks to: Pedrox,Syntec,Ultrascripter, Yannick,Dopeboy,Dynamite\nAnd for the sa-mp development team. and thank you %s for playing in our server","Ok","");
return 1;
}

How do i add it? i searched but no results..
Reply
#2

You can't format a string within the ShowPlayerDialog-function. You first have to format the string and then show the string in that function:

pawn Code:
CMD:credits(playerid, params[])
{
    new pname[MAX_PLAYER_NAME], str[280];
    GetPlayerName(playerid, pname,sizeof(pname));
    format(str, sizeof(str),"Scripters: StuunG23\nMappers: StuunG23\nTesters: PedroX_, Syntec,Yannick, Ultrascripter\nSpecial Thanks to: Pedrox,Syntec,Ultrascripter, Yannick,Dopeboy,Dynamite\nAnd for the sa-mp development team. and thank you %s for playing in our server", pname);
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Credits", str, "Ok","");
    return 1;
}
Reply
#3

Well once i did it and it was the opposite. credits was in the msg and the people in the credits were the title
Reply
#4

Because you put the "str" in the wrong parameter.
Reply
#5

BUMP

I have cmd:info :

Code:
CMD:info(playerid, params[])
{
    //new string[256],targetid; blahblah
    ShowPlayerDialog(playerid, XXX, DIALOG_STYLE_MSGBOX, "Players name %s", string "Ok","");
    format(string,sizeof(string),"");
    return 1;
}
Where to put this:

Code:
GetName(targetid)
So i can see targetid name on dialog header ... ?
Reply
#6

https://sampwiki.blast.hk/wiki/format

Like any other time you want to format a text.
Reply
#7

Quote:
Originally Posted by Vince
View Post
https://sampwiki.blast.hk/wiki/format

Like any other time you want to format a text.
Yes, i know about that and i tried:

Code:
format(string,sizeof(string),"",GetName(targetid));
But ingame dialog show "%s" instead of targetid name ..
Reply
#8

No, you need to format it into a string, you can't natively use formatting in regular functions. Example:
pawn Code:
new
     string[128],
     header[50];

format(header, sizeof header, "Players name %s", GetName(targetid));
ShowPlayerDialog(playerid, XXX, DIALOG_STYLE_MSGBOX, header, string, "Ok", "");
return 1;
}
Reply
#9

Quote:
Originally Posted by ThomasEvil
View Post
Yes, i know about that and i tried:

Code:
format(string,sizeof(string),"",GetName(targetid));
But ingame dialog show "%s" instead of targetid name ..
If you just wanted the name to display you could just do:

format(string,sizeof(string),GetName(targetid));

That's if the function GetName returns a string which I assume it does.
Reply
#10

Quote:
Originally Posted by Schneider
View Post
You can't format a string within the ShowPlayerDialog-function. You first have to format the string and then show the string in that function:

pawn Code:
CMD:credits(playerid, params[])
{
    new pname[MAX_PLAYER_NAME], str[280];
    GetPlayerName(playerid, pname,sizeof(pname));
    format(str, sizeof(str),"Scripters: StuunG23\nMappers: StuunG23\nTesters: PedroX_, Syntec,Yannick, Ultrascripter\nSpecial Thanks to: Pedrox,Syntec,Ultrascripter, Yannick,Dopeboy,Dynamite\nAnd for the sa-mp development team. and thank you %s for playing in our server", pname);
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Credits", str, "Ok","");
    return 1;
}
Wesley!!!!
Maak eens een goaltjuhhh!!!
Reply
#11

Quote:
Originally Posted by Abagail
View Post
No, you need to format it into a string, you can't natively use formatting in regular functions. Example:
pawn Code:
new
     string[128],
     header[50];

format(header, sizeof header, "Players name %s", GetName(targetid));
ShowPlayerDialog(playerid, XXX, DIALOG_STYLE_MSGBOX, header, string, "Ok", "");
return 1;
}
SO SIMPLE AND WORKING THANKS ALOT

I'am so noob i did not make this by myself
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)