Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

esticire - zdjęcie

esticire

Rejestracja: 17.01.2025
Aktualnie: Nieaktywny
Poza forum Ostatnio: 16.05.2025 22:30
-----

Moje tematy

Problem z połączeniem VIP + Free vip

29.04.2025 21:17

Cześć, Mam problem z połączeniem tego kodu wraz z osobnym pluginem freevip w nocy z tego tematu https://amxx.pl/topi...owy-vip-w-nocy/

Mianowicie Plugin raz przyznaje tego vipa po zmianie mapy raz nie przyznaje. Czasami wystarczy zrobić reconnect czasami nawet i to nie pomaga.

Próbowałem bawić się z timerami w client_authorized oraz w client_putinserver ale nic to nie daje. 
Czy jesteście w stanie mi powiedzieć co pominąłem albo po prostu co zmienić w kodzie? 
Męczę się z tym 3 dzień ale z racji na małą ilość czasu obecnie nie jestem w stanie za bardzo się w to zagłębić. 

Oczywiście jest to vip z generatora + pare zmian prze ze mnie wprowadzonych (pewnie lipa i dziury ale mi działa :P )

#include <amxmodx>
#include <cstrike>
#include <csx>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <stripweapons>

new bool:g_Vip[33], gRound=0, g_Hudmsg, maxPlayers,
menu, weapon_id;
new bool:g_GameStarted;
new menu_id[33];

#define TASK_CLOSE_MENU 10000

new p_awp_limit_0_5, p_awp_limit_6_10, p_awp_limit_11_16, p_awp_limit_17_23, p_awp_limit_24_inf;

public plugin_init(){
    register_plugin("VIP Ultimate", "12.3.0.3", "benio101 & speedkill");
    RegisterHam(Ham_Spawn, "player", "SpawnedEventPre", 1);
    register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
    register_logevent("GameCommencing", 2, "1=Game_Commencing");
    register_event("DeathMsg", "DeathMsg", "a");
    register_message(get_user_msgid("ScoreAttrib"), "VipStatus");
    register_message(get_user_msgid("SayText"),"handleSayText");
    register_clcmd("say /vip", "show_vip_motd");
    register_clcmd("say_team /vip", "show_vip_motd");
    g_Hudmsg=CreateHudSyncObj();
    register_logevent("RoundEnd", 2, "1=Round_End");
    register_logevent("event_round_start", 2, "1=Round_Start");
    p_awp_limit_0_5    = register_cvar("awp_limit_0_5", "0");
    p_awp_limit_6_10   = register_cvar("awp_limit_6_10", "5");
    p_awp_limit_11_16  = register_cvar("awp_limit_11_16", "5");
    p_awp_limit_17_23  = register_cvar("awp_limit_17_23", "5");
    p_awp_limit_24_inf = register_cvar("awp_limit_24_inf", "5");
}

public client_authorized(id){
    if(get_user_flags(id) & 524288 == 524288){
        client_authorized_vip(id);
    }
}

public plugin_cfg(){
    maxPlayers = get_maxplayers();
}

public client_connect(id) {
    g_Vip[id] = false;
}

public show_vip_motd(id) {
    show_motd(id, "vip.html", "Informacje o VIP");
}

public check_vip_flag(id){
    if (get_user_flags(id) & ADMIN_LEVEL_H){
        client_authorized_vip(id);
    }
}

public client_putinserver(id){
    set_task(1.0, "check_vip_flag", id);
}

public client_authorized_vip(id) {
    if(is_user_connected(id) && g_Vip[id]) {
        new g_Name[64];
        get_user_name(id, g_Name, charsmax(g_Name));
        set_hudmessage(24, 190, 220, 0.25, 0.2, 0, 6.0, 6.0);
        ShowSyncHudMsg(0, g_Hudmsg, "V.I.P %s wbija na serwer!", g_Name);
        if(is_user_alive(id)) {
            SpawnedEventPreVip(id);
        }
    }
}

public client_disconnected(id) {
    if(g_Vip[id]) {
        g_Vip[id] = false;
    }
    remove_task(id + TASK_CLOSE_MENU);
    remove_task(id);
    if(menu_id[id]) {
        menu_destroy(menu_id[id]);
        menu_id[id] = 0;
    }
}

public client_disconnect_vip(id){
    g_Vip[id] = false;
}
public SpawnedEventPre(id){
    if(g_Vip[id] && is_user_alive(id)){
        SpawnedEventPreVip(id);
    }
}
public SpawnedEventPreVip(id){
    cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM);
    give_item(id, "weapon_hegrenade");
    cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
    give_item(id, "weapon_flashbang");
    StripWeapons(id, Secondary);
    give_item(id, "weapon_deagle");
    give_item(id, "ammo_50ae");
    weapon_id = find_ent_by_owner(-1, "weapon_deagle", id);
    if (weapon_id) cs_set_weapon_ammo(weapon_id, 7);
    cs_set_user_bpammo(id, CSW_DEAGLE, 35);
    set_task(0.1, "show_vip_menu_delayed", id);
    if (gRound >= 3){
        give_item(id, "weapon_smokegrenade");
    }
    if (get_user_team(id) == 2){
        give_item(id, "item_thighpack");
    }
}

