AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   KZTOP [SQL] (https://forums.alliedmods.net/showthread.php?t=63960)

AcidoX 12-04-2007 15:47

KZTOP [SQL]
 
Hello :), i have a problem with my KZTOP [SQL] plugin. The problem is that if you finish a map with you nick it will add you in the top that is ok, but if you finish the current map, or the nextmap nomather what map if you finish with the nick that your already have been added to KZTOP then it will not add you again.

Code:

/*
// Use this to create the table
CREATE TABLE `kz_top` (
 `name` varchar(32) binary NOT NULL default '',
 `time` int(10) unsigned NOT NULL default '0',
 `cp` int(10) unsigned NOT NULL default '0',
 `gc` int(10) unsigned NOT NULL default '0',
 `map` varchar(32) binary NOT NULL default ''
) TYPE=MyISAM COMMENT='Climbers Top Table';
*/
#include <amxmodx>
#include <amxmisc>
#include <dbi>
#include <fun>
#include <kz>
new url[64];
new oldTimer[33];
new kz_enabled;
new Sql:sql;
new Result:result;
new error[33];
public plugin_init() {
 register_plugin("Climbers Top [SQL]", "2.01", "Bentski");
 kz_enabled = get_cvar_pointer("kz_enabled");
}
public kz_Init(_state) {
 if(!_state) {
  pause("a");
  return;
 }
 register_event("DeathMsg", "Event_DeathMsg", "a");
 
 register_cvar("amx_kzt_host", "127.0.0.1");
 register_cvar("amx_kzt_user", "root");
 register_cvar("amx_kzt_pass", "root");
 register_cvar("amx_kzt_db", "kz");
 register_cvar("amx_kzt_url", "http://127.0.0.1:8080/kz_top.php");
 new config[64];
 get_configsdir(config, 63);
 server_cmd("exec %s/kz/top.cfg", config);
 register_clcmd("say /top", "top_show");
 register_clcmd("say /top10", "top_show");
 register_clcmd("say /top15", "top_show");
 register_clcmd("say /top20", "top_show");
 
 set_task(1.0, "delayinit");
}
public delayinit() {
 new dbhost[32], dbuser[32], dbpass[32], dbname[32];
 get_cvar_string("amx_kzt_host", dbhost, 31);
 get_cvar_string("amx_kzt_user", dbuser, 31);
 get_cvar_string("amx_kzt_pass", dbpass, 31);
 get_cvar_string("amx_kzt_db", dbname, 31);
 get_cvar_string("amx_kzt_url", url, 63);
 sql = dbi_connect(dbhost, dbuser, dbpass, dbname, error, 32);
 if(sql == SQL_FAILED) {
  //sql = dbi_connect(dbhost, dbuser, dbpass, dbname, error, 32);
  server_print("[KZTOP] Could not connect to SQL database.");
  return;
 }
 server_print("[KZTOP] Connected to database.");
}
public Event_DeathMsg() {
 if(!get_pcvar_num(kz_enabled))
  return;
 new player = read_data(2);
 cs_set_user_deaths(player, cs_get_user_deaths(player) - 1);
}
public top_add(id, time, cp_count, gc_count) {
 new mapname[32];
 get_mapname(mapname, 32);
 new name[32];
 get_user_name(id, name, 32);
 replace_all(name, 31, "`", "\`");
 replace_all(name, 31, "'", "\'");
 result = dbi_query(sql, "SELECT time FROM kz_top WHERE name='%s' AND map='%s'", name, mapname);
 if(result == RESULT_NONE) {
  dbi_query(sql, "INSERT INTO kz_top VALUES ('%s', '%d', '%d', '%d', '%s')", name, time, cp_count, gc_count, mapname);
 } else if(result <= RESULT_FAILED) {
  server_print("[AMXX] SQL error.");
 }  else {
  new qtime = dbi_field(result, 1);
  dbi_free_result(result);
  if(time < qtime)
  dbi_query(sql, "UPDATE kz_top SET time='%d', cp='%d', gc='%d' WHERE name='%s' AND map='%s'", time, cp_count, gc_count, name, mapname);
 }
}
public kz_FinishClimb(player, time, cp_count, gc_count) {
 if(oldTimer[player] == 0 || time < oldTimer[player]) {
  oldTimer[player] = time;
  set_user_frags(player, time / 60);
  set_user_frags(player, time / 60);
  cs_set_user_deaths(player, time % 60);
 }
 top_add(player, time, cp_count, gc_count);
}
public top_show(id) {
 new path[128];
 new mapname[32];
 get_mapname(mapname, 32);
 format(path, 128, "%s?map=%s&rand=%d", url, mapname, random_num(0, 65535));
 show_motd(id, path);
}

Help pls :)
I have found a newer version ir my PC. Edited.

AcidoX 12-05-2007 11:32

Re: KZTOP [SQL]
 
Nobody? :cry:


All times are GMT -4. The time now is 11:05.

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