Raised This Month: $51 Target: $400
 12% 

MySQL Simple Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fmmymir
New Member
Join Date: Mar 2018
Old 03-16-2018 , 02:30   MySQL Simple Plugin
Reply With Quote #1

Hello guys, can someone teach me how can i save a value (like an array) on a database table.
I want something simple which is working. Please don't post this link https://wiki.alliedmods.net/SQL_(SourceMod_Scripting) cause it didn't helped me. Thank you!
fmmymir is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-16-2018 , 02:51   Re: MySQL Simple Plugin
Reply With Quote #2

If it's working why ask for help?

Please provide more specific information including code.
__________________
Neuro Toxin is offline
fmmymir
New Member
Join Date: Mar 2018
Old 03-16-2018 , 02:58   Re: MySQL Simple Plugin
Reply With Quote #3

Code:
#include <sourcemod>
#include <cstrike>

Database db;
new g_Credits[MAXPLAYERS+1];

public Plugin:myinfo =
{
	name = "Very Basic Shop",
	author = "Fmmymir",
	description = "Test",
	version = "1.0",
	url = ""
};

public OnPluginStart()
{
	HookEvent("player_death", playerDeath);
	
	new String:error[256];
	db = SQL_DefConnect(error, sizeof(error))
	
	if(db == INVALID_HANDLE)
	{
		PrintToServer("Could not connect: %s", error)
	}
}

public Action:playerDeath(Handle:event, const String:name[], bool:dontBroadcast) 
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(attacker != 0 && attacker != client)
	{
		if(GetClientTeam(attacker) == CS_TEAM_T && GetClientTeam(client) == CS_TEAM_CT)
		{
			g_Credits[attacker] += 2;
			PrintToChat(attacker, "You got 2 points!");
		}
	}
}
My small plugin, and im trying to make it save the points on database.

Last edited by fmmymir; 03-16-2018 at 03:00.
fmmymir is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 03-16-2018 , 11:52   Re: MySQL Simple Plugin
Reply With Quote #4

Quote:
Originally Posted by fmmymir View Post
Hello guys, can someone teach me how can i save a value (like an array) on a database table.
I want something simple which is working. Please don't post this link https://wiki.alliedmods.net/SQL_(SourceMod_Scripting) cause it didn't helped me. Thank you!
This is a scripting help forum, not a "spoon-feed" or babysitter forum where you get everything served on a silver platter.

There are already at least 3 admin-related plugins included with SouceMod you can have a look at:

-> admin-sql-threaded.sp
-> admin-sql-prefetch.sp
-> sql-admin-manager.sp

If these as well are of no help to you, the way for you to go would be to hire a developer instead.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 03-16-2018 , 12:36   Re: MySQL Simple Plugin
Reply With Quote #5

For points only you can use clientprefs. It is much simplier and similar to trie. And you don't have to work with databases at all. Everything is done and perfectly fits your need for points storage.
Reiko1231 is offline
Reply



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 01:00.


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