SA-MP Forums Archive
Need Help with Tag - 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)
+--- Thread: Need Help with Tag (/showthread.php?tid=532745)



Need Help with Tag - Iloveimpulse - 20.08.2014

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?


Re: Need Help with Tag - AzaMx - 20.08.2014

- deleted -


Re: Need Help with Tag - Cannary2048 - 20.08.2014

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


Re: Need Help with Tag - Stinged - 20.08.2014

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;
}



Re: Need Help with Tag - Cannary2048 - 20.08.2014

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


Re: Need Help with Tag - Iloveimpulse - 20.08.2014

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


Re: Need Help with Tag - Stinged - 20.08.2014

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



Re: Need Help with Tag - Iloveimpulse - 20.08.2014

i have to add that in OnPlayerText?


Re: Need Help with Tag - Stinged - 20.08.2014

Yes.