GAGA Membru Activ
Numarul mesajelor : 437 Data nasterii : 25/07/1991 Data de inscriere : 20/12/2009 Varsta : 33 Localizare : Baile-Herculane
| Subiect: Sql Csstats Lun Feb 15, 2010 8:02 am | |
| Cu pluginul asta adaugati statistici ale jucatorilor in baza de date update-ul la baza de date se face numai pentru un jucator la fiecare deconectare a acestuia diferenta fata de alte pluginuri de genul asta este acest update care la altele am vazut ca se face la sfarsitul hartii la tot rankul iar daca aveti rank de 2000-3000 de jucatori atunci dureaza mult si serverul va fi indisponibil pe perioada de update iar acesta face update doar la un singur jucator (cand iese de pe server) - Cod:
-
#include <amxmodx> #include <dbi> #include <csx>
new Sql:dbc; new error[33]; new Result:result
public plugin_init() { register_plugin("SQL CSstats","1.2","Sim Master");
dbc = dbi_connect("localhost","root","","amx",error,32) if (dbc == SQL_FAILED) return PLUGIN_HANDLED
server_print("[SQL CSstats] Conexiune reusita"); return PLUGIN_HANDLED }
public client_disconnect(id) { new name[32]; get_user_name(id,name,32);
new stats[8], body[8] get_user_stats(id, stats, body); new score = stats[0]-stats[1]; result = dbi_query(dbc, "SELECT * FROM `sc_rank` WHERE `name` = '%s'", name); if (result <= RESULT_FAILED) { server_print("[SQL CSstats] Nu am putut extrage statistici despre %s",name); } else if (result == RESULT_NONE) { dbi_free_result(result); result = dbi_query(dbc, "INSERT INTO `sc_rank` (`name`,`kills`,`deaths`,`hd`,`shots`,`hits`,`damage`,`eff`,`acc`,`score`) VALUES ('%s','%d','%d','%d','%d','%d','%d','%3.0f%','%3.0f%','%d')", name, stats[0], stats[1], stats[2], stats[4], stats[5], stats[6], effec(stats), accuracy(stats), score); } else { dbi_free_result(result); result = dbi_query(dbc, "UPDATE `sc_rank` SET `kills` = '%d', `deaths` = '%d', `hd` = '%d', `shots` = '%d', `hits` = '%d', `damage` = '%d', `eff` = '%3.0f%', `acc` = '%3.0f%', `score` = '%d' WHERE `name` = '%s'", stats[0], stats[1], stats[2], stats[4], stats[5], stats[6], effec(stats), accuracy(stats), score, name); } return PLUGIN_HANDLED }
stock Float:accuracy(stats[8]) { if(!stats[4]) return ( 0.0 ); new Float:result result = 100.0 * float( stats[5] ) / float( stats[4] ); return (result > 100.0) ? 100.0 : result }
stock Float:effec(stats[8]) { if(!stats[0]) return ( 0.0 ); new Float:result result = 100.0 * float( stats[0] ) / float( stats[0] + stats[1] ); return (result > 100.0) ? 100.0 : result } modificati linia asta: - Cod:
-
dbc = dbi_connect("localhost","root","","amx",error,32) cu detaliile despre baza voastra de date (server,user,parola,nume_baza) codul SQL este: - Cod:
-
CREATE TABLE IF NOT EXISTS `sc_rank` ( `id` int(11) NOT NULL auto_increment, `name` char(255) NOT NULL, `kills` char(255) NOT NULL, `deaths` char(255) NOT NULL, `hd` char(255) NOT NULL, `shots` char(255) NOT NULL, `hits` char(255) NOT NULL, `damage` char(255) NOT NULL, `eff` char(255) NOT NULL, `acc` char(255) NOT NULL, `score` int(11) NOT NULL, PRIMARY KEY (`id`) Module necesare: CSX MySQL | |
|