[Tutorial] Simple Name Tag for Admins and Donators
#1

Introduction

hi guys i know that some of you may think this is easy, but i saw some players made a question about this, so i'm here to help those who wanna make a Name tag ([Admin],[Donator], etc) for players(we do not really need Name tag for players) for admins, But remember: DO NOT COPY AND JUST PASTE the god, so lets start scripting or coding .
Scripting

So i don't know what you using or what your enum is.. but my enums are pDonators and pAdmin:
Код:
enum pInfo
{
    pDonator,
    pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
----------------------------------------------------------------------------------------------------------------------------------------------
Remember: I don't know what you using for this thing, but im using Y_INI, and if you wanna use Y_INI, you gotta search for it.
---------------------------------------------------------------------------------------------------------------------------------------------- So lets proceed...

so lets stat with the Admins first:
Код:
public OnPlayerText(playerid, text[]) 
{
    if(PlayerInfo[playerid][pAdmin] >= 1) //pAdmin is my enum i don't know whats your enum, also number "1" indicates the level of the admin, i got 1-8 admin levels, you can choose what level are yours.
    {
        new string[150], name[MAX_PLAYER_NAME]; //Lets make a new string and a name..
        GetPlayerName(playerid, name, MAX_PLAYER_NAME); // This is the name
        format(string,sizeof(string),"{993300}[ADMIN] {33CC99}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text); //Make your format, you can change the colors...
        SendClientMessageToAll(GetPlayerColor(playerid), string); //SendClientMessageToAll so all can see your chat, "GetPlayerColor" doesn't work if put a color on his name, remove the color so he if he do /red ( if you have a command ) his name will be color red.. 
        return 0; 
    }
put this Under the Last thing we did.
Код:
    if(PlayerInfo[playerid][pDonator] >= 1) 
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"{FF6600}[DONATOR] {990099}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text); 
        SendClientMessageToAll(GetPlayerColor(playerid), string); 
        return 0; 
    }
Then put this again on the last time we did..
Код:
    if(PlayerInfo[playerid][pAdmin] >= 0) //Recommended, also put this at the really bottom( i don't know why), just put in at the very bottom at the Playertext, this is the Chat of the Player we need GetPlayercolor here..
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"%s {999999}[%i]: {FFFFFF}%s", name, playerid, text); 
        SendClientMessageToAll(GetPlayerColor(playerid), string);
        return 0; 
    }
    return 1;
}
Full Code:

Код:
public OnPlayerText(playerid, text[]) 
{
    if(PlayerInfo[playerid][pAdmin] >= 1) 
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"{993300}[ADMIN] {33CC99}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string); 
        return 0; 
    }
    if(PlayerInfo[playerid][pDonator] >= 1) 
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"{FF6600}[DONATOR] {990099}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text); 
        SendClientMessageToAll(GetPlayerColor(playerid), string); 
        return 0; 
	}
    if(PlayerInfo[playerid][pAdmin] >= 0) 
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"%s {999999}[%i]: {FFFFFF}%s", name, playerid, text); 
        SendClientMessageToAll(GetPlayerColor(playerid), string);
        return 0; 
    }
    return 1;
}
Reply
#2

++rep if this helps you
Reply
#3

I not see a tutorial, I see a broken script without offending

i think:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], name[MAX_PLAYER_NAME] ;
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        format(string,sizeof(string),"{993300}[ADMIN] {33CC99}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string); // ?? GetPlayerColor???? you put color {993300}
        return 0;
    }
    else if(PlayerInfo[playerid][pDonator] >= 1)
    {
        format(string,sizeof(string),"{FF6600}[DONATOR] {990099}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string);  // Again use GetPlayerColor?? Put color {FF6600}
        return 0;
    }
    else
    {
        format(string,sizeof(string),"%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
        return 0;
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Cerealguy
Посмотреть сообщение
I not see a tutorial, I see a broken script without offending

i think:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], name[MAX_PLAYER_NAME] ;
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        format(string,sizeof(string),"{993300}[ADMIN] {33CC99}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
        return 0;
    }
    else if(PlayerInfo[playerid][pDonator] >= 1)
    {
        format(string,sizeof(string),"{FF6600}[DONATOR] {990099}%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
        return 0;
    }
    else
    {
        format(string,sizeof(string),"%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
        return 0;
    }
    return 1;
}
Total correct, People should first learn and then teach.
Reply
#5

Is not it easier to use the case?
Reply
#6

Quote:
Originally Posted by SnoopDy
Посмотреть сообщение
Is not it easier to use the case?
Can't use case in that case, because it's not the same variable,
read this

A better way to do it.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
   
    if(PlayerInfo[playerid][pAdmin])
        format(string,sizeof(string),"{993300}[ADMIN] {%06x}%s {999999}[%i]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, name, playerid, text);
    else if(PlayerInfo[playerid][pDonator])
        format(string,sizeof(string),"{FF6600}[DONATOR] {%06x}%s {999999}[%i]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, name, playerid, text);
    else
        format(string,sizeof(string),"%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
       
    SendClientMessageToAll(GetPlayerColor(playerid), string);
    return 0;
}
Reply
#7

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Can't use case in that case, because it's not the same variable,
read this

A better way to do it.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
   
    if(PlayerInfo[playerid][pAdmin])
        format(string,sizeof(string),"{993300}[ADMIN] {%06x}%s {999999}[%i]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, name, playerid, text);
    else if(PlayerInfo[playerid][pDonator])
        format(string,sizeof(string),"{FF6600}[DONATOR] {%06x}%s {999999}[%i]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, name, playerid, text);
    else
        format(string,sizeof(string),"%s {999999}[%i]: {FFFFFF}%s", name, playerid, text);
       
    SendClientMessageToAll(GetPlayerColor(playerid), string);
    return 0;
}
Okay,if its RP Mode,eazy use ProxDetector than "SendClientMessageToAll" )))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)