public show_vip_menu_delayed(id) {
    if (is_user_alive(id)) {
        show_vip_menu(id);
    }
}

public event_new_round(){
    ++gRound;
}
public GameCommencing(){
    gRound = 0;
    g_GameStarted = false;
}
public event_round_start(){
    if (!g_GameStarted) {
        g_GameStarted = true;
        gRound = 1;
    } else {
        gRound++;
    }
}

public DeathMsg(){
    new killer = read_data(1);
    new victim = read_data(2);
    if(is_user_alive(killer) && g_Vip[killer] && get_user_team(killer) != get_user_team(victim)){
        DeathMsgVip(killer, victim, read_data(3));
    }
}
public DeathMsgVip(kid, vid, hs){
    set_user_health(kid, min(get_user_health(kid) + (hs ? 10 : 5), 100));
    cs_set_user_money(kid, cs_get_user_money(kid) + (hs ? 500 : 300));
}

public RoundEnd(){
    for(new i = 1; i <= maxPlayers; i++){
        if(is_user_alive(i) && g_Vip[i]){
            cs_set_user_money(i, cs_get_user_money(i) + 500);
        }
    }
}

public show_vip_menu(id) {
    if (!is_user_alive(id)) return;
    if (gRound < 3) return;
    if (!menu_id[id]) {
        set_task(20.0, "force_close_menu", id + TASK_CLOSE_MENU);
    }
    else {
        return;
    }

    menu = menu_create("\rMenu VIPa", "menu_handler");
    menu_additem(menu, "\wAK47 + DEAGLE");
    menu_additem(menu, "\wM4A1 + DEAGLE");
    menu_additem(menu, "\d(\w2000\y$\d) \wAWP + DEAGLE");
    menu_additem(menu, "\d(\w2000\y$\d) \wKROWA + DEAGLE");
    menu_additem(menu, "\wFAMAS + DEAGLE");
    menu_additem(menu, "\wSCOUT + DEAGLE");
    menu_setprop(menu, MPROP_EXITNAME, "Wyjscie");
    menu_setprop(menu, MPROP_TITLE, "\r[\yMENU broni V.I.P'a\r]^n\r[\y20 sekund na wybor\r]^n\r[\yNasze forum: \r]");
    menu_id[id] = menu;
    menu_display(id, menu);
}

public force_close_menu(taskid) {
    new id = taskid - TASK_CLOSE_MENU;
    if (is_user_connected(id)) {
        show_menu(id, 0, "^n", 1);
        client_print(id, print_center, "Czas na wybor minal! Menu zostało zamkniete.");
        if (menu_id[id]) {
            menu_destroy(menu_id[id]);
            menu_id[id] = 0;
        }
    }
}

public menu_handler(id, menu, item) {
    if (!is_user_alive(id) || item == MENU_EXIT) {
        close_vip_menu(id);
        return PLUGIN_HANDLED;
    }
    if (gRound < 3) {
        client_print(id, print_center, "Menu VIP dostępne od 3 rundy!");
        close_vip_menu(id);
        return PLUGIN_HANDLED;
    }
    switch (item) {
        case 0: {
            menu_1_handler(id);
            close_vip_menu(id);
        }
        case 1: {
            menu_2_handler(id);
            close_vip_menu(id);
        }
        case 2: {
            new money = cs_get_user_money(id);
            if (money < 2000) {
                client_print(id, print_center, "Nie masz 2000$ na AWP!");
                menu_display(id, menu_id[id]);
            } 
            else if (!canBuyAWP(id)) {
                client_print(id, print_center, "Limit AWP w druzynie zostal osiagniety!");
                menu_display(id, menu_id[id]);
            } 
            else {
                menu_3_handler(id);
                cs_set_user_money(id, money - 2000, 1);
                close_vip_menu(id);
            }
        }
        case 3: {
            new money = cs_get_user_money(id);
            if (money < 2000) {
                client_print(id, print_center, "Nie masz 2000$ na KROWE!");
                menu_display(id, menu_id[id]);
            } 
            else {
                menu_4_handler(id);
                cs_set_user_money(id, money - 2000, 1);
                close_vip_menu(id);
            }
        }
        case 4: {
            menu_5_handler(id);
            close_vip_menu(id);
        }
        case 5: {
            menu_6_handler(id);
            close_vip_menu(id);
        }
    }
    return PLUGIN_HANDLED;
}

public close_vip_menu(id) {
    if (menu_id[id]) {
        show_menu(id, 0, "^n", 1);
        menu_destroy(menu_id[id]);
        menu_id[id] = 0;
        remove_task(id + TASK_CLOSE_MENU);
    }
}

