SA-MP Forums Archive
Help with 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: Help with onplayertext (/showthread.php?tid=564052)



Help with onplayertext - Nabster - 19.02.2015

When i go on admin duty and type . then admin chat doesn't work


Код:
public OnPlayerText(playerid,text[])
{
	if(PInfo[playerid][pAdminDuty] == 1)
    {
        new pName[MAX_PLAYER_NAME],String[128],Prefix[24] = "Administrator";
        GetPlayerName(playerid,pName,24);
        format(String, sizeof(String), "%s %s: %s",Prefix,pName,text);
        SendClientMessageToAll(COLOR_GOLD,String);
        return 0;
    }
    if(PInfo[playerid][Level] > 1 && text[0] == '.')
    {
         new msg[128],pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,sizeof pName);
         format(msg,sizeof(msg),"[ADMIN CHAT] %s[%d]: %s",pName,playerid,text[1]);
		 MessageToAdmins(COLOR_MEDIUMSEAGREEN,msg);
         return 0;
    }
    return 1;
}



Re: Help with onplayertext - JeaSon - 19.02.2015

pawn Код:
public OnPlayerText(playerid,text[])
{
    if(PInfo[playerid][pAdminDuty] == 1)
    {
        new pName[MAX_PLAYER_NAME],String[128],Prefix[24] = "Administrator";
        GetPlayerName(playerid,pName,24);
        format(String, sizeof(String), "%s %s: %s",Prefix,pName,text);
        SendClientMessageToAll(COLOR_GOLD,String);
        return 0;
    }
    if(PInfo[playerid][Level] > 1 && text[0] == '.')
    {
         new msg[128],pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,sizeof pName);
         format(msg,sizeof(msg),"[ADMIN CHAT] %s[%d]: %s",pName,playerid,text[1]);
         MessageToAdmins(COLOR_MEDIUMSEAGREEN,msg);
         return 0;
    }
    return 0;
}



Re: Help with onplayertext - Nabster - 19.02.2015

thanks,fixed

EDIT: Chat not working now


Re: Help with onplayertext - Nabster - 20.02.2015

bump


Re: Help with onplayertext - Gammix - 20.02.2015

pawn Код:
public OnPlayerText(playerid,text[])
{
       new string[128], name[MAX_PLAYER_NAME];
       GetPlayerName(playerid, name, sizeof name);
       if(PInfo[playerid][pAdminDuty] == 1)
       {
              format(string, sizeof(string), "Administrator %s: %s", name, text);
              return SendClientMessageToAll(COLOR_GOLD, string);
        }
   
       if(PInfo[playerid][Level] > 1 && text[0] == '.')
       {
               format(string, sizeof(string),"[ADMIN CHAT] %s[%d]: %s", name, playerid, text[1]);
               return MessageToAdmins(COLOR_MEDIUMSEAGREEN, string);
        }
        return 1;
}
Its because the callback returns 0. Just replace with 1 like this^

EDIT: i have edited the code, basically removed string Prefix because there is no need for it. You directly plot it it ing the main string manualy. And some simplifications!


Re: Help with onplayertext - Nabster - 20.02.2015

that code is not working too,now when i type . it sends message 2 times

12:46:31] [ADMIN CHAT] WoLveRiNe[0]: test

[12:46:31] <WoLveRiNe> .test

[12:46:32] <WoLveRiNe> test

[12:46:41] [ADMIN CMD]: WoLveRiNe has used the command ADMINDUTY

[12:46:41] Administrator WoLveRiNe is now on Admin Duty.

[12:46:42] Administrator WoLveRiNe: .test

[12:46:42] <WoLveRiNe> .test


Re: Help with onplayertext - Gammix - 20.02.2015

EDIT:
pawn Код:
public OnPlayerText(playerid,text[])
{
       new string[128], name[MAX_PLAYER_NAME];
       GetPlayerName(playerid, name, sizeof name);

       if(PInfo[playerid][Level] > 1 && text[0] == '.')
       {
               format(string, sizeof(string),"[ADMIN CHAT] %s[%d]: %s", name, playerid, text[1]);
               MessageToAdmins(COLOR_MEDIUMSEAGREEN, string);
               return 0;
        }

       if(PInfo[playerid][pAdminDuty])
       {
               format(string, sizeof string, "Administrator %s: %s", name, text);
               SendClientMessageToAll(COLOR_GOLD, string);
               return 0;
        }
        return 1;
}
I should have done it like this^. This is perfect and compatible.


Re: Help with onplayertext - Nabster - 20.02.2015

FIXED Thanks


Re: Help with onplayertext - Excips - 20.02.2015

EDIT: Gammix already gave it!