Little SQL query problem -
IgrexolonO - 26.01.2013
Haia! I have got a little problem with MySQL Query, and saving it into player variable.
So, here it goes;
#1 When I log into game, I want to send a player message about IDs:
Код:
format(sqlquery, 256, "SELECT `gid`, `forumID`, `adminLvl`, `skin`, `money`, `bMoney`, `lastPosX`, `lastPosY`, `lastPosZ`, `lastPosAngle` FROM `players` WHERE `login`='%s'", playerInfo[pid][playerName_]);
mysql_query(sqlquery);
mysql_store_result();
mysql_fetch_row_format(sqlstring);
sscanf(sqlstring, "p|iiiiiiffff",
playerInfo[pid][gid],
playerInfo[pid][forumID],
playerInfo[pid][adminLvl],
playerInfo[pid][skin],
playerInfo[pid][money],
playerInfo[pid][bMoney],
playerInfo[pid][lastPos][0],
playerInfo[pid][lastPos][1],
playerInfo[pid][lastPos][2],
playerInfo[pid][lastPos][3]);
mysql_free_result();
format(sqlquery, 256, "SELECT `username` FROM `mybb_users` WHERE `uid`='%i'", playerInfo[pid][forumID]);
mysql_query(sqlquery);
mysql_store_result();
mysql_fetch_row_format(sqlstring);
sscanf(sqlstring, "p|s",
playerInfo[pid][forumName]);
mysql_free_result();
format(formats, sizeof(formats), "S-RP: Witaj %s! Zalogowałeś się jako %s (ID: %d, GID: %d, FID: %d)", playerInfo[pid][forumName], pNameW(pid), pid, playerInfo[pid][gid], playerInfo[pid][forumID]);
SendClientMessage(pid, 0, formats);
But the only problem is about forumID. It's 1 and it finds my nickname successfully, but ingame:
/imageshack/img827/894/errords.jpg (FID: 101).
#2 Online time.
When player logs in, I'm using gettime() function, and I'm saving it into player's variable:
Код:
new Second = gettime();
playerInfo[pid][onlineTime] = Second;
Now, I've also got spec command, with sets textdraw's strings, but I'll give only example of time:
Код:
new time[2];
time[0] = gettime();
time[1] = (time[0] - playerInfo[id][onlineTime]);
printf("%i %i %i %i %i", time[0], time[1], playerInfo[id][onlineTime], (time[1] / 60), (time[0] - playerInfo[id][onlineTime]));
format(formats, sizeof(formats), "Czas gry: %i m", (time[1] / 60));
TextDrawSetString(specShowInfo[id][1], formats);
^ It's messed up, cause I was trying like everything.
Print gives: 1359197560 1359197560 0 22653292 1359197560
Thank you for any help! Regards!
Re: Little SQL query problem -
IgrexolonO - 26.01.2013
Dump, somebody?