GetPlayerName Help
#1

Hi

i was making a help menu for a server and i want to Add Player name On it like which Player reading help menu
server get his name on help menu right there

Thanks for reading : Player Name Here :


Код:
if(strcmp(cmdtext,"/Help") == 0)
    {
    new Str1[ ] =   " Hello Friends \n\
                          \n\
                          The Best Of server " Player Name Here "\n",
        StrF[ 1100 ];

    format( StrF, sizeof StrF, "%s%s%s%s%s%s%s%s%s", Str1 );
    ShowPlayerDialog( playerid, DIALOG_donate, DIALOG_STYLE_MSGBOX , "{E01649}Help Menu", StrF, "OK", "CANCEL" );
    return 1;
    }
can anyone help
i tryed it too but i was failed
Reply
#2

Try this
Код:
if(strcmp(cmdtext,"/Help") == 0)
    {
    new StrF[ 1100 ];
    format( StrF, sizeof StrF, "Hello Friends \n\n\n\nThe Best Of server %s \n", GetPlayerName(playerid));
    ShowPlayerDialog( playerid, DIALOG_donate, DIALOG_STYLE_MSGBOX , "{E01649}Help Menu", StrF, "OK", "CANCEL" );
    return 1;
    }
Reply
#3

hmm i didn't get it

here is whole cmd
Код:
    if(strcmp(cmdtext,"/donate") == 0)
    {
    new Str1[ ] =   "{54FF9F}Hello Friends\n\nThis menu is for them who is insterested to donate for our server reason we're\n\
                     Belongs to a poor country we need help to keep online our server now we're requesting for Donations If anyone can donate for\n\
                     Our server Then we must very very thank full to them we will give them a reward\n",
        Str2[ ] =   "Insterested ? contatc to {EE799F}[S4S]Leon {517693}Or {EE799F}Sam_Hero {517693}pm Them on forums or In-Game Or email him : {B5A642}Leon_kenndy1@hotmail.com\n\
                     {517693}Donation Link given on our offical page {5EDA9E}| www.spsamp.tk | {517693}we're accepting all kinds of currency\n\
                     \nForum Registration Method based on Security Qustions\nQ.1 What's the Name of [SPS]Owner | Ans.{54FF9F} leon\n",
        Str3[ ] =   "{517693}Q.2 what is the teleport command of old airport | Ans. {54FF9F}/aa\n\n\
                     {517693}Many Many Thanks For Reading Our Donations Information Mr : {54FF9F}Player Name Here \n\
                     \n",
        StrF[ 2500 ];

    format( StrF, sizeof StrF, "%s%s%s%s%s%s%s%s%s", Str1, Str2, Str3 );
    ShowPlayerDialog( playerid, DIALOG_donate, DIALOG_STYLE_MSGBOX , "{E01649}Donation Menu", StrF, "OK", "CANCEL" );
    return 1;
    }
Reply
#4

Here
Код:
if(strcmp(cmdtext,"/donate") == 0)
    {
    new Str1[ ] =   "{54FF9F}Hello Friends\n\nThis menu is for them who is insterested to donate for our server reason we're\n\
                     Belongs to a poor country we need help to keep online our server now we're requesting for Donations If anyone can donate for\n\
                     Our server Then we must very very thank full to them we will give them a reward\n",
        Str2[ ] =   "Insterested ? contatc to {EE799F}[S4S]Leon {517693}Or {EE799F}Sam_Hero {517693}pm Them on forums or In-Game Or email him : {B5A642}Leon_kenndy1@hotmail.com\n\
                     {517693}Donation Link given on our offical page {5EDA9E}| www.spsamp.tk | {517693}we're accepting all kinds of currency\n\
                     \nForum Registration Method based on Security Qustions\nQ.1 What's the Name of [SPS]Owner | Ans.{54FF9F} leon\n",
        Str3[ ] =   "{517693}Q.2 what is the teleport command of old airport | Ans. {54FF9F}/aa\n\n\
                     {517693}Many Many Thanks For Reading Our Donations Information",
        StrF[ 2500 ];

    format( StrF, sizeof StrF, "%s%s%s%s%s%s%s%s%s.Mr : {54FF9F}%s\n\n", Str1, Str2, Str3, GetPlayerName(playerid));
    ShowPlayerDialog( playerid, DIALOG_donate, DIALOG_STYLE_MSGBOX , "{E01649}Donation Menu", StrF, "OK", "CANCEL" );
    return 1;
    }
Reply
#5

I suggest using a stock or function to retrieve the name, Makes it much easier

Код:
/*
Here is two options you can use, you can either use ZCMD or strcmp. Up to you. Hope this helps you out
*/
#define			DIALOG_DONATE			1

GetName(playerid)
{
    new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	return pName;
}

if(strcmp(cmdtext,"/Help") == 0)
{
	new string[256];
    format(string, sizeof string, "Hello friends\n\n\n\nThe best of server %s\n", GetName(playerid));
    ShowPlayerDialog(playerid, DIALOG_DONATE, DIALOG_STYLE_MSGBOX , "{E01649}Help Menu", string, "Ok", "Close");
    return 1;
}

CMD:help(playerid, params[])
{
	new string[256];
	format(string, sizeof string, "Hello friends\n\n\n\nThe best of server %s\n", GetName(playerid));
	ShowPlayerDialog(playerid, DIALOG_DONATE, DIALOG_STYLE_MSGBOX, "{E01649}Help Menu", string, "Ok", "Close");
	return 1;
}
EDIT: Ops ^ Didnt see someone is helping you already, oh well. you can use this if you want, maybe it will help you
Reply
#6

