Crashing
#1

Hello, my server is crashing at when I use the RadioBroadCast function, but when I use the same function on Localhost, it doesn't crash, it seems to only crash on Linux. I tried using the Crashdetect plugin, but it didn't do anything to tell me.

pawn Код:
forward RadioBroadCast(playerid, Float:radi, color, string[]);
public RadioBroadCast(playerid, Float:radi, color, string[])
{
    new MiscString[128];
    foreach(new i : Player)
    {
        if(PlayerInfo[i][pRadioFreq] == PlayerInfo[playerid][pRadioFreq] && PlayerInfo[i][pRadio] == 1)
        {
            for(new Words; Words < sizeof(BannedWords); Words++) //Sets a loop as it checks the words one by one.
            {
                if(strfind(string,BannedWords[Words],true) != -1 ) // Checks if the text includes any of the defined Swear Words or not
                {
                    SendClientMessage(playerid, -1, "Using OOC Words in IC chat is prohibited.");
                    return 1; // return 0; to avoid sending the text in chat.
                }
            }
            format(MiscString, sizeof(MiscString), "** [%d khz] %s: %s **", PlayerInfo[playerid][pRadioFreq], GetName(playerid), string);
            SendClientMessage(i, color, MiscString);
            format(MiscString, sizeof(MiscString), "(radio) %s says: %s", GetName(playerid), string);
            ProxDetector(radi, playerid, MiscString,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            SetPlayerChatBubble(playerid,string,COLOR_WHITE,5.0,5000);
            format(MiscString, sizeof(MiscString), "[%d khz] %s (IP: %s): %s", PlayerInfo[playerid][pRadioFreq], GetName(playerid), GetPlayerIpEx(playerid), string);
            Log("logs/radio.log", MiscString);
        }
    }
    return 1;
}
Reply
#2

pawn Код:
Log("logs/radio.log", MiscString);
Does the file exist on the host? When you open a file, you actually need to check if it opened and write to/read from it. If it failed to open the file it returns 0.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
Log("logs/radio.log", MiscString);
Does the file exist on the host? When you open a file, you actually need to check if it opened and write to/read from it. If it failed to open the file it returns 0.
Yes, it does.
Reply
#4

Okay, then check if the file opens correctly and then write to it.

An example:
pawn Код:
new
    File: log_file = fopen( "logs/radio.log", io_append )
;
if( log_file ) // it opened correctly, now you can write to it. Othewise you try to write to a closed file which cause problems
{
    fwrite( log_file, "some logs here" );
    fclose( log_file );
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)