help - sscanf - 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)
+--- Thread: help - sscanf (
/showthread.php?tid=280800)
help - sscanf -
Tesse_ - 03.09.2011
Hi guys, I need help
how can I chance strtok for sscanf?
Код:
GetVal(numb, str[])
{
new tmp[256], idx;
for(new i=0; i<numb; i++)
{
tmp=strtok(str, idx);
}
return strval(tmp);
}
EDIT: I was reading this web page:
https://sampwiki.blast.hk/wiki/File_Functions
but I know that sscanf is more fast that strtok, so I need help to change.
thx
Re: help - sscanf -
=WoR=Varth - 03.09.2011
Have you read this?
https://sampforum.blast.hk/showthread.php?tid=120356
Re: help - sscanf -
Tesse_ - 03.09.2011
Quote:
Originally Posted by varthshenon
|
Yes, I've read.
But I don't know switch to sscanf, can you help me?
Re: help - sscanf -
=WoR=Varth - 03.09.2011
Me neither.
Show me an example command I'll explain it to you.
Re: help - sscanf -
Tesse_ - 03.09.2011
Quote:
Originally Posted by varthshenon
Me neither.
Show me an example command I'll explain it to you.
|
Код:
forward AccountRead(playerid);
public AccountRead(playerid)
{
new strpl[30];
format(strpl, 30, "Accounts/%s.ini", pName(playerid));
new File:F = fopen(strpl, io_read);
while(fread(F, strpl))
{
if(strcmp(strpl, "kill ", true, 5)==0)
{
printf("kills %d", GetVal(2, strpl));
}
}
return true;
}
GetVal(numb, str[]) {
new tmp[256], idx;
for(new i=0; i<numb; i++) {
tmp=strtok(str, idx);
}
return strval(tmp);
}
I try, but I don't know how change it :S
I would like to change strtok for sscanf, help :S
Re: help - sscanf -
=WoR=Varth - 03.09.2011
[pawn]
pawn Код:
forward AccountRead(playerid);
public AccountRead(playerid)
{
new strpl[30],asd;
format(strpl, 30, "Accounts/%s.ini", pName(playerid));
new File:F = fopen(strpl, io_read);
while(fread(F, strpl))
{
if(strcmp(strpl, "kill ", true, 5)==0)
{
sscanf(strpl,"{d}d",asd);
printf("kills %d",asd);
}
}
return true;
}
Quote:
The two new specifiers "{" and "}" are used for what are known as "quiet" strings. These are strings which are read and checked, but not saved.
|
Re: help - sscanf -
Tesse_ - 03.09.2011
Quote:
Originally Posted by varthshenon
[pawn]
pawn Код:
forward AccountRead(playerid); public AccountRead(playerid) { new strpl[30],asd; format(strpl, 30, "Accounts/%s.ini", pName(playerid)); new File:F = fopen(strpl, io_read); while(fread(F, strpl)) { if(strcmp(strpl, "kill ", true, 5)==0) { sscanf(strpl,"{d}d",asd); printf("kills %d",asd); } } return true; }
|
Thx!! Now I understand!