Raised This Month: $32 Target: $400
 8% 

How to store information in a database.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FrostSurf
Member
Join Date: Oct 2014
Old 08-22-2015 , 18:24   How to store information in a database.
Reply With Quote #1

This plugin only stores information until map change. Am i able to make it store the information in my MySQL database so it saves it forever ?

Code:
public OnMapStart()
{
	for (new i = 0; i < MAX_LEVEL-1; i++)
	{
		for (new client = 1; client < MAXPLAYERS; client++)
		{
			g_MapLevelBestTime[i][client] = 0.0;
		}
	}
}

public OnClientStartTouchLevel(client, level, lastlevel)
{
	PrintTimeDiff(client, level, lastlevel);
}

public OnClientStartTouchBonusLevel(client, level, lastlevel)
{
	PrintTimeDiff(client, level, lastlevel);
}

stock PrintTimeDiff(client, level, lastlevel)
{
	if(level == lastlevel+1)
	{
		new bool:enabled = false;
		new Float:time;
		new jumps;
		new fpsmax;
		new String:buffer[32];
		
		Timer_GetClientTimer(client, enabled, time, jumps, fpsmax);
		
		if(enabled)
		{
			if(g_MapLevelBestTime[level][client] == 0.0)
			{
				Timer_SecondsToTime(time, buffer, sizeof(buffer), 2);
				#if defined LEGACY_COLORS
				CPrintToChat(client,"{red}[{green}Timer{red}]{green} Checkpoint {red}[{green}-00:00.00{red}]");
				#else
				#endif
				g_MapLevelBestTime[level][client] = time;
			}
			else if(g_MapLevelBestTime[level][client] > time)
			{
				Timer_SecondsToTime(g_MapLevelBestTime[level][client]-time, buffer, sizeof(buffer), 2);
				#if defined LEGACY_COLORS
				CPrintToChat(client, "{red}[{green}Timer{red}]{green} Checkpoint {red}[{green}-%s{red}]", buffer);
				#else
				#endif
				g_MapLevelBestTime[level][client] = time;
			}
			else if(g_MapLevelBestTime[level][client] == time)
			{
				#if defined LEGACY_COLORS
				CPrintToChat(client, "{red}[{green}Timer{red}]{green} Checkpoint {red}[+00:00.00]");
				#else
				#endif
			}
			else if(g_MapLevelBestTime[level][client] < time)
			{
				Timer_SecondsToTime(time-g_MapLevelBestTime[level][client], buffer, sizeof(buffer), 2);
				#if defined LEGACY_COLORS
				CPrintToChat(client, "{red}[{green}Timer{red}]{green} Checkpoint {red}[+%s]", buffer);
				#else
				#endif
			}
		}
	}
}
FrostSurf is offline
FrostSurf
Member
Join Date: Oct 2014
Old 08-22-2015 , 18:38   Re: How to store information in a database.
Reply With Quote #2

I already have a MySQL database ready and other components of this timer are using mysql, i dont know if that helps any.
FrostSurf is offline
SoulSharD
Member
Join Date: Oct 2013
Location: United Kingdom
Old 08-22-2015 , 18:47   Re: How to store information in a database.
Reply With Quote #3

https://wiki.alliedmods.net/SQL_%28S...d_Scripting%29

Ta da!
__________________

SoulSharD is offline
FrostSurf
Member
Join Date: Oct 2014
Old 08-22-2015 , 18:50   Re: How to store information in a database.
Reply With Quote #4

Quote:
Originally Posted by SoulSharD View Post
Doh! Thanks i will take a read at that.
FrostSurf is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 08-22-2015 , 22:06   Re: How to store information in a database.
Reply With Quote #5

Quote:
Originally Posted by FrostSurf View Post
Doh! Thanks i will take a read at that.
Be sure to use Threaded everything on SQL
headline is offline
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

Forum Jump


All times are GMT -4. The time now is 16:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode