\n problem or ?
#1

pawn Код:
if(strcmp(cmd, "/lockhouse", true) == 0)
{
tmp = strtok(cmdtext, idx);
new File:house1;
new pname[24];
new tmpstr[24];
house1 = fopen("house1.txt", io_read);
fread(house1,tmpstr);
GetPlayerName(playerid, pname, 24);
                if(!strcmp(pname,tmpstr,true))
                {
                  print("House1 lockcheckdone");
                  if(!strlen(tmp))
                    {
                                SendClientMessage(playerid,COLOR_WHITE,"USAGE: /lockhouse [1/0] || 1=locked, 0=unlocked");
                                return 1;
                    }
                  else if(strcmp(tmp,"0",true) == 0)
                    {
                      fclose(house1);
                      house1 = fopen("house1.txt", io_write);
                      new playername[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, playername, sizeof(playername));
                        format(string, sizeof(string),"%s",playername);
                        fwrite(house1,string);
                      fwrite(house1,"Unlocked\n");
                        SendClientMessage(playerid,COLOR_HOUSE,"House is unlocked.");
                        return 1;
                    }
                    else if(strcmp(tmp,"1",true) == 0)
                    {
                      fclose(house1);
                      house1 = fopen("house1.txt", io_write);
                      new playername[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, playername, sizeof(playername));
                        format(string, sizeof(string),"%s",playername);
                        fwrite(house1,string);
                        fwrite(house1,"Locked\n");
                        SendClientMessage(playerid,COLOR_HOUSE,"House is locked.");
                        return 1;
                    }else{
                      SendClientMessage(playerid,COLOR_WHITE,"USAGE: /lockhouse [1/0] || 1=locked, 0=unlocked");
                    }
                }
fclose(house1);
return 1;
}
The problem is, that when you do /lockhouse 1 - it writes :
LuxeonLocked

but it should write:
Luxeon
Locked

same shit happens with /lockhouse 0 - it writes:
LuxeonUnlocked instead of
Luxeon
Unlocked

Also i have noticed, that after i do /lockhouse 1/0 - the file house1.txt will be empty and cannot be edited till the server wont be closed. Any ideas? :S

All help is appreciated, thanks !

Your Luxeon
Reply
#2

If you're working with Windows use \r\n
Reply
#3

pawn Код:
format(string, sizeof(string),"%s",playername);
You just forgot to actually add the newline to the string, it's just the name for now dude.

Edit:

Forgot to add you return before closing the file, this is why the text file is bugging out.
Reply
#4

Quote:
Originally Posted by Donny
pawn Код:
format(string, sizeof(string),"%s",playername);
You just forgot to actually add the newline to the string, it's just the name for now dude.

Edit:

Forgot to add you return before closing the file, this is why the text file is bugging out.
Thanks !

Second problem got solved - thanks to you!
But i didn't exactly understand what u meant in 1st problem.
I want it to be:
Luxeon //1line
Locked (or unlocked) //2line


Thanks for help,
Luxeon
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)