Raised This Month: $ Target: $400
 0% 

Saving data to SQL


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 05:15.


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