public menu_2_handler(id){
    StripWeapons(id, Primary);
    give_item(id, "weapon_m4a1");
    give_item(id, "ammo_556nato");
    set_weapon_ammo(id, "weapon_m4a1", 30, CSW_M4A1, 90);
}
public menu_1_handler(id){
    StripWeapons(id, Primary);
    give_item(id, "weapon_ak47");
    give_item(id, "ammo_762nato");
    set_weapon_ammo(id, "weapon_ak47", 30, CSW_AK47, 90);
}
public menu_3_handler(id){
    StripWeapons(id, Primary);
    give_item(id, "weapon_awp");
    give_item(id, "ammo_338magnum");
    set_weapon_ammo(id, "weapon_awp", 10, CSW_AWP, 30);
}
public menu_5_handler(id){
    StripWeapons(id, Primary);
    give_item(id, "weapon_famas");
    give_item(id, "ammo_556nato");
    set_weapon_ammo(id, "weapon_famas", 25, CSW_FAMAS, 90);
}
public menu_4_handler(id){
    StripWeapons(id, Primary);
    give_item(id, "weapon_m249");
    give_item(id, "ammo_556natobox");
    set_weapon_ammo(id, "weapon_m249", 100, CSW_M249, 200);
}
public menu_6_handler(id){
    StripWeapons(id, Primary);
    give_item(id, "weapon_scout");
    give_item(id, "ammo_762nato");
    set_weapon_ammo(id, "weapon_scout", 10, CSW_SCOUT, 90);
}

stock set_weapon_ammo(id, const weapon[], clip, csw, bpammo){
    weapon_id = find_ent_by_owner(-1, weapon, id);
    if(weapon_id) cs_set_weapon_ammo(weapon_id, clip);
    cs_set_user_bpammo(id, csw, bpammo);
}

public bool:canBuyAWP(const id){
    new players[32], num;
    get_players(players, num, "a");
    new team = get_user_team(id);
    new awpCount = 0;
    for(new i = 0; i < num; i++){
        new pid = players[i];
        if(get_user_team(pid) == team && user_has_weapon(pid, CSW_AWP)){
            awpCount++;
        }
    }
    new limit = getDynamicAWPLimit();
    return (awpCount < limit);
}
public getDynamicAWPLimit(){
    new players[32], num;
    get_players(players, num, "h");
    if(num <= 5)
        return get_pcvar_num(p_awp_limit_0_5);
    else if(num <= 10)
        return get_pcvar_num(p_awp_limit_6_10);
    else if(num <= 16)
        return get_pcvar_num(p_awp_limit_11_16);
    else if(num <= 23)
        return get_pcvar_num(p_awp_limit_17_23);
    else if(num > 23)
        return get_pcvar_num(p_awp_limit_24_inf);
    return 0;
}

public VipStatus(){
    new id = get_msg_arg_int(1);
    if(is_user_alive(id) && g_Vip[id]){
        set_msg_arg_int(2, ARG_BYTE, get_msg_arg_int(2) | 4);
    }
}
public bomb_planted(id){
    if(is_user_alive(id) && g_Vip[id]){
        cs_set_user_money(id, cs_get_user_money(id) + 250);
    }
}
public bomb_defused(id){
    if(is_user_alive(id) && g_Vip[id]){
        cs_set_user_money(id, cs_get_user_money(id) + 250);
    }
}

public handleSayText(msgId,msgDest,msgEnt){
    new id = get_msg_arg_int(1);
    if(is_user_connected(id) && g_Vip[id]){
        new szTmp[256],szTmp2[256];
        get_msg_arg_string(2,szTmp, charsmax(szTmp))
        new szPrefix[64] = "^x04[V.I.P]";
        if(!equal(szTmp,"#Cstrike_Chat_All")){
            add(szTmp2,charsmax(szTmp2),szPrefix);
            add(szTmp2,charsmax(szTmp2)," ");
            add(szTmp2,charsmax(szTmp2),szTmp);
        }
        else{
            add(szTmp2,charsmax(szTmp2),szPrefix);
            add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01 :  %s2");
        }
        set_msg_arg_string(2,szTmp2);
    }
    return PLUGIN_CONTINUE;
}

[ROZWIĄZANE] Vip plugin okno menu timer

28.04.2025 12:35

Cześć wszystkim, 

Ostatnio stworzyłem plugin VIP poprzez generator i przerabiam go na własne potrzeby. Mam problem jeszcze z zamykaniem się menu po 20s.
Ustawiłem

set_task(20.0, "zamknij_menu", id + TASK_CLOSE_MENU);

Gdzie trzeba ale menu się nie zamyka... Gdy kliknę "AWP" i menu otworzy się ponownie, bo "nie ma środków" albo limit awp jest przekroczony to od tego momentu menu po 20 sekundach automatycznie się zamknie. 
Gdzie popełniam błąd? Jak to powinno wyglądać aby faktycznie za każdym razem menu zamykało się po 20 sekundach? 

#include <amxmodx>
#include <cstrike>
#include <csx>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <stripweapons>

new bool:g_Vip[33], gRound=0, g_Hudmsg, maxPlayers,
menu, menu_callback_handler, weapon_id;
new bool:g_GameStarted;
new menu_id[33];

#define TASK_CLOSE_MENU 1000

