SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/11/2011, 11:37 PM   #1
telmo_ferreira
Huge Clucker
 
telmo_ferreira's Avatar
 
Join Date: Feb 2008
Location: Portugal
Posts: 230
Reputation: 23
Default [HELP] Server crash on linux

This commands are working on windows loaded pc, but doesn't on linux . It gives crash. anyone knows How to fix?

Code:
#define FILE_NAME "log/gravardata.txt"







public actualizardata(playerid)
{
  if(PlayerInfo[playerid][pPhousekey] == 255)
	{
	return 1;
    }
  if(PlayerInfo[playerid][pPhousekey] <11 )
	{
	return 1;
    }
  new chave;
  new str[128];
  new File:gstats;
  new day,month,year;
  getdate(day,month,year);
  chave = PlayerInfo[playerid][pPhousekey];
  format(str, sizeof(str), "Casa Nš%d",chave);
  fdeleteline(FILE_NAME,str);
  new sstr[128];
  format(sstr, sizeof(sstr), "Casa Nš%d Data: %d.%d.%d \r<br>\n",chave,day,month,year);
  gstats=fopen(FILE_NAME, io_append);
  fwrite(gstats, sstr);
  fclose(gstats);
  return 1;
}


stock fdeleteline(filename[], removed[])
{
    new string[64], str[32], File:handle, File:ftmp;
    handle = fopen(filename,io_read);
    format(str,sizeof(str),"%s.part",filename);
    ftmp = fopen(str,io_write);
    while(fread(handle,string))
        if(strfind(string,removed) == -1)
            fwrite(ftmp,string);
    fclose(handle);
    fclose(ftmp);
    handle = fopen(filename,io_write);
    ftmp = fopen(str,io_read);
    while(fread(ftmp,string))
        fwrite(handle,string);
    fclose(handle);
    fclose(ftmp);
    return fremove(str);
}
telmo_ferreira is offline   Reply With Quote
Old 17/11/2011, 04:13 AM   #2
Calgon
Banned
 
Join Date: Jan 2009
Posts: 6,136
Reputation: 1127
Default Re: [HELP] Server crash on linux

If you use io_read and the file doesn't exist, the server will crash.

Add a check to confirm the file you're trying to open with fopen()'s io_read parameters actually exists.

Not sure if this crash is exclusive to Linux.

pawn Code:
stock fdeleteline(filename[], removed[])
{
    new string[64], str[32], File:handle, File:ftmp;
    if(fexist(filename)) handle = fopen(filename,io_read); else return 0;
    format(str,sizeof(str),"%s.part",filename);
    if(fexist(str)) ftmp = fopen(str,io_write); else return 0;
    while(fread(handle,string))
        if(strfind(string,removed) == -1)
            fwrite(ftmp,string);
    fclose(handle);
    fclose(ftmp);
    handle = fopen(filename,io_write);
    if(fexist(str)) ftmp = fopen(str,io_read); else return 0;
    while(fread(ftmp,string))
        fwrite(handle,string);
    fclose(handle);
    fclose(ftmp);
    return fremove(str);
}
Calgon is offline   Reply With Quote
Old 17/11/2011, 08:02 AM   #3
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,230
Reputation: 993
Default Re: [HELP] Server crash on linux

Files are cASe sEnSiTiVe. If you need to, look at this tutorial written by me: http:/wiki.sa-mp.com/wiki/Debugging
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 17/11/2011, 01:45 PM   #4
telmo_ferreira
Huge Clucker
 
telmo_ferreira's Avatar
 
Join Date: Feb 2008
Location: Portugal
Posts: 230
Reputation: 23
Default Re: [HELP] Server crash on linux

im try only with the actualizardata(playerid) just for testing, and add if(!gstats) { fcreate(FILE_NAME); }
and the linux crashe again.




Code:
public actualizardata(playerid)
{
  if(PlayerInfo[playerid][pPhousekey] == 255)
	{
	return 1;
    }
  if(PlayerInfo[playerid][pPhousekey] <11 )
	{
	return 1;
    }
  new chave;
  new str[128];
  new File:gstats;
  new day,month,year;
  getdate(day,month,year);
  chave = PlayerInfo[playerid][pPhousekey];
  format(str, sizeof(str), "Casa Nš%d",chave);
  new sstr[128];
  format(sstr, sizeof(sstr), "Casa Nš%d Data: %d.%d.%d \r<br>\n",chave,day,month,year);
  gstats=fopen(FILE_NAME, io_append);
  if(!gstats) { fcreate(FILE_NAME); }
//  fdeleteline(FILE_NAME,str);
  fwrite(gstats, sstr);
  fclose(gstats);
  return 1;
}
telmo_ferreira is offline   Reply With Quote
Old 17/11/2011, 03:19 PM   #5
telmo_ferreira
Huge Clucker
 
telmo_ferreira's Avatar
 
Join Date: Feb 2008
Location: Portugal
Posts: 230
Reputation: 23
Default Re: [HELP] Server crash on linux

this simple code is crashing the server only in linux

Code:
if(strcmp(cmdtext, "/actualizardata", true) == 0)
	{

    actualizardata(playerid);
    SendClientMessage(playerid, COLOR_YELLOW, "actualizar");
    return 1;
	}




public actualizardata(playerid)
{
    new File:gstats;
    new pname[24];
    new str[256];
    new ccurdate = getdate();
    GetPlayerName(playerid, pname, 24);
    format(str, 30, "%s %d",pname,ccurdate);
    gstats=fopen(FILE_NAME, io_append);
    fwrite(gstats, str);
    fclose(gstats);
    return 1;
}
telmo_ferreira is offline   Reply With Quote
Old 06/12/2011, 07:38 PM   #6
teste
Little Clucker
 
Join Date: Oct 2009
Posts: 1
Reputation: 0
Default Re: [HELP] Server crash on linux

Files are case sensitive
teste is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crash Linux Server!( Igorek Help Archive 0 18/06/2011 12:40 PM
Linux Server Crash On Restart Sascha Help Archive 2 23/01/2011 07:28 PM
Server wont load plugins for linux on linux server! GrantLea Help Archive 3 24/10/2010 11:55 PM
[HELP] Gives crash on linux server? RoCK'N'Rolla Help Archive 0 12/09/2010 11:45 AM
samp linux server 03r5 doesn't run on 64 bits linux edelcat Server Support 2 08/09/2010 10:22 AM


All times are GMT. The time now is 08:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.