SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/01/2013, 10:32 AM   #1
IgrexolonO
Big Clucker
 
Join Date: Dec 2007
Posts: 87
Reputation: -7
Default Little SQL query problem

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:

Code:
	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:

http://img827.imageshack.us/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:

Code:
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:

Code:
	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!
__________________
IgrexolonO is offline   Reply With Quote
Old 26/01/2013, 12:19 PM   #2
IgrexolonO
Big Clucker
 
Join Date: Dec 2007
Posts: 87
Reputation: -7
Default Re: Little SQL query problem

Dump, somebody?
__________________
IgrexolonO is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query problem. Rokzlive Help Archive 6 10/04/2011 11:16 PM
Another query problem. Rokzlive Help Archive 6 29/03/2011 06:06 PM
query sql problem vardanega Help Archive 2 31/01/2011 04:37 PM
Failed to exeute query. Lost connection to MySQL server during query. *IsBack Help Archive 10 06/01/2011 09:50 AM
Query String problem Wrath2k10 Help Archive 0 24/08/2010 04:52 PM


All times are GMT. The time now is 12:01 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.