new p_awp_limit_0_5, p_awp_limit_6_10, p_awp_limit_11_16, p_awp_limit_17_23, p_awp_limit_24_inf;

public plugin_init(){
register_plugin("VIP Ultimate", "12.3.0.3", "benio101 & speedkill");
RegisterHam(Ham_Spawn, "player", "SpawnedEventPre", 1);
register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
register_logevent("GameCommencing", 2, "1=Game_Commencing");
register_event("DeathMsg", "DeathMsg", "a");
register_message(get_user_msgid("ScoreAttrib"), "VipStatus");
register_message(get_user_msgid("SayText"),"handleSayText");
g_Hudmsg=CreateHudSyncObj();
register_logevent("RoundEnd", 2, "1=Round_End");
register_logevent("event_round_start", 2, "1=Round_Start");

p_awp_limit_0_5 = register_cvar("awp_limit_0_5", "0");
p_awp_limit_6_10 = register_cvar("awp_limit_6_10", "5");
p_awp_limit_11_16 = register_cvar("awp_limit_11_16", "5");
p_awp_limit_17_23 = register_cvar("awp_limit_17_23", "5");
p_awp_limit_24_inf = register_cvar("awp_limit_24_inf", "5");
}

public plugin_cfg(){
maxPlayers = get_maxplayers();
}

public client_putinserver(id){
set_task(1.0, "check_vip_flag", id);
}

public check_vip_flag(id){
if (get_user_flags(id) & ADMIN_LEVEL_H){
client_authorized_vip(id);
}
}

public client_authorized_vip(id){
g_Vip[id]=true;
new g_Name[64];
get_user_name(id,g_Name,charsmax(g_Name));
set_hudmessage(24, 190, 220, 0.25, 0.2, 0, 6.0, 6.0);
ShowSyncHudMsg(0, g_Hudmsg, "V.I.P %s wbija na serwer!", g_Name);
}
public client_disconnected(id) {
if(g_Vip[id]) {
client_disconnect_vip(id);
}
remove_task(id + TASK_CLOSE_MENU);
if(menu_id[id]) {
menu_destroy(menu_id[id]);
menu_id[id] = 0;
}
}

public client_disconnect_vip(id){
g_Vip[id]=false;
}
public SpawnedEventPre(id){
if(g_Vip[id] && is_user_alive(id)){
SpawnedEventPreVip(id);
}
}
public SpawnedEventPreVip(id){
cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM);

give_item(id, "weapon_hegrenade");
cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
give_item(id, "weapon_flashbang");

StripWeapons(id, Secondary);
give_item(id, "weapon_deagle");
give_item(id, "ammo_50ae");

weapon_id = find_ent_by_owner(-1, "weapon_deagle", id);
if (weapon_id) cs_set_weapon_ammo(weapon_id, 7);
cs_set_user_bpammo(id, CSW_DEAGLE, 35);

show_vip_menu(id);

if (gRound >= 3){
give_item(id, "weapon_smokegrenade");
}

if (get_user_team(id) == 2){
give_item(id, "item_thighpack");
}
}

public event_new_round(){
++gRound;
}
public GameCommencing(){
gRound = 0;
g_GameStarted = false;
}
public event_round_start(){
if (!g_GameStarted) {
g_GameStarted = true;
gRound = 1;
} else {
gRound++;
}
}

public DeathMsg(){
new killer = read_data(1);
new victim = read_data(2);

if(is_user_alive(killer) && g_Vip[killer] && get_user_team(killer) != get_user_team(victim)){
DeathMsgVip(killer, victim, read_data(3));
}
}
public DeathMsgVip(kid, vid, hs){
set_user_health(kid, min(get_user_health(kid) + (hs ? 10 : 5), 100));
cs_set_user_money(kid, cs_get_user_money(kid) + (hs ? 500 : 300));
}

public RoundEnd(){
for(new i = 1; i <= maxPlayers; i++){
if(is_user_alive(i) && g_Vip[i]){
cs_set_user_money(i, cs_get_user_money(i) + 500);
}
}
}

