PDA

View Full Version : sscanf2 Example.


rappy93
22/05/2014, 06:27 PM
Hey there. Is there anyone who can give me an example of I can use sscanf to do this instead of explode function ?


stock AssignPlayerTickets(playerid, tickets[])
{
new tmp[MAX_PLAYER_TICKETS][32];
explode(tmp, tickets, "|");
for(new i = 0; i < MAX_PLAYER_TICKETS; i ++)
{
PlayerInfo[playerid][pTickets][i] = strval(tmp[i]);
}
}


I'm not that good with sscanf,I'm still learning how to make use of it.
Any help is much appreciated.

S4t3K
22/05/2014, 06:31 PM
new tmp[MAX_PLAYER_TICKETS][32], selse[sizeof(tickets)];
sscanf(tickets, "s[MAX_PLAYER_TICKETS]p<|>s[sizeof(tickets)]", tmp, selse);



Before the delimiter, the string will be cut and stored in tmp, and after the delimiter, it will be stored in selse.

rappy93
22/05/2014, 06:35 PM
I'll try it , thanks.