HP za zabicie
Best Answer Przemekb88 26.12.2013 21:09
Teraz śmiga pięknie. + poleciał. Dziękuję - temat do zamknięcia.
Go to the full post
Przemekb88
25.12.2013
Mam problem, gdyż chciałem aby plugin to zabiciu hs'em dawał graczowi 20hp a po normalnym zabiciu 15hp. Limit dla zwykłego użytkownika miał być 100hp a dla vip'a (z flagą t) 150hp. Plugin działa, a konkretnie problem tkwi w tym, iż limit dla każdego gracza bez względu na to czy jest vip'em czy nie limit hp wynosi 150.
Attached Files
Edited by Przemekb88, 25.12.2013 11:53.
0-0-0
25.12.2013
Sprawdź
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #define PLUGIN "Vampire" #define AUTHOR "Przemekb88" #define VERSION "1.0" #define LIMIT 100 #define LIMIT 150 public plugin_init() { register_plugin("HP za Zabicie", VERSION, "Przemekb88"); register_event("DeathMsg", "DeathMsg", "a") } public DeathMsg(id) { new kid = read_data(1) //zabojca new vid = read_data(2); new hs = read_data(3) // HeadShot (1 == true) if(!(get_user_flags(id) & ADMIN_LEVEL_H)) { if(is_user_alive(kid) && is_user_connected(vid) && get_user_team(kid) != get_user_team(vid)) { new health = get_user_health(kid), dodaj = hs ? 20 : 15; set_user_health(id,min(get_user_health(id)+dodaj,LIMIT)); if(hs == 1) { set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+20hp") } else if(hs != 1) { set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+15hp") } return PLUGIN_CONTINUE; } } else if((get_user_flags(id) & ADMIN_LEVEL_H)) { if(is_user_alive(kid) && is_user_connected(vid) && get_user_team(kid) != get_user_team(vid)) { new health = get_user_health(kid), dodaj = hs ? 20 : 15; set_user_health(id,min(get_user_health(id)+dodaj,LIMIT2)); if(hs == 1) { set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+20hp") } else if(hs != 1) { set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+15hp") } return PLUGIN_CONTINUE; } } return PLUGIN_HANDLED }
Przemekb88
25.12.2013
Następnym razem proszę o stosowanie tabulatorów. To rozwiązanie co mi podałeś Zerko to miało ono błąd - zawierało 2 razy zdefiniowany LIMIT, ale nawet po wyeliminowaniu errorów i warningów (z wykorzystaniem tego co mi podałeś) problem dalej się pojawia, i to większy, gdyż w takiej sytuacji plugin wcale nie chce działać.
Przemekb88
25.12.2013
vaulT - to co mi podałeś przynajmniej nie ma żadnych błędów (nie pokazuje żadnych ani w konsoli, ani w kompilatorze), ale problem dalej się pojawia - ludzie bez vip'a dalej mają max 150 hp, a nawet więcej.
Edited by Przemekb88, 25.12.2013 13:42.
0-0-0
25.12.2013
To co jest podane będzię złe ponieważ gracz mający powiedzmy 149 hp i zabije on z HS i doda mu 20 to będzie miał 169 hp i wtedy mu zaprzestanie dodawać. Trzeba sprawdzić czy gracz posiada hp + 20 wieksze od 150.
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #define PLUGIN "---" #define AUTHOR "----" #define VERSION "1.0" public plugin_init() { register_plugin("HP za Zabicie", VERSION, "Przemekb88"); register_event("DeathMsg", "DeathMsg", "a") } public DeathMsg(id) { new kid = read_data(1) //zabojca new vid = read_data(2); new hs = read_data(3) // HeadShot (1 == true) if(!(get_user_flags(kid) & ADMIN_LEVEL_H)) { if(is_user_alive(kid) && is_user_connected(vid) && get_user_team(kid) != get_user_team(vid)) { if(hs == 1) { set_user_health(kid,get_user_health(kid) + 20); if(get_user_health(kid) + 20> 100) set_user_health(kid,100); set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+20hp") } else if(hs != 1) { set_user_health(kid,get_user_health(kid) + 15); if(get_user_health(kid) +15 > 100) set_user_health(kid,100); set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+15hp") } return PLUGIN_CONTINUE; } } else if(get_user_flags(kid) & ADMIN_LEVEL_H) { if(is_user_alive(kid) && is_user_connected(vid) && get_user_team(kid) != get_user_team(vid)) { if(hs == 1) { set_user_health(kid,get_user_health(kid) + 20); if(get_user_health(kid) + 20 > 150) set_user_health(kid,150); set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+20hp") } else if(hs != 1) { set_user_health(kid,get_user_health(kid) + 15); if(get_user_health(kid) + 15 > 150) set_user_health(kid,150); set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+15hp") } return PLUGIN_CONTINUE; } } return PLUGIN_HANDLED }
GwynBleidD
26.12.2013
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #define PLUGIN "Vampire" #define AUTHOR "GwynBleidD" #define VERSION "1.2" #define MAX_HP 100 #define MAX_HP_VIP 150 #define VIP_FLAG ADMIN_LEVEL_H public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); register_event("DeathMsg", "DeathMsg", "a") } public DeathMsg(id) { new kid = read_data(1) //zabojca new vid = read_data(2); if(!is_user_alive(kid) || get_user_team(kid) == get_user_team(vid)) return PLUGIN_CONTINUE; new hs = read_data(3) // HeadShot (1 == true) new hp = get_user_health(kid) new is_vip = get_user_flags(kid) & ADMIN_LEVEL_H if(hp<MAX_HP || (is_vip && hp<MAX_HP_VIP)) { new new_hp = min( hp + (hs ? 20 : 15), is_vip ? MAX_HP_VIP : MAX_HP ) set_user_health(kid, new_hp) set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0) show_hudmessage(kid, "+%dhp", new_hp-hp) } return PLUGIN_CONTINUE }
Przemekb88
26.12.2013
@GwynBleidD jak już piszesz plugin komuś w odpowiedzi to sprawdź czy nie ma on błędów. W 36 linijce brakuje nawiasu zamykającego instrukcję warunkową if, a po nawiasie zamykającym w 44 linijce brakuje "return PLUGIN_HANDLED;". Po naprawieniu tych błędów, skompilowaniu pluginu i wstawieniu go na serwer dostrzegłem, że zamiast dostawać po 20 hp za hs a 15hp za zwykłe zabicie to dostawałem po np 119hp i w dodatku nie było limitu hp. Następnych chcących mi pomóc proszę o sprawdzenie pluginu najpierw w kompilatorze, a dopiero wstawianie go tutaj.
Edited by Przemekb88, 26.12.2013 12:17.
GwynBleidD
26.12.2013
I nie PLUGIN_HANDLED, ale PLUGIN_CONTINUE, bo nie chcemy wstrzymywać eventu dla innych pluginów, a po prostu informujemy że skończyliśmy już pracę nad danym eventem. Zresztą nie jest to błąd, jedynie mały warning, nic nie znaczący w tym przypadku wyskakuje.
Best Answer
Przemekb88
26.12.2013
Teraz śmiga pięknie. + poleciał. Dziękuję - temat do zamknięcia.