[ExperienceMod] Silnik
Skull3D
15.09.2011
Załączam wam silnik ExperienceMod roboty xmS
Plugin dodaje gdyż będą do niego tutoriale
Plugin dodaje gdyż będą do niego tutoriale
/*--------------------- / / Silnik XP Mod / /----------------------*/ #include <amxmodx> #include <cstrike> #include <fun> #include <amxmisc> #include <nvault> #include <ColorChat> #include <fakemeta> #define MAXLEVEL 10 #define prefix "XP" /*--------===== HEAD SPLASH DEFINES =====-------*/ #define MINIMUM_FALL_SPEED 300 #define MAXIMUM_DAMAGE_FROM_JUMP 70.0 #define DAMAGE 5.0 #define DELAY 0.03 new const LEVELS[10] = { // Level 500, // 1 3000, // 2 8000, // 3 15000, // 4 19000, // 5 25000, // 6 31000, // 7 38000, // 8 41000, // 9 50000 // 10 }; new const RANGI[10][] = { "Ranga 1", "Ranga 2", "Ranga 3", "Ranga 4", "Ranga 5", "Ranga 6", "Ranga 7", "Ranga 8", "Ranga 9", "Ranga 10" }; /*--------===== ZMIENNE GLOBALNE =====-------*/ new g_Vault,xp_kill,xp_hs,xp_headsplash,SkillPoints[33],PlayerXP[33],PlayerLevel[33]; new Float:falling_speed[33]; new Float:damage_after[33][33]; new amx_headsplash; new sprite_blood; new sprite_bloodspray; public plugin_init() { /*--------===== REJERSTRACJA PLUGINU =====-------*/ register_plugin("SILNIK XP MOD", "1.0", "xmS") /*--------===== CVARY =====-------*/ register_cvar("xp_kill", "25") register_cvar("xp_hs","10") register_cvar("xp_headsplash","35") amx_headsplash = register_cvar("amx_headsplash", "1"); /*--------===== ZMIENNE GLOBALNE =====-------*/ xp_kill = get_cvar_num("xp_kill") xp_hs = get_cvar_num("xp_hs") xp_headsplash = get_cvar_num("xp_headsplash") g_Vault = nvault_open("xms_xp_mod"); /*--------===== FORWARDS =====-------*/ register_forward(FM_PlayerPreThink, "hud_prethink"); register_forward(FM_Touch, "forward_touch"); /*--------===== EVENTS =====-------*/ register_event("DeathMsg", "eDeath", "a"); } public eDeath() { new attacker = read_data( 1 ); new ofiara = read_data( 2 ); new headshot = read_data( 3 ); if(ofiara != attacker && attacker != 0) { if(get_user_team(attacker) != get_user_team(ofiara)) { PlayerXP[attacker] += xp_kill; if(headshot) { PlayerXP[attacker] += xp_hs; ColorChat(attacker,GREEN,"[%s]^x01: Dostales ^x04%d^x01 xp za zabicie wroga oraz bonus^x04 %d^x01 xp za headshot'a !",prefix,xp_kill,xp_hs); } else { ColorChat(attacker,GREEN,"[%s]^x01: Dostales ^x04%d^x01 xp za zabicie wroga",prefix,xp_kill); } } } while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) { PlayerLevel[attacker] += 1; SkillPoints[attacker] += 1; ColorChat(attacker,GREEN,"[%s]^x01: Gratuluje, wbiles poziom ! Twoj Poziom to :^x03 %d^x01, posiadasz :^x03 %d^x01 punktow skilli.",prefix,PlayerLevel[attacker],SkillPoints[attacker]); } } public hud_prethink(id) { if(PlayerLevel[id]>=MAXLEVEL) { new text[512] format(text,511,"Level: %d Exp: %d Ranga: %s",PlayerLevel[id],PlayerXP[id],RANGI[PlayerLevel[id]]) message_begin(MSG_ONE,get_user_msgid("StatusText"),{0,0,0}, id) write_byte(0) write_string(text) message_end() } else { new text[512] format(text,511,"Level: %d Exp: %d/%d (+%d) Ranga: %s", PlayerLevel[id], PlayerXP[id], LEVELS[PlayerLevel[id]],LEVELS[PlayerLevel[id]]-PlayerXP[id],RANGI[PlayerLevel[id]]) message_begin(MSG_ONE,get_user_msgid("StatusText"),{0,0,0}, id) write_byte(0) write_string(text) message_end() } } public client_connect(id) LoadXp(id); public client_disconnect(id) SaveXp(id); public SaveXp(id) { new AuthID[35]; get_user_authid(id, AuthID, 34); new vaultkey[64], vaultdata[256]; format(vaultkey, 63, "%s-Mod", AuthID); format(vaultdata, 255, "%i#%i#%i#", PlayerXP[id], PlayerLevel[id],SkillPoints[id]); nvault_set(g_Vault, vaultkey, vaultdata); return PLUGIN_CONTINUE; } public LoadXp(id) { new AuthID[35]; get_user_authid(id,AuthID,34); new vaultkey[64], vaultdata[256]; format(vaultkey, 63, "%s-Mod", AuthID); format(vaultdata, 255, "%i#%i#%i#", PlayerXP[id], PlayerLevel[id],SkillPoints[id]); nvault_get(g_Vault, vaultkey, vaultdata,255); replace_all(vaultdata, 255, "#", " "); new playerxp[32], playerlevel[32], skillpoints[32]; parse(vaultdata, playerxp, 31, playerlevel, 31, skillpoints, 31); PlayerXP[id] = str_to_num(playerxp); PlayerLevel[id] = str_to_num(playerlevel); SkillPoints[id] = str_to_num(skillpoints); return PLUGIN_CONTINUE; } public forward_touch(toucher, touched) { if(!is_user_alive(toucher) || !is_user_alive(touched)) return; if(!get_pcvar_num(amx_headsplash)) return; if(falling_speed[touched]) return; if(get_user_team(toucher) == get_user_team(touched) && !get_cvar_num("mp_friendlyfire")) return; new touched_origin[3], toucher_origin[3]; get_user_origin(touched, touched_origin); get_user_origin(toucher, toucher_origin); new Float:toucher_minsize[3], Float:touched_minsize[3]; pev(toucher,pev_mins,toucher_minsize); pev(touched,pev_mins,touched_minsize); if(touched_minsize[2] != -18.0) { if(!(toucher_origin[2] == touched_origin[2]+72 && toucher_minsize[2] != -18.0) && !(toucher_origin[2] == touched_origin[2]+54 && toucher_minsize[2] == -18.0)) { return; } } else { if(!(toucher_origin[2] == touched_origin[2]+68 && toucher_minsize[2] != -18.0) && !(toucher_origin[2] == touched_origin[2]+50 && toucher_minsize[2] == -18.0)) { return; } } if(falling_speed[toucher] >= MINIMUM_FALL_SPEED) { new Float:damage = ((falling_speed[toucher] - MINIMUM_FALL_SPEED + 30) * (falling_speed[toucher] - MINIMUM_FALL_SPEED + 30)) / 1300; if(damage > MAXIMUM_DAMAGE_FROM_JUMP) damage = MAXIMUM_DAMAGE_FROM_JUMP; damage_player(touched, toucher, damage); damage_after[toucher][touched] = 0.0; } if(is_user_alive(touched) && damage_after[toucher][touched] <= get_gametime()) { damage_after[toucher][touched] = get_gametime() + DELAY; damage_player(touched, toucher, DAMAGE); } } public damage_player(pwned, pwnzor, Float:damage) { new health = get_user_health(pwned); if(get_user_team(pwned) == get_user_team(pwnzor)) damage /= 1.4; new CsArmorType:armortype; cs_get_user_armor(pwned, armortype); if(armortype == CS_ARMOR_VESTHELM) damage *= 0.7; if(health > damage) { new pwned_origin[3]; get_user_origin(pwned, pwned_origin); message_begin(MSG_BROADCAST, SVC_TEMPENTITY); write_byte(TE_BLOODSPRITE); write_coord(pwned_origin[0]+8); write_coord(pwned_origin[1]); write_coord(pwned_origin[2]+26); write_short(sprite_bloodspray); write_short(sprite_blood); write_byte(248); write_byte(4); message_end(); new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "trigger_hurt")); if(!ent) return; new value[16]; float_to_str(damage * 2, value, sizeof value - 1); set_kvd(0, KV_ClassName, "trigger_hurt"); set_kvd(0, KV_KeyName, "dmg"); set_kvd(0, KV_Value, value); set_kvd(0, KV_fHandled, 0); dllfunc(DLLFunc_KeyValue, ent, 0); num_to_str(DMG_GENERIC, value, sizeof value - 1); set_kvd(0, KV_ClassName, "trigger_hurt"); set_kvd(0, KV_KeyName, "damagetype"); set_kvd(0, KV_Value, value); set_kvd(0, KV_fHandled, 0); dllfunc(DLLFunc_KeyValue, ent, 0); set_kvd(0, KV_ClassName, "trigger_hurt"); set_kvd(0, KV_KeyName, "origin"); set_kvd(0, KV_Value, "8192 8192 8192"); set_kvd(0, KV_fHandled, 0); dllfunc(DLLFunc_KeyValue, ent, 0); dllfunc(DLLFunc_Spawn, ent); set_pev(ent, pev_classname, "head_splash"); dllfunc(DLLFunc_Touch, ent, pwned); engfunc(EngFunc_RemoveEntity, ent); } else { new pwned_origin[3]; get_user_origin(pwned, pwned_origin); message_begin(MSG_BROADCAST, SVC_TEMPENTITY); write_byte(TE_BLOODSPRITE); write_coord(pwned_origin[0]+8); write_coord(pwned_origin[1]); write_coord(pwned_origin[2]+26); write_short(sprite_bloodspray); write_short(sprite_blood); write_byte(248); write_byte(12); message_end(); set_pev(pwned, pev_frags, float(get_user_frags(pwned) + 1)); user_silentkill(pwned); make_deathmsg(pwnzor, pwned, 1, "his/her feet <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/smile.png' class='bbc_emoticon' alt=':)' />"); if(get_user_team(pwnzor) != get_user_team(pwned)) { set_pev(pwnzor, pev_frags, float(get_user_frags(pwnzor) + 1)); cs_set_user_money(pwnzor, cs_get_user_money(pwnzor) + 300); PlayerXP[pwnzor]+=xp_headsplash; ColorChat(pwnzor,GREEN,"[%s]^x01: Zabiles headsplashem , dostales %d xp.",prefix,xp_headsplash); while(PlayerXP[pwnzor] >= LEVELS[PlayerLevel[pwnzor]]) { client_cmd(pwnzor,"stopsound;wait;mp3 play sound/misc/xmsexpmod/lvlup.mp3") PlayerLevel[pwnzor] += 1; SkillPoints[pwnzor] += 1; ColorChat(pwnzor,GREEN,"[%s]^x01: Level UP ! Twoj Poziom =^x03 %d^x01 Skill Points =^x03 %d",prefix,PlayerLevel[pwnzor],SkillPoints[pwnzor]); } } else { set_pev(pwnzor, pev_frags, float(get_user_frags(pwnzor) - 1)); cs_set_user_money(pwnzor, cs_get_user_money(pwnzor) - 300); } message_begin(MSG_ALL, get_user_msgid("ScoreInfo")); write_byte(pwnzor); write_short(get_user_frags(pwnzor)); write_short(cs_get_user_deaths(pwnzor)); write_short(0); write_short(get_user_team(pwnzor)); message_end(); message_begin(MSG_ALL, get_user_msgid("ScoreInfo")); write_byte(pwned); write_short(get_user_frags(pwned)); write_short(cs_get_user_deaths(pwned)); write_short(0); write_short(get_user_team(pwned)); message_end(); set_pev(pwned, pev_frags, float(get_user_frags(pwned) - 1)); } }
diggs
15.09.2011
Moim zdaniem powinno się odejść już od NVault a przejść na bazy danych bo dają dużo więcej możliwości niż NVault.
Użytkownik diggs edytował ten post 15.09.2011 17:29
Użytkownik diggs edytował ten post 15.09.2011 17:29
diggs
15.09.2011
Tylko że jeśli chcesz zapisywać coś do baz danych musisz zabezpieczyć je i siebie przed ewentualnymi błędami, a dokonanie czegoś takiego nie jest proste i nie można zrobić czegoś takiego w ciągu kilku minut czy godzin. Po za tym żeby to przerobić trzeba by wywalić znaczą część kodu i dopisać jeszcze raz tyle.
Ja osobiście tego nie będę przerabiał bo mam już takie rozwiązanie, może ktoś inny się na to zdecyduje. Mi osobiście dopracowanie pluginów korzystających z baz danych zajęło ok 6 miesięcy, pisałem poprawki i od razu były testowane na serwerze, a po drodze było wiele błędów i problemów głównie wynikających z mojej niewiedzy ale było warto bo to naprawdę daje fajne możliwości i prowadzi w pewnym sensie do zautomatyzowania niektórych czynności (nie będę ujawniał szczegółów zostawię do do indywidualnych przemyśleń).
Ja osobiście tego nie będę przerabiał bo mam już takie rozwiązanie, może ktoś inny się na to zdecyduje. Mi osobiście dopracowanie pluginów korzystających z baz danych zajęło ok 6 miesięcy, pisałem poprawki i od razu były testowane na serwerze, a po drodze było wiele błędów i problemów głównie wynikających z mojej niewiedzy ale było warto bo to naprawdę daje fajne możliwości i prowadzi w pewnym sensie do zautomatyzowania niektórych czynności (nie będę ujawniał szczegółów zostawię do do indywidualnych przemyśleń).
A może sma?
15.09.2011
Automatyzację można osiągnąć również po przez nvalut - stosująć php, konsole rcon no i oczwiście odpowiednie komendy
diablix
15.09.2011
Nvault jest szybsze no ale zrobienie statystyk www z nvault wymaga sporo zabawy
diggs
15.09.2011
Czyli dużo więcej pracy i zachodu niż przy sql'u bo w php brak odpowiednich bibliotek, a jak ktoś się zna na bazach danych to plugin zrobi szybciej niż ja.Automatyzację można osiągnąć również po przez nvalut - stosująć php, konsole rcon no i oczwiście odpowiednie komendy
Edit.
@up - o ile szybsze? o tyle że nie trzeba czekać na odpowiedź serwera baz danych? Nawet jeśli serwer gry i serwer baz danych łączą się przez sieć opóźnienia nie są aż tak dokuczliwe.
Użytkownik diggs edytował ten post 15.09.2011 18:27
R3X
15.09.2011
Testowałem na małych danych różnicę nVault vs MySQLowy localhost i była kilkukrotna przebitka, jakoś 1ms kontra 20ms; dla większych danych pewnie różnice by były mniej zauważalna, ale zawsze. Tylko..operacje na zewnętrznych danych są dość rzadkie, w prostym modelu można się zmieścić w 1 operacji odczytu i 1 zapisu. Przewaga w funkcjonalności serwera bazy danych nad mapą użytą w nVault jest jednak ogromna i wg mnie warta tych kilku ms więcej
mierzwi
15.09.2011
1. usuń wogóle ten silnik, hud_prethink? dobre...
2. sql czy nvault, można dodać dwa
2. sql czy nvault, można dodać dwa

Jak się nazwać
28.01.2012
Jak dla mnie temat do kosza czemu? Hud - prethink i co jeszcze ? Funkcja na damage haha dobre
od kiedy jest kanapka nie powinno się w ogóle o takich rzeczach myśleć, fakemeta? Szybsze i mniej obciążające jest engine które posiada prawie identyczne funkcje (w sumie identyczne bo tu nie ma util czyli sotcków do fake)
