How can i make this so a user can choose the name?
#1

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.
Reply
#2

Create a command with strtok, and then Update3DTextLabel.
Reply
#3

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
Reply
#4

What command system are you using? DCMD?
Reply
#5

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
Reply
#6

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]'
Reply
#7

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] ?
Reply
#8

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 ]!");
Reply
#9

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..
Reply
#10

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

by ******.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)