Error @ OnPlayerText crashing server
#1

I typed a long line of text on the chat and it crashed the server.


PHP код:
[01:19:02] [debugAMX backtrace:
[
01:19:02] [debug#0 0000006d in ?? (... <8 arguments>) at <unknown file>:0
[01:19:02] [debug#1 0000006d in public OnPlayerText () at <unknown file>:0 
PHP код:
public OnPlayerText(playeridtext[])
{
    if (!
PlayerData[playerid][pLogged] || !PlayerData[playerid][pCharacter] || PlayerData[playerid][pTutorial] > || PlayerData[playerid][pTutorialStage] > || PlayerData[playerid][pHospital] != -1)
        return 
false;
    if (
PlayerData[playerid][pNewsGuest] != INVALID_PLAYER_ID && GetFactionType(PlayerData[playerid][pNewsGuest]) == FACTION_NEWS//&& IsPlayerInAnyVehicle(playerid) && IsNewsVehicle(GetPlayerVehicleID(playerid)))
    
{
        foreach (new 
Player) if (!PlayerData[i][pDisableBC]) {
              
SendClientMessageEx(iCOLOR_LIGHTGREEN"[NEWS] Guest %s: %s"ReturnName(playerid0), text);
        }
           return 
false;
       }
    else
    {
        new
            
targetid PlayerData[playerid][pCallLine],
            
string[200];
           new 
text1[128],
            
text2[128],
            
bubble[200];
        
strmid(text2text90128);
        
strmid(text1text090);
        if (!
IsPlayerOnPhone(playerid))
        {
             if(
strlen(text) > 90)
            {
                if (
IsPlayerInAnyVehicle(playerid) && IsWindowedVehicle(GetPlayerVehicleID(playerid)) && !CoreVehicles[GetPlayerVehicleID(playerid)][vehWindowsDown])
                {
                    
format(stringsizeof(string), "(vehicle) %s says: %s..."ReturnName(playerid0), text1);
                    
ProxDetector(25.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
                    
format(stringsizeof(string), "..%s"ReturnName(playerid0), text2);
                    
ProxDetector(25.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
                     
//SetPlayerChatBubble(playerid, string, COLOR_WHITE, 50, 5000);
                
}
                else
                {
                    if (!
PlayerData[playerid][pInjured] && !PlayerData[playerid][pLoopAnim])
                    {
                        switch (
random(6))
                        {
                            case 
0ApplyAnimation(playerid"GANGS""prtial_gngtlkA"4.10111strlen(text) * 1001);
                            case 
1ApplyAnimation(playerid"GANGS""prtial_gngtlkB"4.10111strlen(text) * 1001);
                            case 
2ApplyAnimation(playerid"GANGS""prtial_gngtlkE"4.10111strlen(text) * 1001);
                            case 
3ApplyAnimation(playerid"GANGS""prtial_gngtlkF"4.10111strlen(text) * 1001);
                            case 
4ApplyAnimation(playerid"GANGS""prtial_gngtlkG"4.10111strlen(text) * 1001);
                            case 
5ApplyAnimation(playerid"GANGS""prtial_gngtlkH"4.10111strlen(text) * 1001);
                        }
                        
SetTimerEx("StopChatting"strlen(text) * 100false"d"playerid);
                    }
                    
format(string128"%s says: %s..."ReturnName(playerid0), text1);
                    
ProxDetector(25.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
                    
format(string128"..%s"text2);
                    
ProxDetector(25.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
                    
//SetPlayerChatBubble(playerid, string, COLOR_WHITE, 50, 5000);
                
}
                return 
false;
            }
            else
            {
                if (
IsPlayerInAnyVehicle(playerid) && IsWindowedVehicle(GetPlayerVehicleID(playerid)) && !CoreVehicles[GetPlayerVehicleID(playerid)][vehWindowsDown])
                {
                    
format(stringsizeof(string), "(vehicle) %s says: %s"ReturnName(playerid0), text);
                    
ProxDetector(25.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
                    
format(bubblesizeof(bubble), "(vehicle) %s"text);
                     
SetPlayerChatBubble(playeridbubbleCOLOR_WHITE505000);
                }
                else
                {
                    if (!
PlayerData[playerid][pInjured] && !PlayerData[playerid][pLoopAnim])
                    {
                        switch (
random(6))
                        {
                            case 
0ApplyAnimation(playerid"GANGS""prtial_gngtlkA"4.10111strlen(text) * 1001);
                            case 
1ApplyAnimation(playerid"GANGS""prtial_gngtlkB"4.10111strlen(text) * 1001);
                            case 
2ApplyAnimation(playerid"GANGS""prtial_gngtlkE"4.10111strlen(text) * 1001);
                            case 
3ApplyAnimation(playerid"GANGS""prtial_gngtlkF"4.10111strlen(text) * 1001);
                            case 
4ApplyAnimation(playerid"GANGS""prtial_gngtlkG"4.10111strlen(text) * 1001);
                            case 
5ApplyAnimation(playerid"GANGS""prtial_gngtlkH"4.10111strlen(text) * 1001);
                        }
                        
SetTimerEx("StopChatting"strlen(text) * 100false"d"playerid);
                    }
                     
format(stringsizeof string"%s says: %s"ReturnName(playerid0), text);
                     
ProxDetector(25.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
                      
format(bubblesizeof(bubble), "%s"text);
                     
SetPlayerChatBubble(playeridbubbleCOLOR_WHITE505000);
                }
                 return 
false;
            }
        } 
What seems to be the problem here?
Reply
#2

Did you try crash detect??
Reply
#3

Yes I have crashdetect and that's what the plugin detect.
Reply
#4

Run with debug level 3
Reply
#5

you have to check if text variable contains anything, because otherwise sendclientmessageex will crash
and i wouldnt even use that system, because every loop you again format message and then send it, but its better to format first message and then sent it.
and dont use ProxDetector because its just waste of time, because you need to copy this thing every time and colors will be same always, you dont write colors from your head.
PHP код:
ChattingAnim(playerid,time){
    if (!
PlayerData[playerid][pInjured] && !PlayerData[playerid][pLoopAnim]) 
    { 
        switch (
random(6)) 
        { 
            case 
0ApplyAnimation(playerid"GANGS""prtial_gngtlkA"4.10111strlen(text) * 1001); 
            case 
1ApplyAnimation(playerid"GANGS""prtial_gngtlkB"4.10111strlen(text) * 1001); 
            case 
2ApplyAnimation(playerid"GANGS""prtial_gngtlkE"4.10111strlen(text) * 1001); 
            case 
3ApplyAnimation(playerid"GANGS""prtial_gngtlkF"4.10111strlen(text) * 1001); 
            case 
4ApplyAnimation(playerid"GANGS""prtial_gngtlkG"4.10111strlen(text) * 1001); 
            case 
5ApplyAnimation(playerid"GANGS""prtial_gngtlkH"4.10111strlen(text) * 1001); 
        } 
        
SetTimerEx("StopChatting"timefalse"d"playerid); 
    } 
    return 
1;
}
public 
OnPlayerText(playeridtext[]) 

    if (!
PlayerData[playerid][pLogged] || !PlayerData[playerid][pCharacter] || PlayerData[playerid][pTutorial] > || PlayerData[playerid][pTutorialStage] > || PlayerData[playerid][pHospital] != -1
        return 
false
    if(
strlen(text) < || strlen(text) > 128)return SendClientMessage(playerid,-1,"Your text must be atleast 3 letters long!"),0;
    
    new 
s[144];
    if (
PlayerData[playerid][pNewsGuest] != INVALID_PLAYER_ID && GetFactionType(PlayerData[playerid][pNewsGuest]) == FACTION_NEWS//&& IsPlayerInAnyVehicle(playerid) && IsNewsVehicle(GetPlayerVehicleID(playerid))) 
    

        
format(s,144,"[NEWS] Guest %s: %s",ReturnName(playerid0), text);
        foreach (
Player,i
        if (!
PlayerData[i][pDisableBC]) { 
            
SendClientMessage(i,COLOR_LIGHTGREEN,s);
        } 
        return 
false
    } 
    else 
    { 
        new 
            
targetid PlayerData[playerid][pCallLine], 
            
vid=GetPlayerVehicleID(playerid),
            
text1[128], 
            
text2[128];
        if(
IsPlayerOnPhone(playerid)) return SendClientMessage(playerid,-1,"You are using your phone!"),0
        new 
bool:isinveh=!!(IsPlayerInAnyVehicle(playerid) && IsWindowedVehicle(vid) && !CoreVehicles[vid][vehWindowsDown]);
        if(!
isinveh)ChattingAnim(playerid,strlen(text) * 100);
        if(
strlen(text) > 90) {       
            
strmid(text1text090); 
            
strmid(text2text90128); 
            
            
format(s144"%s%s says: %s...",isinveh?("(vehicle) "):(""), ReturnName(playerid0), text1); 
            
ProxDetector(25.0playeridsCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5); 
            
format(s144"..%s"ReturnName(playerid0), text2); 
            
ProxDetector(25.0playeridsCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);         
        } 
        else 
        { 
            
format(s144"%s%s says: %s",isinveh?("(vehicle) "):(""), ReturnName(playerid0), text); 
            
ProxDetector(25.0playeridsCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5); 
        } 
        return 
false
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)