Raised This Month: $ Target: $400
 0% 

Saving data to SQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ESTCOBS
Junior Member
Join Date: May 2008
Location: Kraków, Poland
Old 05-23-2010 , 22:04   Saving data to SQL
Reply With Quote #1

Hi :]
This is the code for a making screenshots of players.
Could some one add code to saving to SQL : admin-nick;nick;ip;steamid;date ?
I want to in my MySQL DB at table amx_screenshots saved the admin nick, player [which is taken snapshots] nick, player ip, player steamid, date

Code:
#include <amxmodx>
#include <amxmisc>

#define VERSION		"0.9"

new g_Hostname, g_DelaySS, g_DelayBan, g_SnapShot, g_UnbanURL

public plugin_init()
{
	register_plugin("ScreenShots", VERSION, "ESTcobs")
	
	register_dictionary("admincmd.txt")
	register_dictionary("screenshots.txt")

	g_Hostname = get_cvar_pointer("hostname")
	g_DelaySS = register_cvar("ss_delay", "1.5")
	g_DelayBan = register_cvar("ss_bandelay", "15.0")
	g_SnapShot = register_cvar("ss_number", "3")
	g_UnbanURL = register_cvar("ss_website", "www.ESTcobs.pl")
	
	register_concmd("mbs_ss", "zrobSS", ADMIN_KICK, "<name lub #userid> - ")
	register_concmd("mbs_ssban", "zrobSSban", ADMIN_BAN, "<nick lub #userid> - ")
}

public zrobSS(id,level,cid)
{
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED
	
	new target[32]
	read_argv(1, target, 31)
	new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY)

	if(!player)
		return PLUGIN_HANDLED

	new Param[2]
	Param[0] = id
	Param[1] = player

	set_task(Float:get_pcvar_float(g_DelaySS), "SS_Task", 0, Param,2, "a", get_pcvar_num(g_SnapShot))

	return PLUGIN_HANDLED
}

public zrobSSban(id,level,cid)
{
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED
	
	new target[32]
	read_argv(1, target, 31)
	new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY)

	if(!player)
		return PLUGIN_HANDLED

	new Param[2]
	Param[0] = id
	Param[1] = player

	set_task(Float:get_pcvar_float(g_DelaySS), "SS_Task", 0, Param,2, "a", get_pcvar_num(g_SnapShot))
	set_task(Float:get_pcvar_float(g_DelayBan), "BanSS_Task", 0, Param,2)

	return PLUGIN_HANDLED
}

public SS_Task(Param[2])
{
	new player = Param[1]
	new id = Param[0]
	new name[32], timer[32], hostname[64], name2[32], ip[32], authid2[32], site[64]

	get_user_name(id, name, 31)
	get_user_name(player, name2, 31)
	get_user_authid(player, authid2, 31)
	get_user_ip(player, ip, 31, 1)

	get_time("%d/%m/%Y - %H:%M:%S", timer, 63)
	get_pcvar_string(g_Hostname, hostname, charsmax(hostname))
	get_pcvar_string(g_UnbanURL, site, charsmax(site))

	client_print(player, print_chat, "%L", LANG_PLAYER, "SS_MSG1", name)
	client_print(player, print_chat, "%L", LANG_PLAYER, "SS_MSG2", timer, hostname)
	client_print(player, print_chat ,"%L", LANG_PLAYER, "SS_MSG3", name2, ip, authid2)
	client_print(player, print_chat ,"%L", LANG_PLAYER, "SS_MSG4", site)

	set_hudmessage(150, 0, 255, -1.0, 0.1, 0, 0.25, 1.0, 0.0, 0.0, 4)
	show_hudmessage(player, "%L", player, "SS_MSG_HUD", timer, hostname, name2, ip, authid2, site)

	client_cmd(player,"snapshot")

	return PLUGIN_HANDLED
}

public BanSS_Task(Param[])
{
	new id = Param[0]
	new player = Param[1]
	new userid2 = get_user_userid(player)

	client_cmd(id, "amx_ban 0 #%d ^"HERE REASON^"", userid2)
	
	return PLUGIN_HANDLED
}
Thanks a lot for help :]
__________________
Róót ! xD
ESTCOBS is offline
Old 05-24-2010, 00:26
ESTCOBS
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
Old 05-24-2010, 00:30
lazarev
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
Brreaker
Senior Member
Join Date: Oct 2009
Location: Constanta, Romania
Old 05-24-2010 , 06:58   Re: Saving data to SQL
Reply With Quote #2

Wiki is your friend!
http://wiki.alliedmods.net/Advanced_...X)#SQL_Support
__________________
There are 10 kinds of people.Those who understand binary, and those who don't.
Also, for those who understand binary, there is a donation tab too!
No steam || PM support!
Brreaker is offline
Send a message via MSN to Brreaker Send a message via Yahoo to Brreaker
ESTCOBS
Junior Member
Join Date: May 2008
Location: Kraków, Poland
Old 05-24-2010 , 10:03   Re: Saving data to SQL
Reply With Quote #3

huh, could you give me a working code ?
my attempts ends in compilation errors :/
__________________
Róót ! xD
ESTCOBS is offline
Old 05-30-2010, 09:47
ESTCOBS
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post. Bump again and topic will be locked.
Old 05-30-2010, 10:40
unnyquee
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post. Bump again and topic will be locked.
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 08:04.


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