Opening files.. etc help -
MafiaGuy™ - 15.05.2010
Код:
stock pAddGateKeys(name[], faction)
{
new filestr[128],string[128];
if(faction == 0) return 1;
if(faction == 1){format(string,sizeof(string),"D-RP/Factions/LSPD_Keys.cfg");}
new File:file = fopen(string,io_append);
if (file)
{
while(fread(file,filestr,sizeof(filestr)))
{
if (strfind(filestr, name, true) != -1)
{
}
else
{
format(string,128,"%s\r\n", name);
fwrite(file,string);
}
}
}
fclose(file);
return 1;
}
well i am trying to add someone's name in a file if it doesn't exist in it but it doesnt work for some reason :S
Re: Opening files.. etc help -
MafiaGuy™ - 15.05.2010
Sorry for bumping.. kinda in hurry
Re: Opening files.. etc help -
iJumbo - 15.05.2010
if((file = fopen("file...i",io_append)))

Re: Opening files.. etc help -
MafiaGuy™ - 15.05.2010
Quote:
Originally Posted by [ZDM
jumbo ]
if((file = fopen("file...i",io_append)))  
|
What's the use of those brackets and only one "=" ?
Re: Opening files.. etc help -
MafiaGuy™ - 16.05.2010
bump
Re: Opening files.. etc help - Micko9 - 16.05.2010
Quote:
Originally Posted by MafiaGuy™
bump
|
you're in a hurry ooooh people are in a hurry too idiots only can bump thats really bad of you don't act like a child!
Re: Opening files.. etc help -
MafiaGuy™ - 16.05.2010
Код:
« Reply #3 on: May 15, 2010, 06:28:07 pm »
Код:
« Reply #4 on: Today at 08:41:14 am »
- You can bump your own topic after 12 hours. So don't bitch.
Re: Opening files.. etc help - Micko9 - 16.05.2010
please don't call me a bitch that wood make you something much more . kay?
Re: Opening files.. etc help -
juice.j - 16.05.2010
Oh dear... SAMP heroes fighting again
What happens when you execute that code?
The way I see it this:
Код:
while(fread(file,filestr,sizeof(filestr)))
{
if (strfind(filestr, name, true) != -1)
{
}
else
{
format(string,128,"%s\r\n", name);
fwrite(file,string);
}
}
writes in quite a few names seeing that in each line you don't find "name" the else clause gets executed.
Is that the case or what happens - in which way does it not work correctly?
Re: Opening files.. etc help -
MafiaGuy™ - 16.05.2010
wops.. i only meant to write them once..
when i execute the code i get no response..
Can i use "break" to break the loop ?
then:
Код:
stock pAddGateKeys(name[], faction)
{
new filestr[128],string[128];
if(faction == 0) return 1;
if(faction == 1){format(string,sizeof(string),"D-RP/Factions/LSPD_Keys.cfg");}
new File:file = fopen(string,io_append);
if (file)
{
while(fread(file,filestr,sizeof(filestr)))
{
if (strfind(filestr, name, true) != -1)
{
}
else
{
format(string,128,"%s\r\n", name);
fwrite(file,string);
break;
}
}
}
fclose(file);
return 1;
}
this code looks fucked up.. u have any other idea how to do it simplier or w/e ?