SA-MP Forums Archive
OnPlayerText Problem - 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: OnPlayerText Problem (/showthread.php?tid=342875)



OnPlayerText Problem - [D]ry[D]esert - 15.05.2012

Hi every one
i tried to make if player talk or text anything and he is VIP it Show like That [Gold VIP][D]ry[D]esert:Whats Problem in that ?
pawn Код:
public OnPlayerText(playerid, text[])
{

    if(AccountInfo[playerid][VIPlevel] == 1)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Bronze"Bronze "PURPLE"VIP]"Bronze" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;
    }
    if(AccountInfo[playerid][VIPlevel] == 2)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Silver"Silver "PURPLE"VIP]"Silver" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    if(AccountInfo[playerid][VIPlevel] == 3)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Gold"Gold "PURPLE"VIP]"Gold" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
}



Re: OnPlayerText Problem - doreto - 15.05.2012

and what is the problem ?


Re: OnPlayerText Problem - [D]ry[D]esert - 15.05.2012

lol my bad i mean it show like this
D]ry[D]esert:[Gold VIP][[D]ry[D]esertWhats Problem in that ?


Re: OnPlayerText Problem - doreto - 15.05.2012

pawn Код:
public OnPlayerText(playerid, text[])
{

    if(AccountInfo[playerid][VIPlevel] == 1)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Bronze"Bronze "PURPLE"VIP]"Bronze" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;
    }
    if(AccountInfo[playerid][VIPlevel] == 2)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Silver"Silver "PURPLE"VIP]"Silver" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    if(AccountInfo[playerid][VIPlevel] == 3)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Gold"Gold "PURPLE"VIP]"Gold" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    return 0; // ignore the default text and send the custom one
}



Re: OnPlayerText Problem - TzAkS. - 15.05.2012

You got somewhere in OnPlayerText something like this

Код:
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s :  %s", sendername, text);
Is just an exemple..there you need to do something like this
Код:
if(AccountInfo[playerid][VIPlevel] == 0)
{
// codes
}
Becouse is called 2 times..


Re: OnPlayerText Problem - [D]ry[D]esert - 15.05.2012

Quote:
Originally Posted by doreto
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{

    if(AccountInfo[playerid][VIPlevel] == 1)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Bronze"Bronze "PURPLE"VIP]"Bronze" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;
    }
    if(AccountInfo[playerid][VIPlevel] == 2)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Silver"Silver "PURPLE"VIP]"Silver" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    if(AccountInfo[playerid][VIPlevel] == 3)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Gold"Gold "PURPLE"VIP]"Gold" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    return 0; // ignore the default text and send the custom one
}
Quote:
Originally Posted by TzAkS.
Посмотреть сообщение
You got somewhere in OnPlayerText something like this

Код:
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s :  %s", sendername, text);
Is just an exemple..there you need to do something like this
Код:
if(AccountInfo[playerid][VIPlevel] == 0)
{
// codes
}
Becouse is called 2 times..
not work i will show all my OnPlayerText
pawn Код:
public OnPlayerText(playerid, text[])
{

    if(AccountInfo[playerid][VIPlevel] == 0)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Bronze"Bronze "PURPLE"VIP]"Bronze" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;
    }
    if(AccountInfo[playerid][VIPlevel] == 1)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Bronze"Bronze "PURPLE"VIP]"Bronze" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;
    }
    if(AccountInfo[playerid][VIPlevel] == 2)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Silver"Silver "PURPLE"VIP]"Silver" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    if(AccountInfo[playerid][VIPlevel] == 3)
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}["Gold"Gold "PURPLE"VIP]"Gold" %s: %s", playername, text);
        SendPlayerMessageToAll(playerid, str);
        return 0;

    }
    if(text[0] == '!')
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}[TEAM CHAT]{00FF00} %s: %s", playername, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
            if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid])
                SendClientMessage(i, COLOR_ORANGE, str);
        return 0;
    }
    if(text[0] == '/')
    {
        new str[128];
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        format(str, sizeof(str), "{FFFFFF}[Commands]{00FF00} %s: %s", playername, text);
        for(new i = 0; i < MAX_PLAYERS; i++)
            if(IsPlayerConnected(i) && AccountInfo[playerid][AdminLevel] >= 1)
                SendMessageToAdmins(COLOR_ORANGE, str);
        return 0;
    }
    if(Mute[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_BRIGHTRED,"You Cant Use The Chat You Have Been Muted");
        return 0;
    }
    return 0;
}



Re: OnPlayerText Problem - Andi_Evandy - 15.05.2012

try to change:
pawn Код:
SendPlayerMessageToAll(playerid, str);
to
pawn Код:
for(new i;i<MAX_PLAYERS;i++) if(IsPlayerConnected(i)) SendClientMessage(i, -1, str);
or
pawn Код:
SendClientMessageToAll(-1, str);
hope it works