public show_vip_menu(id){
if (!is_user_alive(id)) return;

if (gRound < 3) return;

set_task(20.0, "zamknij_menu", id + TASK_CLOSE_MENU);

menu = menu_create("\rMenu VIPa", "menu_handler");
menu_callback_handler = menu_makecallback("menu_callback");
new bool:active = false, num = -1;

menu_additem(menu, "\wAK47 + DEAGLE", "", 0, menu_callback_handler);
if (menu_callback(id, menu, ++num) == ITEM_ENABLED) active = true;

menu_additem(menu, "\wM4A1 + DEAGLE", "", 0, menu_callback_handler);
if (menu_callback(id, menu, ++num) == ITEM_ENABLED) active = true;

menu_additem(menu, "\d(\w2000\y$\d) \wAWP + DEAGLE", "", 0, menu_callback_handler);
if (menu_callback(id, menu, ++num) == ITEM_ENABLED) active = true;

menu_additem(menu, "\d(\w2000\y$\d) \wKROWA + DEAGLE", "", 0, menu_callback_handler);
if (menu_callback(id, menu, ++num) == ITEM_ENABLED) active = true;

menu_additem(menu, "\wFAMAS + DEAGLE", "", 0, menu_callback_handler);
if (menu_callback(id, menu, ++num) == ITEM_ENABLED) active = true;

menu_additem(menu, "\wSCOUT + DEAGLE", "", 0, menu_callback_handler);
if (menu_callback(id, menu, ++num) == ITEM_ENABLED) active = true;

if (active) {
menu_setprop(menu, MPROP_EXITNAME, "Wyjście");
menu_setprop(menu, MPROP_TITLE, "\r[\yMENU broni V.I.P'a\r]^n\r[\y20 sekund na wybór\r]^n\r[\yNasze forum: \r]");
menu_setprop(menu, MPROP_NUMBER_COLOR, "\r");
menu_display(id, menu);
menu_id[id] = menu;
} else {
menu_destroy(menu);
}
}

public menu_callback(id, menu, item){
return ITEM_ENABLED;
}

public menu_handler(id, menu, item) {
remove_task(id + TASK_CLOSE_MENU);

if (!is_user_alive(id) || item == MENU_EXIT) {
if (menu_id[id]) {
menu_destroy(menu_id[id]);
menu_id[id] = 0;
}
return PLUGIN_HANDLED;
}

if (gRound >= 3) {
switch (item) {
case 0: menu_1_handler(id);
case 1: menu_2_handler(id);
case 2: {
new money = cs_get_user_money(id);
if (money < 2000) {
client_print(id, print_center, "Nie masz 2000$ na AWP!");
show_vip_menu(id);
return PLUGIN_HANDLED;
}
if (!canBuyAWP(id)) {
client_print(id, print_center, "Limit AWP w druzynie zostal osiagniety!");
show_vip_menu(id);
return PLUGIN_HANDLED;
}
menu_3_handler(id);
cs_set_user_money(id, money - 2000, 1);
}
case 3: {
new money = cs_get_user_money(id);
if (money < 2000) {
client_print(id, print_center, "Nie masz 2000$ na KROWE!");
show_vip_menu(id);
return PLUGIN_HANDLED;
}
menu_4_handler(id);
cs_set_user_money(id, money - 2000, 1);
}
case 4: menu_5_handler(id);
case 5: menu_6_handler(id);
}
}

if (menu_id[id]) {
menu_destroy(menu_id[id]);
menu_id[id] = 0;
}
set_task(20.0, "zamknij_menu", id + TASK_CLOSE_MENU);
return PLUGIN_HANDLED;
}

public zamknij_menu(taskid) {
new id = taskid - TASK_CLOSE_MENU;

if (!is_user_connected(id))
return;

if (menu_id[id]) {
show_menu(id, 0, "^n", 1);

menu_destroy(menu_id[id]);
menu_id[id] = 0;

client_print(id, print_center, "Menu VIP wygasło po 20 sekundach!");
}
}

public menu_2_handler(id){
StripWeapons(id, Primary);
give_item(id, "weapon_m4a1");
give_item(id, "ammo_556nato");
set_weapon_ammo(id, "weapon_m4a1", 30, CSW_M4A1, 90);
}
public menu_1_handler(id){ 
StripWeapons(id, Primary);
give_item(id, "weapon_ak47");
give_item(id, "ammo_762nato");
set_weapon_ammo(id, "weapon_ak47", 30, CSW_AK47, 90);
}
public menu_3_handler(id){ 
StripWeapons(id, Primary);
give_item(id, "weapon_awp");
give_item(id, "ammo_338magnum");
set_weapon_ammo(id, "weapon_awp", 10, CSW_AWP, 30);
}
public menu_5_handler(id){ 
StripWeapons(id, Primary);
give_item(id, "weapon_famas");
give_item(id, "ammo_556nato");
set_weapon_ammo(id, "weapon_famas", 25, CSW_FAMAS, 90);
}
public menu_4_handler(id){
StripWeapons(id, Primary);
give_item(id, "weapon_m249");
give_item(id, "ammo_556natobox");
set_weapon_ammo(id, "weapon_m249", 100, CSW_M249, 200);
}
public menu_6_handler(id){ 
StripWeapons(id, Primary);
give_item(id, "weapon_scout");
give_item(id, "ammo_762nato");
set_weapon_ammo(id, "weapon_scout", 10, CSW_SCOUT, 90);
}

stock set_weapon_ammo(id, const weapon[], clip, csw, bpammo){
weapon_id = find_ent_by_owner(-1, weapon, id);
if(weapon_id) cs_set_weapon_ammo(weapon_id, clip);
cs_set_user_bpammo(id, csw, bpammo);
}

