Helló, SQL mentéshez kell egy hosting, például amin a szervered fut, tőlük lehet igényelni ingyen adatbázist. Egyébként mforce tutorialja megtalálható itt: SQL Tutorial Végül a kért mentésed.
Kód: #include <amxmodx> #define PLUGIN "Plugin" #define VERSION "1.0" #define AUTHOR "mforce" new kills[33];
//fvaultos rész new filename[128]; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_event("DeathMsg", "eDeathMsg", "a") set_task(1.0, "HUD", 0, _, _, "b") //Ez az addons/amxmodx/configs mappába menti. get_localinfo("amxx_configsdir", filename, charsmax(filename)) //Fájlnév format(filename, charsmax(filename), "%s/mforce_fajlmentes.ini", filename) } public eDeathMsg() { new killer = read_data(1); new victim = read_data(2);
if(killer != victim) { kills[killer]++; } }
public HUD() { static id for(id = 1; id <= get_maxplayers(); id++) { set_hudmessage(0, 255, 0, 0.01, 0.20, 0, 6.0, 1.0) show_hudmessage(id, "[Oles: %i]", kills[id]) } return PLUGIN_CONTINUE; }
public client_disconnect(id) { if (is_user_bot(id) || is_user_hltv(id)) return; save(id); }
public client_authorized(id) { if(!is_user_bot(id) && !is_user_hltv(id)) { load(id); } }
public save(id) { new szData[128]; new steamid[32]; get_user_authid(id, steamid, charsmax(steamid)); if(contain(steamid, "_ID_LAN") != -1) get_user_ip(id, steamid, charsmax(steamid), 1); formatex(szData, charsmax(szData), "%i", kills[id]); set_data(steamid, szData) }
public load(id) { new szData[128]; new steamid[32]; get_user_authid(id, steamid, charsmax(steamid)); if(contain(steamid, "_ID_LAN") != -1) get_user_ip(id, steamid, charsmax(steamid), 1); if(get_data(steamid, szData, charsmax(szData))) { new kills_cache[32]; parse(szData, kills_cache, charsmax(kills_cache)); kills[id] = str_to_num(kills_cache) } }
//Ezeket hagyd békén, nem kell velük semmit se csinálni. stock get_data(const key[], data[], len) { new vault = fopen(filename, "rt"); new _data[512], _key[64]; while( !feof(vault) ) { fgets(vault, _data, charsmax(_data)); parse(_data, _key, charsmax(_key), data, len); if( equal(_key, key) ) { fclose(vault); return 1; } } fclose(vault); copy(data, len, ""); return 0; } stock set_data(const key[], const data[]) { static const temp_vault_name[] = "set_data.txt"; new file = fopen(temp_vault_name, "wt"); new vault = fopen(filename, "rt"); new _data[512], _key[64], _other[32]; new bool:replaced = false; while( !feof(vault) ) { fgets(vault, _data, charsmax(_data)); parse(_data, _key, charsmax(_key), _other, charsmax(_other)); if( equal(_key, key) && !replaced ) { fprintf(file, "^"%s^" ^"%s^"^n", key, data); replaced = true; } else { fputs(file, _data); } } if( !replaced ) { fprintf(file, "^"%s^" ^"%s^"^n", key, data); } fclose(file); fclose(vault); delete_file(filename); while( !rename_file(temp_vault_name, filename, 1) ) { } //delete_file(temp_vault_name); }
|