#include #include #include #include #include #include #include #define MAXLEVEL 10 #define prefix "XP" /*--------===== HEAD SPLASH DEFINES =====-------*/ #define MINIMUM_FALL_SPEED 0.01 #define MAXIMUM_DAMAGE_FROM_JUMP 70 #define DAMAGE 70 #define DELAY 0.01 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 pointshp[33], pointsgranat[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"); /*------==== LOG EVENTY ====-----*/ register_logevent("EventRoundStart",2,"1=Round_Start"); } public EventRoundStart(id) { for (new id=0; id < 32; id++) { new starthealth = get_user_health( id ); // sprawdzamy ile gracz ma zycia set_user_health( id, pointshp[id] * 10 + starthealth ); // do jego zycia dodajemy nasz skill // razy 10 czyli 1 * 10 = 10 (2 * 10 = 20 etc.) + jego zycie na start } if(pointsgranat[id] >= 1) { set_task(5.0, "weapon_granaty", id); } } 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 skill_menu(id) { new msgtitle[128] format(msgtitle,127,"\w[\rExpMod\w]\y Posiadasz skillow: %d", SkillPoints[id]); new menu_exp = menu_create(msgtitle, "cbskill_menu") // dajemy w title format, poniewaz nowy styl menu nie obsluguje zmiennych po przecinku menu_additem(menu_exp , "Zycie", "1", 0) menu_additem(menu_exp , "Granaty", "2", 0) menu_setprop(menu_exp,MPROP_EXITNAME,"\wWyjscie"); // zamieniamy exit na wyjscie menu_display(id, menu_exp, 0) } public cbskill_menu(id, menu , item) { new data[6], iName[64] new acces, callback menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback) new klawisz = str_to_num(data) switch(klawisz) { case 1 : { if(SkillPoints[id] == 0) { // sprawdzamy czy posiada wolny skill ColorChat(id, GREEN, "[Exp Mod]^x01 Nie posiadasz wolnych skillow!"); } else { if(pointshp[id] >= 5) { // jesli gracz dodal 5 skilli do zycia to juz nie moze ColorChat(id, GREEN, "[Exp Mod]^x01 Masz juz maksymalna ilosc skillow"); } else { SkillPoints[id] -= 1; // zabieramy wolny skill pointshp[id] += 1; // dodajemy skill zycia ColorChat(id, GREEN, "******** Dodanie skilla do Zycia zakonczone sukcesem!"); } } } case 2 : { if(SkillPoints[id] == 0) { // sprawdzamy czy posiada wolny skill ColorChat(id, GREEN, "[Exp Mod]^x01 Nie posiadasz wolnych skillow!"); } else { if(pointsgranat[id] >= 5) { // jesli gracz dodal 5 skilli do zycia to juz nie moze ColorChat(id, GREEN, "[Exp Mod]^x01 Masz juz maksymalna ilosc skillow"); } else { SkillPoints[id] -= 1; // zabieramy wolny skill pointsgranat[id] += 1; // dodajemy skill zycia ColorChat(id, GREEN, "******** Dodanie skilla do Zycia zakonczone sukcesem!"); } } } } } 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#%i#", PlayerXP[id], PlayerLevel[id],SkillPoints[id], pointshp[id], pointsgranat[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#%i#", PlayerXP[id], PlayerLevel[id],SkillPoints[id], pointshp[id], pointsgranat[id]); nvault_get(g_Vault, vaultkey, vaultdata,255); replace_all(vaultdata, 255, "#", " "); new playerxp[32], playerlevel[32], SkillPointsx[32], pointshpx[32], pointsgranatx[32]; parse(vaultdata, playerxp, 31, playerlevel, 31, SkillPointsx, 31, pointshpx, 31, pointsgranatx, 31); PlayerXP[id] = str_to_num(playerxp); PlayerLevel[id] = str_to_num(playerlevel); SkillPoints[id] = str_to_num(SkillPointsx); pointshp[id] = str_to_num(pointshpx); pointsgranat[id] = str_to_num(pointsgranatx); 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 :)"); 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)); } } public weapon_granaty(id) { new los = random_num(1, 100); if(los <= 50 * pointsgranat[id]) { if (get_user_team(id) == 1) // 1 - terro { give_item(id, "weapon_smokegrenade"); give_item(id, "weapon_hegrenade"); give_item(id, "weapon_flashbang"); give_item(id, "weapon_flashbang"); ColorChat(id, GREEN, "[%d '/.]^x01 Dostales Zestaw Granatow!", 50 * pointsgranat[id]); } else { //give_item(id, "weapon_smokegrenade"); give_item(id, "weapon_hegrenade"); //give_item(id, "weapon_flashbang"); //give_item(id, "weapon_flashbang"); ColorChat(id, GREEN, "[%d '/.]^x01 Dostales Granata Wybuchowego!", 50 * pointsgranat[id]); } } else {// 56 procent ze nic nie wypadnie //ColorChat(id, GREEN, "[xmS? XpMOD]^x01 Pech.. nic nie wylosowales."); } }