Need Help with Tag
#1

Well i was making a tag like Deadly(0) when the player chat's but all of it just messed up my gamemode
So, I was Just Wondering how to add it?
Reply
#2

- deleted -
Reply
#3

What do you mean? A tag when someone chat like:
"Cannary [Deadly]: (message)" ?
pawn Код:
public OnPlayerText(playerid, text[])
{
    new pText[128];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName,sizeof(pName));
    if(GetPlayerScore(playerid) == 1000)
    {
        format(pText, sizeof (pText), "%s (ID: %d) [{#FF0000}Deadly{FFFFFF}]: %s", pName, playerid, text);
        SendPlayerMessageToAll(playerid, pText);
    }
    else
    {
        format(pText, sizeof (pText), "%s (ID: %d): %s",pName, playerid, text);
        SendPlayerMessageToAll(playerid, pText);
    }
    return 0; // ignore the default text and send the custom one
}
I think that will work, pardon me if it doesn't
Reply
#4

Cannary2048's code will work (Note change player message to client mesage)
But making a function that gets the tag from the score would be easier if you want to use them somewhere else.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pText[160];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName,sizeof(pName));
    if(GetPlayerScore(playerid) >= 1000)
    {
        format(pText, sizeof (pText), "{%06x}%s (ID: %d) [{FF0000}%s{FFFFFF}]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, pName, playerid, GetTagFromScore(playerid), text);
        SendClientMessageToAll(-1, pText);
    }
    else
    {
        format(pText, sizeof (pText), "{%06x}%s (ID: %d): {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, pName, playerid, text);
        SendClientMessageToAll(-1, pText); // CLIENT message not PLAYER message.
        // Player messages are "Name: your formatted string"
        // Client messages are "your formatted string"
    }
    return 0;
}

GetTagFromScore(playerid)
{
    new string[32];
    switch(GetPlayerScore(playerid))
    {
        case 1000: format(string, sizeof (string), "Deadly");
        case 2000: format(string, sizeof (string), "what ever you want");
        // ...
    }
    return string;
}
Reply
#5

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Cannary2048's code will work (Note change player message to client mesage)
But making a function that gets the tag from the score would be easier if you want to use them somewhere else.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pText[160];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName,sizeof(pName));
    if(GetPlayerScore(playerid) >= 1000)
    {
        format(pText, sizeof (pText), "{%06x}%s (ID: %d) [{FF0000}%s{FFFFFF}]: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, pName, playerid, GetTagFromScore(playerid), text);
        SendClientMessageToAll(-1, pText);
    }
    else
    {
        format(pText, sizeof (pText), "{%06x}%s (ID: %d): {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, pName, playerid, text);
        SendClientMessageToAll(-1, pText); // CLIENT message not PLAYER message.
        // Player messages are "Name: your formatted string"
        // Client messages are "your formatted string"
    }
    return 0;
}

GetTagFromScore(playerid)
{
    new string[32];
    switch(GetPlayerScore(playerid))
    {
        case 1000: format(string, sizeof (string), "Deadly");
        case 2000: format(string, sizeof (string), "what ever you want");
        // ...
    }
    return string;
}
Ah, yes, I copied from the wiki and it's SendPlayerMessageToAll
Reply
#6

No i mean something like this when player types text in chat then this happens Deadly(0): What ever the Message
it is necessary for stunt servers :P
Reply
#7

pawn Код:
new string[144];
format(string, sizeof (string), "{FF0000}Deadly(%i): %s", playerid, text);
SendClientMessageToAll(-1, string);
Reply
#8

i have to add that in OnPlayerText?
Reply
#9

Yes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)