LoadData(playerid) { new pName[24], query[61], line[100]; GetPlayerName(playerid, pName, 24); mysql_real_escape_string(pName, pName); format(query, sizeof(query), "SELECT * FROM jugadores WHERE nombre='%s'", pName); // we check and get the gata from that name mysql_query(query); mysql_store_result(); // we store the result. mysql_fetch_row_format(line, "."); // we set a delimiter sscanf(line, "p.issiii", pinfo[playerid][id], pinfo[playerid][nombre], pinfo[playerid][pass], pinfo[playerid][dinero], pinfo[playerid][trabajo], pinfo[playerid][admin]); // this will get the first 3 fields into pinfo[playerid][playeri] mysql_free_result(); new textto[128]; SendClientMessage(playerid, COLOR_LIGHTBLUE, textto); return 1; }
sscanf(line, "p<.>issiii", pinfo[playerid][id], pinfo[playerid][nombre], pinfo[playerid][pass], pinfo[playerid][dinero], pinfo[playerid][trabajo], pinfo[playerid][admin]); // this will get the first 3 fields into pinfo[playerid][playeri][/code{
new str[20];
sscanf("hello there", "s[20]", str);
Originally Posted by bogeyman_EST
The size of the string goes right behind the specifier.
Example: pawn Код:
|
sscanf(line, "p<.>is[/*insert size of pinfo[playerid][nombre] here */]s[/*insert size of pinfo[playerid][pass] here*/]iiiiiiiifffiii", pinfo[playerid][id], pinfo[playerid][nombre], pinfo[playerid][pass], pinfo[playerid][nivel], pinfo[playerid][dinero], pinfo[playerid][trabajo], pinfo[playerid][admin], pinfo[playerid][online], pinfo[playerid][phone], pinfo[playerid][banco], pinfo[playerid][skin], pinfo[playerid][px], pinfo[playerid][py], pinfo[playerid][pz], pinfo[playerid][hp], pinfo[playerid][armor], pinfo[playerid][sp]);