SA-MP Forums Archive
Onplayertext - 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 (/showthread.php?tid=288556)



Onplayertext - omer5198 - 08.10.2011

do i have to put else in this code? (because if i put it this way it send "Chat Is Closed" but send a message like the default message... and not what i did)
pawn Code:
public OnPlayerText(playerid, text[])
{
    if(ChatClosed == 1 && !IsPlayerAdmin(playerid) && PlayerInfo[playerid][AdminLevel] < 3) return SendClientMessage(playerid, COLOR_RED, "Chat Is Closed");
    new string[256];
    if(IsPlayerAdmin(playerid))
    {
        format(string, sizeof(string), "[Server Programmer]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_LIGHTGREEN, string);
    }
    else if(PlayerInfo[playerid][AdminLevel] == 0)
    {
        format(string, sizeof(string), "%s: {FFFFFF}%s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
    }
    else if(PlayerInfo[playerid][AdminLevel] == 1)
    {
        format(string, sizeof(string), "[Activity Maneger]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_AM, string);
    }
    else if(PlayerInfo[playerid][AdminLevel] >= 2 && PlayerInfo[playerid][AdminLevel] <= 4)
    {
        format(string, sizeof(string), "[Admin]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_ADMIN, string);
    }
    else if(PlayerInfo[playerid][AdminLevel] == 5)
    {
        format(string, sizeof(string), "[Main Admin]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_ADMIN, string);
    }
    return 0;
}



Re: Onplayertext - [HiC]TheKiller - 08.10.2011

Remember that you have to return 0 as well as sending the client message.


Re: Onplayertext - omer5198 - 08.10.2011

i remember but... look i did return 0; but still it doesnt work! it does like this:
if i want to write :"hello"
so:
The Chat is Close!
omer5198: hello
__________________
if the chat is open:
[Main Admin]omer5198(id:0): hello


Re: Onplayertext - Jafet_Macario - 08.10.2011

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(ChatClosed == 1 && !IsPlayerAdmin(playerid) && PlayerInfo[playerid][AdminLevel] < 3)
    {
        SendClientMessage(playerid, COLOR_RED, "Chat Is Closed");
        return 0;
    }
    new string[256];
    if(IsPlayerAdmin(playerid))
    {
        format(string, sizeof(string), "[Server Programmer]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_LIGHTGREEN, string);
    }
    else if(PlayerInfo[playerid][AdminLevel] == 0)
    {
        format(string, sizeof(string), "%s: {FFFFFF}%s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
    }
    else if(PlayerInfo[playerid][AdminLevel] == 1)
    {
        format(string, sizeof(string), "[Activity Maneger]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_AM, string);
    }
    else if(PlayerInfo[playerid][AdminLevel] >= 2 && PlayerInfo[playerid][AdminLevel] <= 4)
    {
        format(string, sizeof(string), "[Admin]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_ADMIN, string);
    }
    else if(PlayerInfo[playerid][AdminLevel] == 5)
    {
        format(string, sizeof(string), "[Main Admin]%s: %s [ID:%d]", GetName(playerid), text, playerid);
        SendClientMessageToAll(COLOR_ADMIN, string);
    }
    return 0;
}