Help with onplayertext
#1

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;
}
Reply
#2

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;
}
Reply
#3

thanks,fixed

EDIT: Chat not working now
Reply
#4

bump
Reply
#5

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!
Reply
#6

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
Reply
#7

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.
Reply
#8

FIXED Thanks
Reply
#9

EDIT: Gammix already gave it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)