SA-MP Forums Archive
How can i make this so a user can choose the name? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can i make this so a user can choose the name? (/showthread.php?tid=151533)



How can i make this so a user can choose the name? - Ihsan_Cingisiz - 30.05.2010

Hello,
How can i do that a player can choose a name for
his name tag above his head, for this script.
Quote:

if(strcmp(cmdtext, "/player_on", true) == 0) {
if(IsPlayerAdmin(playerid))
label2[playerid] = Create3DTextLabel(">PLAYER<",COLOR_LIGHTBLUE,30.0, 40.0,50.0,40.0,0);
Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
SendClientMessage(playerid, COLOR_YELLOW, "** Player Name Tag = On");
return 1;

So at the place where >PLAYER< is writed, i want that a user can fill it
by his own what for text he wants.



Re: How can i make this so a user can choose the name? - Conroy - 30.05.2010

Create a command with strtok, and then Update3DTextLabel.


Re: How can i make this so a user can choose the name? - Ihsan_Cingisiz - 30.05.2010

Quote:
Originally Posted by Conroy
Create a command with strtok, and then Update3DTextLabel.
How can i do that?
Can you post the script?
I'm sorry, but i'm new to Scripting


Re: How can i make this so a user can choose the name? - Conroy - 30.05.2010

What command system are you using? DCMD?


Re: How can i make this so a user can choose the name? - Ihsan_Cingisiz - 30.05.2010

Quote:
Originally Posted by Conroy
What command system are you using? DCMD?
Uhh.. I'm just using strcmp,
i don't really know what you say


Re: How can i make this so a user can choose the name? - ReVo_ - 30.05.2010

pawn Код:
if(strcmp(cmd, "/player_on", true) == 0) {
        new scritta[256];
        scritta = strtok(cmdtext,idx);
    if(IsPlayerAdmin(playerid))
    {
         if(!LabelCreated[playerid])
         {
            label2[playerid] = Create3DTextLabel(scritta,COLOR_LIGHTBLUE,30.0,40.0,50.0,40.0,0);
        Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
        SendClientMessage(playerid, COLOR_YELLOW, "** Player Name Tag = On");
             LabelCreated[playerid] = 1;
          }
          else
          {
            Update3DTextLabelText(label2[playerid],COLOR_LIGHTBLUE,scritta);
        }
        }
      return 1;
}
Create var 'LabelCreated[MAX_PLAYERS]'


Re: How can i make this so a user can choose the name? - Ihsan_Cingisiz - 30.05.2010

Quote:
Originally Posted by [TLV
ReVo_ ]
pawn Код:
if(strcmp(cmd, "/player_on", true) == 0) {
        new scritta[256];
        scritta = strtok(cmdtext,idx);
    if(IsPlayerAdmin(playerid))
    {
         if(!LabelCreated[playerid])
         {
            label2[playerid] = Create3DTextLabel(scritta,COLOR_LIGHTBLUE,30.0,40.0,50.0,40.0,0);
        Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
        SendClientMessage(playerid, COLOR_YELLOW, "** Player Name Tag = On");
             LabelCreated[playerid] = 1;
          }
          else
          {
            Update3DTextLabelText(label2[playerid],COLOR_LIGHTBLUE,scritta);
        }
        }
      return 1;
}
Create var 'LabelCreated[MAX_PLAYERS]'
So can the player now type /player_on [Text] ?


Re: How can i make this so a user can choose the name? - ReVo_ - 30.05.2010

Add if(!strlen(scritta)) return SendClientMessage(playerid,COLOR_RED," Use: /player_on [TEXT]");

For check if player write text...

if you "filtre" the [ or ]

add end of you script
pawn Код:
CheckText(string[])
{
for(new i = 0; i < sizeof(string); i++)
{
if(string[i] == ']' || string[i] == '[') return 1;
}
return 0;
}
And in the command

if(CheckText(scritta)) return SendClientMessage(playerid,COLOR_RED," Not write [ or ]!");


Re: How can i make this so a user can choose the name? - Ihsan_Cingisiz - 30.05.2010

Quote:
Originally Posted by [TLV
ReVo_ ]
Add if(!strlen(scritta)) return SendClientMessage(playerid,COLOR_RED," Use: /player_on [TEXT]");

For check if player write text...

if you "filtre" the [ or ]

add end of you script
pawn Код:
CheckText(string[])
{
for(new i = 0; i < sizeof(string); i++)
{
if(string[i] == ']' || string[i] == '[') return 1;
}
return 0;
}
And in the command

if(CheckText(scritta)) return SendClientMessage(playerid,COLOR_RED," Not write [ or ]!");
Uhh...
I.. I.. Uh.. Can you please rewrite the script for me,
i don't exactly know what to do..


Re: How can i make this so a user can choose the name? - ReVo_ - 30.05.2010

What are you looking for? avoid writing the [] or check if the play wrote something after / player_on?

by ******.