OnPlayerText
#1

Hi i have a problem with OnPlayerText

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(textv2, sizeof (textv2), "{D6D6D6}[Mдngija] [%d] %s: {F0F0F0}%s", playerid, name, text);
    SendPlayerMessageToAll(playerid, textv2);
   
    if(PlayerInfo[playerid][Adminlevel] == 1)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{0BE62C}[Moderaator] [%d] %s: {14F736}%s", playerid, name, text);
        SendPlayerMessageToAll(playerid, textv2);
    }
    else if(PlayerInfo[playerid][Adminlevel] == 2)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{DB170D}[Admin] [%d] %s: {FF6B63}%s", playerid, name, text);
        SendPlayerMessageToAll(playerid, textv2);
    }
    else if(PlayerInfo[playerid][Adminlevel] == 3)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{E3A617}[Peaadmin] [%d] %s: {FAB920}%s", playerid, name, text);
        SendPlayerMessageToAll(playerid, textv2);
    }
    else if(PlayerInfo[playerid][Adminlevel] == 4)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{0DDED3}[Abiomanik] [%d] %s: {1CFFF4}%s", playerid, name, text);
        SendPlayerMessageToAll(playerid, textv2);
    }
    else if(PlayerInfo[playerid][Adminlevel] >= 5)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{7564CC}[Omanik] [%d] %s: {A28FFF}%s", playerid, name, text);
        SendPlayerMessageToAll(playerid, textv2);
    }
    else if(PlayerInfo[playerid][VIP] >= 1)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{B2B54E}[VIP] [%d] %s: {E8ED5F}%s", playerid, name, text);
        SendPlayerMessageToAll(playerid, textv2);
    }
   
    return 1;
}
And results are:


But i want only when im omanik then show this:


And when im just a player then:


umm, i hope you understand my problem!
Reply
#2

Try to return 0; at the end of OnPlayerText
Reply
#3

Quote:
Originally Posted by Mario'
Посмотреть сообщение
Try to return 0; at the end of OnPlayerText
All same!
Reply
#4

Try using SendClientMessageToAll instead of SendPlayerMessageToAll
Reply
#5

Quote:
Originally Posted by Mario'
Посмотреть сообщение
Try using SendClientMessageToAll instead of SendPlayerMessageToAll
Nope, don't work its same (((
Reply
#6

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
   
    if(PlayerInfo[playerid][Adminlevel] < 1)
    {
        format(textv2, sizeof (textv2), "{D6D6D6}[Mдngija] [%d] %s: {F0F0F0}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    if(PlayerInfo[playerid][Adminlevel] == 1)
    {
        format(textv2, sizeof (textv2), "{0BE62C}[Moderaator] [%d] %s: {14F736}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    if(PlayerInfo[playerid][Adminlevel] == 2)
    {
        format(textv2, sizeof (textv2), "{DB170D}[Admin] [%d] %s: {FF6B63}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    if(PlayerInfo[playerid][Adminlevel] == 3)
    {
        format(textv2, sizeof (textv2), "{E3A617}[Peaadmin] [%d] %s: {FAB920}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    if(PlayerInfo[playerid][AdminLevel] == 4)
    {
        format(textv2, sizeof (textv2), "{0DDED3}[Abiomanik] [%d] %s: {1CFFF4}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    if(PlayerInfo[playerid][Adminlevel] >= 5)
    {
        format(textv2, sizeof (textv2), "{7564CC}[Omanik] [%d] %s: {A28FFF}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    if(PlayerInfo[playerid][VIP] >= 1)
    {
        format(textv2, sizeof (textv2), "{B2B54E}[VIP] [%d] %s: {E8ED5F}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
    }
    return 0;
}
This should work
Reply
#7

Use "return 0;" in all if-statements.
Otherwise when you're any admin-level AND VIP, you'll send the message twice.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
   
    if(PlayerInfo[playerid][Adminlevel] < 1)
    {
        format(textv2, sizeof (textv2), "{D6D6D6}[Mдngija] [%d] %s: {F0F0F0}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] == 1)
    {
        format(textv2, sizeof (textv2), "{0BE62C}[Moderaator] [%d] %s: {14F736}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] == 2)
    {
        format(textv2, sizeof (textv2), "{DB170D}[Admin] [%d] %s: {FF6B63}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] == 3)
    {
        format(textv2, sizeof (textv2), "{E3A617}[Peaadmin] [%d] %s: {FAB920}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][AdminLevel] == 4)
    {
        format(textv2, sizeof (textv2), "{0DDED3}[Abiomanik] [%d] %s: {1CFFF4}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] >= 5)
    {
        format(textv2, sizeof (textv2), "{7564CC}[Omanik] [%d] %s: {A28FFF}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][VIP] >= 1)
    {
        format(textv2, sizeof (textv2), "{B2B54E}[VIP] [%d] %s: {E8ED5F}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Use "return 0;" in all if-statements.
Otherwise when you're any admin-level AND VIP, you'll send the message twice.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
   
    if(PlayerInfo[playerid][Adminlevel] < 1)
    {
        format(textv2, sizeof (textv2), "{D6D6D6}[Mдngija] [%d] %s: {F0F0F0}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] == 1)
    {
        format(textv2, sizeof (textv2), "{0BE62C}[Moderaator] [%d] %s: {14F736}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] == 2)
    {
        format(textv2, sizeof (textv2), "{DB170D}[Admin] [%d] %s: {FF6B63}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] == 3)
    {
        format(textv2, sizeof (textv2), "{E3A617}[Peaadmin] [%d] %s: {FAB920}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][AdminLevel] == 4)
    {
        format(textv2, sizeof (textv2), "{0DDED3}[Abiomanik] [%d] %s: {1CFFF4}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][Adminlevel] >= 5)
    {
        format(textv2, sizeof (textv2), "{7564CC}[Omanik] [%d] %s: {A28FFF}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    if(PlayerInfo[playerid][VIP] >= 1)
    {
        format(textv2, sizeof (textv2), "{B2B54E}[VIP] [%d] %s: {E8ED5F}%s", playerid, name, text);
        SendClientMessageToAll(playerid, textv2);
        return 0;
    }
    return 1;
}
Okay that work now!
Thanks!
Reply
#9

This will works!

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(textv2, sizeof (textv2), "{D6D6D6}[Mдngija] [%d] %s: {F0F0F0}%s", playerid, name, text);


    if(PlayerInfo[playerid][Adminlevel] == 1)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{0BE62C}[Moderaator] [%d] %s: {14F736}%s", playerid, name, text);
    }
    else if(PlayerInfo[playerid][Adminlevel] == 2)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{DB170D}[Admin] [%d] %s: {FF6B63}%s", playerid, name, text);
    }
    else if(PlayerInfo[playerid][Adminlevel] == 3)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{E3A617}[Peaadmin] [%d] %s: {FAB920}%s", playerid, name, text);
    }
    else if(PlayerInfo[playerid][Adminlevel] == 4)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{0DDED3}[Abiomanik] [%d] %s: {1CFFF4}%s", playerid, name, text);
    }
    else if(PlayerInfo[playerid][Adminlevel] >= 5)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{7564CC}[Omanik] [%d] %s: {A28FFF}%s", playerid, name, text);
    }
    else if(PlayerInfo[playerid][VIP] >= 1)
    {
        GetPlayerName(playerid, name, sizeof (name));
        format(textv2, sizeof (textv2), "{B2B54E}[VIP] [%d] %s: {E8ED5F}%s", playerid, name, text);
    }
    SendPlayerMessageToAll(GetPlayerColor(playerid), textv2);
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)