public bool:canBuyAWP(const id){
new players[32], num;
get_players(players, num, "a");

new team = get_user_team(id);
new awpCount = 0;

for(new i = 0; i < num; i++){
new pid = players[i];
if(get_user_team(pid) == team && user_has_weapon(pid, CSW_AWP)){
awpCount++;
}
}

new limit = getDynamicAWPLimit();
return (awpCount < limit);
}
public getDynamicAWPLimit(){
new players[32], num;
get_players(players, num, "h");

if(num <= 5)
return get_pcvar_num(p_awp_limit_0_5);
else if(num <= 10)
return get_pcvar_num(p_awp_limit_6_10);
else if(num <= 16)
return get_pcvar_num(p_awp_limit_11_16);
else if(num <= 23)
return get_pcvar_num(p_awp_limit_17_23);
else if(num > 23)
return get_pcvar_num(p_awp_limit_24_inf);

return 0;
}

public VipStatus(){
new id = get_msg_arg_int(1);
if(is_user_alive(id) && g_Vip[id]){
set_msg_arg_int(2, ARG_BYTE, get_msg_arg_int(2) | 4);
}
}
public bomb_planted(id){
if(is_user_alive(id) && g_Vip[id]){
cs_set_user_money(id, cs_get_user_money(id) + 250);
}
}
public bomb_defused(id){
if(is_user_alive(id) && g_Vip[id]){
cs_set_user_money(id, cs_get_user_money(id) + 250);
}
}

public handleSayText(msgId,msgDest,msgEnt){
new id = get_msg_arg_int(1);

if(is_user_connected(id) && g_Vip[id]){
new szTmp[256],szTmp2[256];
get_msg_arg_string(2,szTmp, charsmax(szTmp))

new szPrefix[64] = "^x04[V.I.P]";

if(!equal(szTmp,"#Cstrike_Chat_All")){
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2)," ");
add(szTmp2,charsmax(szTmp2),szTmp);
}
else{
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01 : %s2");
}
set_msg_arg_string(2,szTmp2);
}
return PLUGIN_CONTINUE;
}

Plugin na cheaterów

17.01.2025 23:05

 

Cześć, Ostatnio myślałem o próbie napisania pluginu który zamraża gracza oraz nie pozwala mu strzelać, co się udało.
Chciałem go rozbudować o zapisywanie SID do pliku TXT i blokowanie każdego gracza z danym SID który jest obecnie na serwerze.
Niestety nie mogę przeprowadzić tego pluginu przez proces kompilacji i nie rozumiem dlaczego, czy możecie mi  w tym pomóc?
Załączam plugin który zatrzymuje (podstawke) i w cytacie to co rozbudowałem.
 

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>

#define PLUGIN "AMX Stay"
#define VERSION "1.0"
#define AUTHOR "mT[1]g"

new bool:g_bStayBlocked[33];
new Float:g_fMaxSpeed[33];
new String:g_szBlockedSIDs[100][32];
new g_iBlockedCount = 0;

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_concmd("amx_stay", "cmd_amx_stay", ADMIN_BAN, "<nick/steamid> - Zatrzymaj/odblokuj gracza");
    register_concmd("amx_stay_remove", "cmd_amx_stay_remove", ADMIN_BAN, "<SID> - Usuń SID z blokady");
    RegisterHam(Ham_Spawn, "player", "client_spawn", 1);
    register_forward(FM_CmdStart, "on_cmd_start", 1);
    LoadBlockedSIDs();
}

LoadBlockedSIDs() {
    new file[64];
    formatex(file, sizeof(file), "blocked_sids.txt");
    new handle = fopen(file, "r");
    if (handle) {
        while (!feof(handle)) {
            new line[32];
            fgets(line, sizeof(line), handle);
            if (line[0] != '\0') {
                trim(line);
                formatex(g_szBlockedSIDs[g_iBlockedCount], sizeof(g_szBlockedSIDs[g_iBlockedCount]), "%s", line);
                g_iBlockedCount++;
            }
        }
        fclose(handle);
    }
}

SaveBlockedSID(szSID[]) {
    new file[64];
    formatex(file, sizeof(file), "blocked_sids.txt");
    new handle = fopen(file, "a");
    if (handle) {
        fprintf(handle, "%s^n", szSID);
        fclose(handle);
    }
}

RemoveBlockedSID(szSID[]) {
    new file[64];
    formatex(file, sizeof(file), "blocked_sids.txt");
    new handle = fopen(file, "r");
    new tempFile[64];
    formatex(tempFile, sizeof(tempFile), "temp_blocked_sids.txt");
    new tempHandle = fopen(tempFile, "w");

    if (handle && tempHandle) {
        while (!feof(handle)) {
            new line[32];
            fgets(line, sizeof(line), handle);
            if (line[0] != "\0") {
                trim(line);
                if (!equal(line, szSID)) {
                    fprintf(tempHandle, "%s^n", line);
                }
            }
        }
        fclose(handle);
        fclose(tempHandle);
        delete_file(file);
        rename_file(tempFile, file);
    }
}

