Insert a name before your name when using a command?
#1

Alright as the topic says "Insert a name before your name using a command?"

Example when you type in /aduty it should insert "Admin" infront of your name with the color red.

I can't really get the "string" stuff straight and I would be very thankful if someone could help me.
Reply
#2

Do you mean 3D text Label?
Reply
#3

Use SetPlayerName to change their names and to set their colors use SetPlayerColor. But it's better (My opinion) to have it in a 3d text label, use Create3DTextLabel to create a 3d text label with the text "On Duty!" then attach it to the player by using Attach3DTextLabelToPlayer and when they go off duty then you can use Delete3DTextLabel to delete the 3d text label.
Reply
#4

Alright this is what I have but it doesn't actually change my name.

pawn Код:
COMMAND:aduty(playerid, params[])
{
    new adminname[128];
   
    format(adminname, sizeof(adminname), "Administrator %s", GetName(playerid));
    SetPlayerName(playerid, adminname);
    SetPlayerHealth(playerid, 999999);
    SetPlayerArmour(playerid, 999999);
    SendClientMessage(playerid, COLOR_WHITE, "You are now on admin duty");
    return 1;
}
Reply
#5

What's too long? The "Administrator"? Anyways I changed it to "Admin" and it still doesn't work.

I want my name to be "Admin Wicked" with help of "%s".
Reply
#6

you cant use spaces in names! Anyways attach a text to the admin . . .
Reply
#7

Thanks Tigerkiller but how do I make a space between the Admin and %s? I know it's possible.
Reply
#8

it is possible for strings ex: in OnPlayerText but not for names but you can use "_" there is no other way to do this
Reply
#9

Quote:
Originally Posted by .Wicked
Посмотреть сообщение
Thanks Tigerkiller but how do I make a space between the Admin and %s? I know it's possible.
you
cant
have
spaces
in
names
Reply
#10

I
Think
You
Can.

Something like this might work.
pawn Код:
RemoveUnderscoreFromName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
   
    for(new i=0; i < MAX_PLAYER_NAME; ++i)
    {
        if(pName[i] == EOS)break;
        if(pName[i] == '_') pName[i] = ' ';
    }
    SetPlayerName(playerid, pName);
}
EDIT: Or if you don't want to change the players name for any reason.

pawn Код:
GetPlayerRpName(playerid)//couldn't think of a better name that is shorter than this.
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
   
    for(new i=0; i < MAX_PLAYER_NAME; ++i)
    {
        if(pName[i] == EOS)break;
        if(pName[i] == '_') pName[i] = ' ';
    }
    return pName;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)