Witam.
Staram się zrobić plugin blokujący shotguny, jeśli graczy spodnie poniżej wartości określonej cvarem.
Plugin sprawdza co rundę na jej początku ilość graczy (nie licząc spektatorów) i jeśli jest niższa niż wymagana to:
- nie można kupić shotguna
- jeśli gracz zachował shotguna z poprzedniej rundy to go traci
- jeśli na ziemi leży shotgun, to nie można go podnieść
Mam problem, aby zrobić by plugin odpowiednio blokował lub nie robił nic. Prawdopodobnie żle zwracam wartości returnami, ale właściwie to się na tym, nie znam i prosiłbym o edukacyjny temat, link lub własne wyjaśnienie :F
O to mój kod:
#include <amxmodx> #include <amxmisc> #include <StripWeapons> #include <hamsandwich> #include <fun> #include <cstrike> #define PLUGIN "Shotguns Limited" #define VERSION "0.1" #define AUTHOR "$OLDIER" #define IsPlayer(%1) (1<=%1<=maxPlayers) new pys_num, enabled, Players[32], Num, maxPlayers, rounds=0; //new Nums, Num2; //new Players2[32]; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_event("HLTV", "round_start", "a", "1=0", "2=0") register_cvar("shotgunsblock_enabled", "1") register_cvar("shotguns_players", "8") register_logevent("round_end", 2, "1=Round_End") register_event("TextMsg","restart_roundsnum","a","2&#Game_C"/*,"2&#Game_w"*/) register_clcmd("m3","block"); register_clcmd("xm1014","block"); RegisterHam( Ham_Touch, "weaponbox", "HamTouchPre", 0 ) pys_num = get_cvar_num("shotguns_players") enabled = get_cvar_num("shotgunsblock_enabled") } public plugin_cfg() { maxPlayers=get_maxplayers(); } public round_start() { get_players(Players, Num, "a"); client_print(0, print_chat, "%d", Num) // tutaj sobie dodałem w celu sprawdzenia jak liczy graczy if(enabled == 1 && rounds != 0) { if (Num<pys_num) { for(new i=0; i < Num; i++) { new id=Players[i]; if(user_has_weapon(id, CSW_M3) || user_has_weapon(id, CSW_XM1014)) { StripWeapons(id, Primary); client_print(id, print_chat, "Nie mozesz posiadac Shotguna, kiedy respi sie jedna matka Zombie"); } } } } return true } public round_end() { rounds++; } public restart_roundsnum() { rounds = 0; } public block(id) { if(enabled == 1 && rounds !=0) { if (Num<pys_num) { client_print(id, print_chat, "Nie mozesz kupic tej broni, gdy respi sie tylko jedna matka Zombie"); return PLUGIN_CONTINUE } } return PLUGIN_HANDLED } public HamTouchPre( weapon, id ) { if(enabled == 1 && rounds !=0) { if (Num<pys_num) { if(!pev_valid(weapon) || !IsPlayer(id) || !is_user_alive(id)) { return HAM_IGNORED; } new name[20]; pev(weapon, pev_model, name, 19); if(containi(name, "w_m3")!=-1) { client_print(id, print_chat, "Nie mozesz posiadac Shotguna, kiedy respi sie jedna matka Zombie"); return HAM_SUPERCEDE; } new name2[20]; pev(weapon, pev_model, name2, 19); if(containi(name, "w_xm1014")!=-1) { client_print(id, print_chat, "Nie mozesz posiadac Shotguna, kiedy respi sie jedna matka Zombie"); return HAM_SUPERCEDE; } } } return PLUGIN_CONTINUE }