\n problem or ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: \n problem or ? (
/showthread.php?tid=69350)
\n problem or ? -
luxeon - 17.03.2009
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
Re: \n problem or ? -
Rimeau - 17.03.2009
If you're working with Windows use \r\n
Re: \n problem or ? -
Donny_k - 17.03.2009
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.
Re: \n problem or ? -
luxeon - 18.03.2009
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