public cmd_amx_stay(id, level, cid) {
    if (!(get_user_flags(id) & ADMIN_BAN)) {
        client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy.");
        return PLUGIN_HANDLED;
    }

    if (read_argc() < 2) {
        client_print(id, print_console, "[AMX Stay] Użycie: amx_stay <nick/steamid>");
        return PLUGIN_HANDLED;
    }

    new arg[32];
    read_argv(1, arg, charsmax(arg));

    new target = FindTarget(arg);

    if (!target) {
        client_print(id, print_console, "[AMX Stay] Nie znaleziono gracza o nicku/SteamID: %s", arg);
        return PLUGIN_HANDLED;
    }

    new targetSID[32];
    get_user_authid(target, targetSID, charsmax(targetSID));

    for (new i = 0; i < g_iBlockedCount; i++) {
        if (equal(g_szBlockedSIDs[i], targetSID)) {
            client_print(id, print_console, "[AMX Stay] Gracz z SID %s jest zablokowany.", targetSID);
            return PLUGIN_HANDLED;
        }
    }

    SaveBlockedSID(targetSID);
    g_bStayBlocked[target] = true;
    g_fMaxSpeed[target] = get_user_maxspeed(target);
    set_user_maxspeed(target, 0.1);

    new target_name[32];
    get_user_name(target, target_name, charsmax(target_name));

    new message[64];
    formatex(message, charsmax(message), "[AMX Stay] Zatrzymano gracza %s.", target_name);
    client_print(id, print_console, message);

    return PLUGIN_HANDLED;
}

public cmd_amx_stay_remove(id, level, cid) {
    if (!(get_user_flags(id) & ADMIN_BAN)) {
        client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy.");
        return PLUGIN_HANDLED;
    }

    if (read_argc() < 2) {
        client_print(id, print_console, "[AMX Stay] Użycie: amx_stay_remove <SID>");
        return PLUGIN_HANDLED;
    }

    new arg[32];
    read_argv(1, arg, charsmax(arg));

    bool found = false;
    for (new i = 0; i < g_iBlockedCount; i++) {
        if (equal(g_szBlockedSIDs[i], arg)) {
            found = true;
            break;
        }
    }

    if (!found) {
        client_print(id, print_console, "[AMX Stay] SID %s nie został znaleziony w blokadzie.", arg);
        return PLUGIN_HANDLED;
    }

    RemoveBlockedSID(arg);
    client_print(id, print_console, "[AMX Stay] SID %s został usunięty z blokady.", arg);
    return PLUGIN_HANDLED;
}

public client_disconnect(id) {
    g_bStayBlocked[id] = false;
    g_fMaxSpeed[id] = 0.1;
}

public client_spawn(id) {
    if (g_bStayBlocked[id]) {
        set_user_maxspeed(id, 0.1);
    }
}

public on_cmd_start(id, uc_handle, seed) {
    if (!g_bStayBlocked[id]) {
        return FMRES_IGNORED;
    }

    set_user_maxspeed(id, 0.1);

    static uc_cmd;
    uc_cmd = get_uc(uc_handle, UC_Buttons);
    set_uc(uc_handle, UC_Buttons, uc_cmd & ~(IN_ATTACK | IN_ATTACK2 | IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT | IN_JUMP | IN_USE));

    return FMRES_SUPERCEDE;
}

FindTarget(szKey[]) {
    new iTarget = 0;
    trim(szKey);
    remove_quotes(szKey);

    if (szKey[0] == "#") {
        iTarget = find_player("a", szKey + 1);
    } else if ((iTarget = find_player("b", szKey))) {
        return iTarget;
    } else if ((iTarget = find_player("c", szKey))) {
        return iTarget;
    }

    return iTarget;
}

 


Cześć, Ostatnio myślałem o próbie napisania pluginu który zamraża gracza oraz nie pozwala mu strzelać, co się udało.
Chciałem go rozbudować o zapisywanie SID do pliku TXT i blokowanie każdego gracza z danym SID który jest obecnie na serwerze.
Niestety nie mogę przeprowadzić tego pluginu przez proces kompilacji i nie rozumiem dlaczego, czy możecie mi  w tym pomóc?
Załączam plugin który zatrzymuje (podstawke) i w cytacie to co rozbudowałem.
 

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>

#define PLUGIN "AMX Stay"
#define VERSION "1.0"
#define AUTHOR "mT[1]g"

new bool:g_bStayBlocked[33];
new Float:g_fMaxSpeed[33];
new String:g_szBlockedSIDs[100][32];
new g_iBlockedCount = 0;

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_concmd("amx_stay", "cmd_amx_stay", ADMIN_BAN, "<nick/steamid> - Zatrzymaj/odblokuj gracza");
    register_concmd("amx_stay_remove", "cmd_amx_stay_remove", ADMIN_BAN, "<SID> - Usuń SID z blokady");
    RegisterHam(Ham_Spawn, "player", "client_spawn", 1);
    register_forward(FM_CmdStart, "on_cmd_start", 1);
    LoadBlockedSIDs();
}

