help - sscanf
#1

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
Reply
#2

Have you read this?
https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#3

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
Yes, I've read.
But I don't know switch to sscanf, can you help me?
Reply
#4

Me neither.
Show me an example command I'll explain it to you.
Reply
#5

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
Reply
#6

[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.

Reply
#7

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)