Код:
D:\Others\101SSCAM\samp03x_svr_R1-2_win32\gamemodes\xd.pwn(5506) : warning 202: number of arguments does not match definition
D:\Others\101SSCAM\samp03x_svr_R1-2_win32\gamemodes\xd.pwn(5506) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           5032 bytes
Code size:          2694576 bytes
Data size:           437392 bytes
Stack/heap size:      16384 bytes; estimated max. usage=7119 cells (28476 bytes)
Total requirements: 3153384 bytes

2 Warnings.
2 warning :/ ?
Reply
#7

For all new members, please just don't try to help others if you don't know what are you DOING actually, and I really mean it, just stop doign it. Nicoh, what is this?

pawn Код:
GetPlayerName(playerid);
JUST tell me, what is that? Do you know that you are missing 2 arguments? Obviusly you have no idea that you DO. You might say why am I so mean towards you, I'm not, I'm just pointing towards an obvius fact. That in these last days, newbies try to help more experienced people, and they do it wrong.

ON TOPIC, Salsa, here's the correct code:

pawn Код:
if(strcmp(cmdtext,"/donate") == 0)
{
    new pName[24];
    GetPlayerName(playerid,pName,24);  
    new Str1[ ] =   "{54FF9F}Hello Friends\n\nThis menu is for them who is insterested to donate for our server reason we're\n\
                     Belongs to a poor country we need help to keep online our server now we're requesting for Donations If anyone can donate for\n\
                     Our server Then we must very very thank full to them we will give them a reward\n"
,
    Str2[ ] =   "Insterested ? contatc to {EE799F}[S4S]Leon {517693}Or {EE799F}Sam_Hero {517693}pm Them on forums or In-Game Or email him : {B5A642}Leon_kenndy1@hotmail.com\n\
                     {517693}Donation Link given on our offical page {5EDA9E}| http://www.spsamp.tk | {517693}we're accepting all kinds of currency\n\
                     \nForum Registration Method based on Security Qustions\nQ.1 What's the Name of [SPS]Owner | Ans.{54FF9F} leon\n"
,
    Str3[ ] =   "{517693}Q.2 what is the teleport command of old airport | Ans. {54FF9F}/aa\n\n\
                     {517693}Many Many Thanks For Reading Our Donations Information"
,
    StrF[ 2500 ];
    format( StrF, sizeof StrF, "%s%s%s.Mr : {54FF9F}%s\n\n", Str1, Str2, Str3, pName);
    ShowPlayerDialog( playerid, DIALOG_donate, DIALOG_STYLE_MSGBOX , "{E01649}Donation Menu", StrF, "OK", "CANCEL" );
    return 1;
}
Reply
#8

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
For all new members, please just don't try to help others if you don't know what are you DOING actually, and I really mean it, just stop doign it. Nicoh, what is this?

pawn Код:
GetPlayerName(playerid);
JUST tell me, what is that? Do you know that you are missing 2 arguments? Obviusly you have no idea that you DO. You might say why am I so mean towards you, I'm not, I'm just pointing towards an obvius fact. That in these last days, newbies try to help more experienced people, and they do it wrong.

ON TOPIC, Salsa, here's the correct code:

pawn Код:
if(strcmp(cmdtext,"/donate") == 0)
{
    new pName[24];
    GetPlayerName(playerid,pName,24);  
    new Str1[ ] =   "{54FF9F}Hello Friends\n\nThis menu is for them who is insterested to donate for our server reason we're\n\
                     Belongs to a poor country we need help to keep online our server now we're requesting for Donations If anyone can donate for\n\
                     Our server Then we must very very thank full to them we will give them a reward\n"
,
    Str2[ ] =   "Insterested ? contatc to {EE799F}[S4S]Leon {517693}Or {EE799F}Sam_Hero {517693}pm Them on forums or In-Game Or email him : {B5A642}Leon_kenndy1@hotmail.com\n\
                     {517693}Donation Link given on our offical page {5EDA9E}| http://www.spsamp.tk | {517693}we're accepting all kinds of currency\n\
                     \nForum Registration Method based on Security Qustions\nQ.1 What's the Name of [SPS]Owner | Ans.{54FF9F} leon\n"
,
    Str3[ ] =   "{517693}Q.2 what is the teleport command of old airport | Ans. {54FF9F}/aa\n\n\
                     {517693}Many Many Thanks For Reading Our Donations Information"
,
    StrF[ 2500 ];
    format( StrF, sizeof StrF, "%s%s%s.Mr : {54FF9F}%s\n\n", Str1, Str2, Str3, pName);
    ShowPlayerDialog( playerid, DIALOG_donate, DIALOG_STYLE_MSGBOX , "{E01649}Donation Menu", StrF, "OK", "CANCEL" );
    return 1;
}
well this is working very well +repu

+ i think they are trying to increasing their post
Reply
#9

To make it easier, you can also create a callback for this.

pawn Код:
stock GetPlayerNameEx(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, 24);
    return name;
}
This will require you to only do

pawn Код:
format(string, sizeof(string), "%s", GetPlayerNameEx(playerid));
instead of

pawn Код:
new name[24];
GetPlayerName(playerid, name);
format(string, sizeof(string), "%s", name);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)