Error @ OnPlayerText crashing server
#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


Messages In This Thread
Error @ OnPlayerText crashing server - by Uberanwar - 06.07.2018, 17:28
Re: Error @ OnPlayerText crashing server - by coool - 06.07.2018, 17:48
Re: Error @ OnPlayerText crashing server - by Uberanwar - 06.07.2018, 18:00
Re: Error @ OnPlayerText crashing server - by Verc - 06.07.2018, 18:50
Re: Error @ OnPlayerText crashing server - by CodeStyle175 - 06.07.2018, 18:58

Forum Jump:


Users browsing this thread: 1 Guest(s)