LoadBlockedSIDs() {
    new file[64];
    formatex(file, sizeof(file), "blocked_sids.txt");
    new handle = fopen(file, "r");
    if (handle) {
        while (!feof(handle)) {
            new line[32];
            fgets(line, sizeof(line), handle);
            if (line[0] != '\0') {
                trim(line);
                formatex(g_szBlockedSIDs[g_iBlockedCount], sizeof(g_szBlockedSIDs[g_iBlockedCount]), "%s", line);
                g_iBlockedCount++;
            }
        }
        fclose(handle);
    }
}

SaveBlockedSID(szSID[]) {
    new file[64];
    formatex(file, sizeof(file), "blocked_sids.txt");
    new handle = fopen(file, "a");
    if (handle) {
        fprintf(handle, "%s^n", szSID);
        fclose(handle);
    }
}

RemoveBlockedSID(szSID[]) {
    new file[64];
    formatex(file, sizeof(file), "blocked_sids.txt");
    new handle = fopen(file, "r");
    new tempFile[64];
    formatex(tempFile, sizeof(tempFile), "temp_blocked_sids.txt");
    new tempHandle = fopen(tempFile, "w");

    if (handle && tempHandle) {
        while (!feof(handle)) {
            new line[32];
            fgets(line, sizeof(line), handle);
            if (line[0] != "\0") {
                trim(line);
                if (!equal(line, szSID)) {
                    fprintf(tempHandle, "%s^n", line);
                }
            }
        }
        fclose(handle);
        fclose(tempHandle);
        delete_file(file);
        rename_file(tempFile, file);
    }
}

public cmd_amx_stay(id, level, cid) {
    if (!(get_user_flags(id) & ADMIN_BAN)) {
        client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy.");
        return PLUGIN_HANDLED;
    }

    if (read_argc() < 2) {
        client_print(id, print_console, "[AMX Stay] Użycie: amx_stay <nick/steamid>");
        return PLUGIN_HANDLED;
    }

    new arg[32];
    read_argv(1, arg, charsmax(arg));

    new target = FindTarget(arg);

    if (!target) {
        client_print(id, print_console, "[AMX Stay] Nie znaleziono gracza o nicku/SteamID: %s", arg);
        return PLUGIN_HANDLED;
    }

    new targetSID[32];
    get_user_authid(target, targetSID, charsmax(targetSID));

    for (new i = 0; i < g_iBlockedCount; i++) {
        if (equal(g_szBlockedSIDs[i], targetSID)) {
            client_print(id, print_console, "[AMX Stay] Gracz z SID %s jest zablokowany.", targetSID);
            return PLUGIN_HANDLED;
        }
    }

    SaveBlockedSID(targetSID);
    g_bStayBlocked[target] = true;
    g_fMaxSpeed[target] = get_user_maxspeed(target);
    set_user_maxspeed(target, 0.1);

    new target_name[32];
    get_user_name(target, target_name, charsmax(target_name));

    new message[64];
    formatex(message, charsmax(message), "[AMX Stay] Zatrzymano gracza %s.", target_name);
    client_print(id, print_console, message);

    return PLUGIN_HANDLED;
}

public cmd_amx_stay_remove(id, level, cid) {
    if (!(get_user_flags(id) & ADMIN_BAN)) {
        client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy.");
        return PLUGIN_HANDLED;
    }

    if (read_argc() < 2) {
        client_print(id, print_console, "[AMX Stay] Użycie: amx_stay_remove <SID>");
        return PLUGIN_HANDLED;
    }

    new arg[32];
    read_argv(1, arg, charsmax(arg));

    bool found = false;
    for (new i = 0; i < g_iBlockedCount; i++) {
        if (equal(g_szBlockedSIDs[i], arg)) {
            found = true;
            break;
        }
    }

    if (!found) {
        client_print(id, print_console, "[AMX Stay] SID %s nie został znaleziony w blokadzie.", arg);
        return PLUGIN_HANDLED;
    }

    RemoveBlockedSID(arg);
    client_print(id, print_console, "[AMX Stay] SID %s został usunięty z blokady.", arg);
    return PLUGIN_HANDLED;
}

public client_disconnect(id) {
    g_bStayBlocked[id] = false;
    g_fMaxSpeed[id] = 0.1;
}

public client_spawn(id) {
    if (g_bStayBlocked[id]) {
        set_user_maxspeed(id, 0.1);
    }
}

public on_cmd_start(id, uc_handle, seed) {
    if (!g_bStayBlocked[id]) {
        return FMRES_IGNORED;
    }

    set_user_maxspeed(id, 0.1);

    static uc_cmd;
    uc_cmd = get_uc(uc_handle, UC_Buttons);
    set_uc(uc_handle, UC_Buttons, uc_cmd & ~(IN_ATTACK | IN_ATTACK2 | IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT | IN_JUMP | IN_USE));

    return FMRES_SUPERCEDE;
}

FindTarget(szKey[]) {
    new iTarget = 0;
    trim(szKey);
    remove_quotes(szKey);

    if (szKey[0] == "#") {
        iTarget = find_player("a", szKey + 1);
    } else if ((iTarget = find_player("b", szKey))) {
        return iTarget;
    } else if ((iTarget = find_player("c", szKey))) {
        return iTarget;
    }

    return iTarget;
}