SA-MP Forums Archive
Adding %s to showplayerdialog.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Adding %s to showplayerdialog.. (/showthread.php?tid=554796)



Adding %s to showplayerdialog.. - Glossy42O - 05.01.2015

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..


Re: Adding %s to showplayerdialog.. - Schneider - 05.01.2015

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;
}



Re: Adding %s to showplayerdialog.. - Glossy42O - 05.01.2015

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


Re: Adding %s to showplayerdialog.. - Beckett - 05.01.2015

Because you put the "str" in the wrong parameter.


Re: Adding %s to showplayerdialog.. - ThomasEvil - 06.06.2017

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 ... ?


Re: Adding %s to showplayerdialog.. - Vince - 06.06.2017

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

Like any other time you want to format a text.


Re: Adding %s to showplayerdialog.. - ThomasEvil - 06.06.2017

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 ..


Re: Adding %s to showplayerdialog.. - Abagail - 06.06.2017

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;
}



Re: Adding %s to showplayerdialog.. - Kyle - 06.06.2017

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.


Re: Adding %s to showplayerdialog.. - Ivor8000 - 06.06.2017

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!!!


Re: Adding %s to showplayerdialog.. - ThomasEvil - 06.06.2017

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