OnPlayerText doesn't work.
#1

PHP код:
    if(GetPlayerState(playerid) == PLAYER_STATE_SPAWNED)
    {
        if(
PlayerTemp[playerid][muted]==0)
        {
            new 
sender[MAX_STRING];
            if(
PlayerTemp[playerid][phone]!=0)
            {
                if(
PlayerTemp[playerid][hname]==1myStrcpy(sender,iStr);
                else 
myStrcpy(sender,RPName(playerid));
                if(
text[0]== '(')
                {
                    new 
mid[MAX_STRING];
                    
strmid(mid,text,1,256,sizeof(mid));
                    
text[0] = toupper(text[0]);
                    
format(stringa,sizeof(stringa),"(Phone) %s says: (( %s ))",RPName(playerid),mid);
                }
                else
                {
                    
text[0] = toupper(text[0]);
                    
format(stringa,sizeof(stringa),"(Phone) %s says: %s",sender,text);
                    
SendClientMessage(PlayerTemp[playerid][onphone],COLOR_YELLOW,stringa);
                }
            }
            else
            {
                if(
PlayerTemp[playerid][hname]==1myStrcpy(sender,iStr);
                else 
myStrcpy(sender,RPName(playerid));
                if(
text[0]== '(')
                {
                    new 
mid[MAX_STRING];
                    
strmid(mid,text,1,256,sizeof(mid));
                    
format(iStrsizeof(iStr), "(( %s ))"mid);
                    
SetPlayerChatBubble(playerid,iStr,COLOR_WHITE50.0 5000);
                    
format(stringa,sizeof(stringa),"%s says: (( %s ))",RPName(playerid),mid);
                }
                 else
                {
                    
text[0] = toupper(text[0]);
                    
SetPlayerChatBubble(playerid,text,COLOR_WHITE50.0 5000);
                    if(!
strcmp(PlayerInfo[playerid][accent],"unset"))
                    {
                        
format(iStrsizeof(iStr),": ");
                    }
                    else
                    {
                        
format(iStr,sizeof(iStr),": [%s Accent] ",PlayerInfo[playerid][accent]);
                    }
                    
format(stringa,sizeof(stringa),"%s says%s%s",sender,iStr,text);
                }
            }
            
PlayerLoop(i)
            {
                if(!
IsPlayerConnected(i)) continue;
                if(!
IsPlayerInRangeOfPoint(i60.0px,py,pz)) continue;
                if(
GetPlayerVirtualWorld(i) != GetPlayerVirtualWorld(playerid) || GetPlayerInterior(i) != GetPlayerInterior(playerid)) continue;
                new 
Float:dis;
                
disGetDistanceBetweenPlayers(playerid,i);
                if(
dis>45SendClientMessage(i,COLOR_PLAYER_DARKGREY,stringa);
                if(
dis<=35 && dis >15SendClientMessage(i,COLOR_PLAYER_GREY,stringa);
                if(
dis<=15SendClientMessage(i,COLOR_PLAYER_WHITE,stringa);
            }
            
strdel(stringa,0,strlen(PlayerName(playerid))+7);
            new 
tmpStr144 ];
            if(
text[0]== '(')
            {
                new 
mid[MAX_STRING];
                
strmid(mid,text,1,256,sizeof(mid));
                
format(tmpStr164"7%s[%d]: (( %s ))"RPName(playerid), playeridmid);
                
text[0] = toupper(text[0]);
                
iEcho(tmpStrIRC_LIVE);
            }
            else
            {
                
format(tmpStr164"7%s[%d]: %s"RPName(playerid), playeridtext);
                
text[0] = toupper(text[0]);
                
iEcho(tmpStr ,IRC_LIVE);
            }
            if(
stringContainsIP(text))
            {
                new 
wat80 ];
                
//GetPlayerName(playerid, wat, 20);
                
format(watsizeof(wat),"IP Advertisments");//format(string, sizeof(string), "[!] \"%s\" named player has been banned from the server! [Reason: IP advertisements]", string);
                
return BanReas("SERVER",playerid,wat1), false;
            }
        }
        else
        {
            
SendClientMessage(playerid,COLOR_RED," You are muted!");
            return 
0;
        }
    }
    else if(
GetPlayerState(playerid) == PLAYER_STATE_WASTED)
    {
        
SendClientError(playerid"You cannot talk in local chat while dead!");
        return 
0;
    } 
When I'm typing in local chat, the text doesn't appear
Reply
#2

Which part of the code doesn't get executed? Do couple of prints in different sections of the code and see which line is not being executed, fix it or ask for help.

If the entire OnPlayerText doesn't get called, then it's being prevented by another filterscript or gamemode.
Reply
#3

It's working if I removed " GetPlayerState(playerid) " functions.

but if I added it, it's still working but the format won't appear.
Reply
#4

Quote:
Originally Posted by ServerFiles
Посмотреть сообщение
It's working if I removed " GetPlayerState(playerid) " functions.

but if I added it, it's still working but the format won't appear.
Well if you want to check if player is spawned then you need to use this function because your way doesn't work always.

PHP код:
stock bool:IsPlayerSpawned(playerid)
{
    new 
pState GetPlayerState(playerid);
    return 
<= playerid MAX_PLAYERS && pState != PLAYER_STATE_NONE && pState != PLAYER_STATE_WASTED && pState != PLAYER_STATE_SPECTATING;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)