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
 

Zdjęcie

hp shop


  • Zamknięty Temat jest zamknięty
15 odpowiedzi w tym temacie

#1 Arct

    Zaawansowany

  • Użytkownik

Reputacja: 10
Początkujący

  • Postów:105
  • Lokalizacja:Szczecin
Offline

Napisano 21.10.2009 22:05

Witam!

niedawno na forum zobaczylem fajny plugin
hp shop link tutaj
poprostu sklep z HP :P


i mam pytanie czy da sie przerobic ten plugin tak aby
mogli z tego korzystac tylko ci co maja range Admin_level_H czy C

np. jesli wpisze w say czy say_team zwykly gracz /hpshop nic nie zobaczy
jesli zas wpisze to gracz z odpowiednia ranga (np.w/w) to zobaczyc sklepiek :)

najlepiej aby jeszcze niepokazywal sie wszystkim ten komunikat
"wpisz /hpshop"

da rade cos takiego wykonac ?
czekam na odp.
  • +
  • -
  • 0

#2 DarkGL

    Nie oddam ciasteczka !

  • Administrator

Reputacja: 6 554
Godlike

  • Postów:11 979
  • GG:
  • Steam:steam
  • Imię:Rafał
  • Lokalizacja:Warszawa
Offline

Napisano 21.10.2009 22:46

może tak
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"

#define FM_MONEY_OFFSET 115

new health40[200]
new health60[200]
new health80[200]
new health100[200]
new health120[200]
new health140[200]
new health160[200]

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_160hp

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /hpshop", "show_menu_buy_hp")
	register_clcmd("say_team /hpshop", "show_menu_buy_hp")
	
	register_logevent("Event_Round_Start", 2, "1=Round_Start")
	
	cost_40hp = register_cvar("hs_40hp_cost", "2000")
	cost_60hp = register_cvar("hs_60hp_cost", "4000")
	cost_80hp = register_cvar("hs_80hp_cost", "6000")
	cost_100hp = register_cvar("hs_100hp_cost", "8000")
	cost_120hp = register_cvar("hs_120hp_cost", "10000")
	cost_140hp = register_cvar("hs_140hp_cost", "12000")
	cost_160hp = register_cvar("hs_160hp_cost", "14000")
}

public show_menu_buy_hp(id)
{
	if(has_flags(id,"h,c")){
		new menu = menu_create("rHealth Shop", "handle_buy_hp_menu")
		
		formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp))
		menu_additem(menu, health40, "1")
		
		formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp))
		menu_additem(menu, health60, "2")
		
		formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp))
		menu_additem(menu, health80, "3")
		
		formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp))
		menu_additem(menu, health100, "4")
		
		formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp))
		menu_additem(menu, health120, "5")
		
		formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp))
		menu_additem(menu, health140, "6")
		
		formatex(health160, 199, "+160 Health - $%d", get_pcvar_num(cost_160hp))
		menu_additem(menu, health160, "7")
		
		menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
		menu_display(id, menu, 0)
	}
}

public handle_buy_hp_menu(id, menu, item)
{
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	
	new Data[6];
	new Access;
	new Callback;
	new Name[64];
	menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)
	
	new Key = str_to_num(Data);
	
	switch (Key)
	{
		case 1:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_40hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +40 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+40)
			}
		}
		
		case 2:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_60hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +60 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+60)
			}
		}
		
		case 3:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_80hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +80 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+80)
			}
		}
		
		case 4:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_100hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +100 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+100)
			}
		}
		
		case 5:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_120hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +120 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+120)
			}
		}
		
		case 6:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_140hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +140 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+140)
			}
		}
		
		case 7:
		{
			if (!is_user_alive(id))
			{
				client_print(id, print_chat, "You Have To Be Alive To Buy Health")
				return PLUGIN_HANDLED
			}
			
			new Money = fm_get_user_money(id)
			new Pcvar = get_pcvar_num(cost_160hp)
			new Health = get_user_health(id)
			
			if (Money < Pcvar)
			{
				client_print(id, print_chat, "You don't have enough money to buy this")
			}
			else
			{
				client_print(id, print_chat, "You just purchared +160 HP")
				fm_set_user_money(id, Money-Pcvar)
				fm_set_user_health (id, Health+160)
			}
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}

public Event_Round_Start()
{
	for(new i=1;i<33;i++){
		if(has_flags(i,"h,c")){
			client_print(0, print_chat, "To Open Up Health Shop,Type /hpshop in chat")
		}
	}
}

stock fm_set_user_health(index, health) 
{
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
	return 1
}

stock fm_get_user_money(index) 
{
	return get_pdata_int(index, FM_MONEY_OFFSET)
}

stock fm_set_user_money(index, money, flash = 1) 
{
	set_pdata_int(index, FM_MONEY_OFFSET, money);
	
	message_begin(MSG_ONE, get_user_msgid("Money"), _, index);
	write_long(money);
	write_byte(flash ? 1 : 0);
	message_end();
}

public has_flags(id,string[]) 
{ 
	new ret=1 
	new byte 
	
	new len = strlen(string) 
	new p_flag = get_user_flags(id) 
	
	for(new i=0;i<=len;i++) 
	{ 
		if(string[i]>='a' && string[i]<='z') byte = (1<<(string[i]-'a')) 
		else if(string[i]>='A' && string[i]<='Z') byte = (1<<(string[i]-'A')) 
			else if(string[i]==',' && ret==1) return 1 
			else if(string[i]==',') ret=1 
			if(byte!=0 && !(p_flag & byte)) ret=0 
		
		byte=0 
	} 
	
	return ret 
}

  • +
  • -
  • 0

#3 Vertricus

    Godlike

  • Przyjaciel

Reputacja: 426
Wszechobecny

  • Postów:1 549
  • Lokalizacja:.
Offline

Napisano 22.10.2009 08:53

@Up
t - własny poziom H
o - własny poziom C

Flagi dostępu
a - immunitet (gracz z tą flagą ma immunitet czyli nie może być kickowany, banowany, slapowany itp. Zaleca się nie dawanie tej flagi nikomu. Co najwyżej sobie (H@)). 
b - rezerwacja slotu (gracz dostaje rezerwacje slotu) 
c - amx_kick (admin z tą flagą może kopać ludzi z serwera). 
d - amx_ban i amx_unban (admin z tą flagą może banować i odbanowywac graczy) 
e - amx_slay i amx_slap (admin z tą flagą może slayować i slapować graczy) 
f - amx_map (admin z tą flagą może zmieniać mapę) 
g - amx_cvar (admin z tą flagą może zmieniać ustawienia serwera [nie wszystkie!]) 
h - amx_cfg (admin z tą flagą może uruchamiać configi serwera) 
i - amx_chat (admin z tą flagą może używać kolorowych napisów) 
j - amx_vote (admin z tą flagą może uruchamiać glosowania) 
k - dostęp do sv_password (admin z tą flagą może ustawić hasło na serwerze) 
l - dostęp do amx_rcon (admin z tą flagą może wykonywać polecenia na konsoli samego serwera poprzez amx_cvar) 
m - własny poziom A 
n - własny poziom B 
o - własny poziom C 
p - własny poziom D - (Flagi te są używane przez dodatkowe pluginy. Poziom A ma najniższy priorytet, poziom H najwyższy.) 
q - własny poziom E 
r - własny poziom F 
s - własny poziom G 
t - własny poziom H 
u - menu access (admin z tą flagą może używać menu) 
z - użytkownik (flaga do oznaczenia NIE admin, zwykłego użytkownika)

  • +
  • -
  • 0

#4 DarkGL

    Nie oddam ciasteczka !

  • Administrator

Reputacja: 6 554
Godlike

  • Postów:11 979
  • GG:
  • Steam:steam
  • Imię:Rafał
  • Lokalizacja:Warszawa
Offline

Napisano 22.10.2009 15:21

no to
/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <fakemeta> 

#define PLUGIN "Health Shop" 
#define VERSION "1.0" 
#define AUTHOR "ZaCkY" 

#define FM_MONEY_OFFSET 115 

new health40[200] 
new health60[200] 
new health80[200] 
new health100[200] 
new health120[200] 
new health140[200] 
new health160[200] 

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_160hp 

public plugin_init() { 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
    
    register_clcmd("say /hpshop", "show_menu_buy_hp") 
    register_clcmd("say_team /hpshop", "show_menu_buy_hp") 
    
    register_logevent("Event_Round_Start", 2, "1=Round_Start") 
    
    cost_40hp = register_cvar("hs_40hp_cost", "2000") 
    cost_60hp = register_cvar("hs_60hp_cost", "4000") 
    cost_80hp = register_cvar("hs_80hp_cost", "6000") 
    cost_100hp = register_cvar("hs_100hp_cost", "8000") 
    cost_120hp = register_cvar("hs_120hp_cost", "10000") 
    cost_140hp = register_cvar("hs_140hp_cost", "12000") 
    cost_160hp = register_cvar("hs_160hp_cost", "14000") 
} 

public show_menu_buy_hp(id) 
{ 
    if(has_flags(id,"t,o")){ 
        new menu = menu_create("rHealth Shop", "handle_buy_hp_menu") 
        
        formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp)) 
        menu_additem(menu, health40, "1") 
        
        formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp)) 
        menu_additem(menu, health60, "2") 
        
        formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp)) 
        menu_additem(menu, health80, "3") 
        
        formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp)) 
        menu_additem(menu, health100, "4") 
        
        formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp)) 
        menu_additem(menu, health120, "5") 
        
        formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp)) 
        menu_additem(menu, health140, "6") 
        
        formatex(health160, 199, "+160 Health - $%d", get_pcvar_num(cost_160hp)) 
        menu_additem(menu, health160, "7") 
        
        menu_setprop(menu, MPROP_EXIT, MEXIT_ALL) 
        menu_display(id, menu, 0) 
    } 
} 

public handle_buy_hp_menu(id, menu, item) 
{ 
    if (item == MENU_EXIT) 
    { 
        menu_destroy(menu) 
        return PLUGIN_HANDLED 
    } 
    
    new Data[6]; 
    new Access; 
    new Callback; 
    new Name[64]; 
    menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback) 
    
    new Key = str_to_num(Data); 
    
    switch (Key) 
    { 
        case 1: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_40hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +40 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+40) 
            } 
        } 
        
        case 2: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_60hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +60 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+60) 
            } 
        } 
        
        case 3: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_80hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +80 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+80) 
            } 
        } 
        
        case 4: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_100hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +100 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+100) 
            } 
        } 
        
        case 5: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_120hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +120 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+120) 
            } 
        } 
        
        case 6: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_140hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +140 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+140) 
            } 
        } 
        
        case 7: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_160hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +160 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+160) 
            } 
        } 
    } 
    menu_destroy(menu) 
    return PLUGIN_HANDLED 
} 

public Event_Round_Start() 
{ 
    for(new i=1;i<33;i++){ 
        if(has_flags(i,"t,o")){ 
            client_print(0, print_chat, "To Open Up Health Shop,Type /hpshop in chat") 
        } 
    } 
} 

stock fm_set_user_health(index, health) 
{ 
    health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index) 
    return 1 
} 

stock fm_get_user_money(index) 
{ 
    return get_pdata_int(index, FM_MONEY_OFFSET) 
} 

stock fm_set_user_money(index, money, flash = 1) 
{ 
    set_pdata_int(index, FM_MONEY_OFFSET, money); 
    
    message_begin(MSG_ONE, get_user_msgid("Money"), _, index); 
    write_long(money); 
    write_byte(flash ? 1 : 0); 
    message_end(); 
} 

public has_flags(id,string[]) 
{ 
    new ret=1 
    new byte 
    
    new len = strlen(string) 
    new p_flag = get_user_flags(id) 
    
    for(new i=0;i<=len;i++) 
    { 
        if(string[i]>='a' && string[i]<='z') byte = (1<<(string[i]-'a')) 
        else if(string[i]>='A' && string[i]<='Z') byte = (1<<(string[i]-'A')) 
            else if(string[i]==',' && ret==1) return 1 
            else if(string[i]==',') ret=1 
            if(byte!=0 && !(p_flag & byte)) ret=0 
        
        byte=0 
    } 
    
    return ret 
}

  • +
  • -
  • 0

#5 Arct

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 10
Początkujący

  • Postów:105
  • Lokalizacja:Szczecin
Offline

Napisano 23.10.2009 00:07

dobra plugin dziala iz tylko gracz z ranga LVL H czy C moze kupic
lecz kazdej osobie nadal pojawia sie komunikat w say

"To Open Up Health Shop,Type /hpshop in chat"
bez znaczenia czy ma dana range czy tez jej brak
  • +
  • -
  • 0

#6 DarkGL

    Nie oddam ciasteczka !

  • Administrator

Reputacja: 6 554
Godlike

  • Postów:11 979
  • GG:
  • Steam:steam
  • Imię:Rafał
  • Lokalizacja:Warszawa
Offline

Napisano 23.10.2009 15:08

/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <fakemeta> 

#define PLUGIN "Health Shop" 
#define VERSION "1.0" 
#define AUTHOR "ZaCkY" 

#define FM_MONEY_OFFSET 115 

new health40[200] 
new health60[200] 
new health80[200] 
new health100[200] 
new health120[200] 
new health140[200] 
new health160[200] 

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_160hp 

public plugin_init() { 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
    
    register_clcmd("say /hpshop", "show_menu_buy_hp") 
    register_clcmd("say_team /hpshop", "show_menu_buy_hp") 
    
    register_logevent("Event_Round_Start", 2, "1=Round_Start") 
    
    cost_40hp = register_cvar("hs_40hp_cost", "2000") 
    cost_60hp = register_cvar("hs_60hp_cost", "4000") 
    cost_80hp = register_cvar("hs_80hp_cost", "6000") 
    cost_100hp = register_cvar("hs_100hp_cost", "8000") 
    cost_120hp = register_cvar("hs_120hp_cost", "10000") 
    cost_140hp = register_cvar("hs_140hp_cost", "12000") 
    cost_160hp = register_cvar("hs_160hp_cost", "14000") 
} 

public show_menu_buy_hp(id) 
{ 
    if(has_flags(id,"t,o")){ 
        new menu = menu_create("rHealth Shop", "handle_buy_hp_menu") 
        
        formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp)) 
        menu_additem(menu, health40, "1") 
        
        formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp)) 
        menu_additem(menu, health60, "2") 
        
        formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp)) 
        menu_additem(menu, health80, "3") 
        
        formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp)) 
        menu_additem(menu, health100, "4") 
        
        formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp)) 
        menu_additem(menu, health120, "5") 
        
        formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp)) 
        menu_additem(menu, health140, "6") 
        
        formatex(health160, 199, "+160 Health - $%d", get_pcvar_num(cost_160hp)) 
        menu_additem(menu, health160, "7") 
        
        menu_setprop(menu, MPROP_EXIT, MEXIT_ALL) 
        menu_display(id, menu, 0) 
    } 
} 

public handle_buy_hp_menu(id, menu, item) 
{ 
    if (item == MENU_EXIT) 
    { 
        menu_destroy(menu) 
        return PLUGIN_HANDLED 
    } 
    
    new Data[6]; 
    new Access; 
    new Callback; 
    new Name[64]; 
    menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback) 
    
    new Key = str_to_num(Data); 
    
    switch (Key) 
    { 
        case 1: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_40hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +40 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+40) 
            } 
        } 
        
        case 2: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_60hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +60 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+60) 
            } 
        } 
        
        case 3: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_80hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +80 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+80) 
            } 
        } 
        
        case 4: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_100hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +100 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+100) 
            } 
        } 
        
        case 5: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_120hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +120 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+120) 
            } 
        } 
        
        case 6: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_140hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +140 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+140) 
            } 
        } 
        
        case 7: 
        { 
            if (!is_user_alive(id)) 
            { 
                client_print(id, print_chat, "You Have To Be Alive To Buy Health") 
                return PLUGIN_HANDLED 
            } 
            
            new Money = fm_get_user_money(id) 
            new Pcvar = get_pcvar_num(cost_160hp) 
            new Health = get_user_health(id) 
            
            if (Money < Pcvar) 
            { 
                client_print(id, print_chat, "You don't have enough money to buy this") 
            } 
            else 
            { 
                client_print(id, print_chat, "You just purchared +160 HP") 
                fm_set_user_money(id, Money-Pcvar) 
                fm_set_user_health (id, Health+160) 
            } 
        } 
    } 
    menu_destroy(menu) 
    return PLUGIN_HANDLED 
} 

public Event_Round_Start() 
{ 
    for(new i=1;i<33;i++){ 
        if(has_flags(i,"t,o")){ 
            client_print(i, print_chat, "To Open Up Health Shop,Type /hpshop in chat") 
        } 
    } 
} 

stock fm_set_user_health(index, health) 
{ 
    health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index) 
    return 1 
} 

stock fm_get_user_money(index) 
{ 
    return get_pdata_int(index, FM_MONEY_OFFSET) 
} 

stock fm_set_user_money(index, money, flash = 1) 
{ 
    set_pdata_int(index, FM_MONEY_OFFSET, money); 
    
    message_begin(MSG_ONE, get_user_msgid("Money"), _, index); 
    write_long(money); 
    write_byte(flash ? 1 : 0); 
    message_end(); 
} 

public has_flags(id,string[]) 
{ 
    new ret=1 
    new byte 
    
    new len = strlen(string) 
    new p_flag = get_user_flags(id) 
    
    for(new i=0;i<=len;i++) 
    { 
        if(string[i]>='a' && string[i]<='z') byte = (1<<(string[i]-'a')) 
        else if(string[i]>='A' && string[i]<='Z') byte = (1<<(string[i]-'A')) 
            else if(string[i]==',' && ret==1) return 1 
            else if(string[i]==',') ret=1 
            if(byte!=0 && !(p_flag & byte)) ret=0 
        
        byte=0 
    } 
    
    return ret 
}
jeden malutki błąd ;)
  • +
  • -
  • 0

#7 Arct

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 10
Początkujący

  • Postów:105
  • Lokalizacja:Szczecin
Offline

Napisano 26.10.2009 20:05

ok dzięki za zmiane
choc od dzis srednio co min.
mam cos takiego

10/26/2009 - 20:06:36: [AMXX] Displaying debug trace (plugin "health_shop.amxx")
L 10/26/2009 - 20:06:36: [AMXX] Run time error 10: native error (native "get_user_flags")
L 10/26/2009 - 20:06:36: [AMXX]    [0] health_shop.sma::has_flags (line 294)
L 10/26/2009 - 20:06:36: [AMXX]    [1] health_shop.sma::Event_Round_Start (line 261)

  • +
  • -
  • 0

#8 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 26.10.2009 22:53

Arct, chyba musisz dodac:
#include <amxmisc>

  • +
  • -
  • 0

#9 Arct

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 10
Początkujący

  • Postów:105
  • Lokalizacja:Szczecin
Offline

Napisano 27.10.2009 00:47

po restarcie i zmianie mapy przez 30m bylo ok
lecz na tym sie skonczylo ten sam blad dalej istnieje
  • +
  • -
  • 0

#10 Vertricus

    Godlike

  • Przyjaciel

Reputacja: 426
Wszechobecny

  • Postów:1 549
  • Lokalizacja:.
Offline

Napisano 27.10.2009 01:06

Spróbuj zmienić na:
public Event_Round_Start() 
{
	new graczy = get_playersnum()
	for(new i=1;i<graczy;i++){ 
		if(get_user_flags(i)&ADMIN_LEVEL_H&&is_user_alive(i))
		{
			client_print(i, print_chat, "To Open Up Health Shop,Type /hpshop in chat") 
		} 
	} 
}

  • +
  • -
  • 0

#11 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 27.10.2009 09:16

Vertricus, nie wywalaj mojej funkcji jakby ona byla winna :zly:

Co ja poradze, ze nawet jak jest 1 osoba na serwie to chcecie sprawdzic flage 32 osoba...

new p[32],n
get_players(p,n,"c")
for(new i=0;i<n;i++){ 
 new id=p[i]
        if(has_flags(id,"t,o")){ 
            client_print(id, print_chat, "To Open Up Health Shop,Type /hpshop in chat") 
        } 
    }

Powinno byc ok, ale pisalem tu wiec moze byc literowka O:)
  • +
  • -
  • 0

#12 mgr inż. Pavulon

    C35H60Br2N2O4

  • Przyjaciel

Reputacja: 1 742
Godlike

  • Postów:6 881
  • Steam:steam
  • Imię:Konrad
  • Lokalizacja:Koniecpol
Offline

Napisano 27.10.2009 09:24

Co ja poradze, ze nawet jak jest 1 osoba na serwie to chcecie sprawdzic flage 32 osoba...

On to przecież robi w jeszcze gorszy sposób.
get_playersnum zwróci liczbę graczy, ale nie można zrobić pętle od i=1 do ilości graczy traktując i jako id gracza.
Równie dobrze na serwerze mogą być gracze o id= 3, 8, 12 i co wtedy ?
  • +
  • -
  • 0

#13 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 27.10.2009 13:40

Pavulon, sorry powinienem to zauwazyc, ale co innego mnie uderzylo najpierw ;>
  • +
  • -
  • 0

#14 Vertricus

    Godlike

  • Przyjaciel

Reputacja: 426
Wszechobecny

  • Postów:1 549
  • Lokalizacja:.
Offline

Napisano 27.10.2009 17:16

To ja przepraszam :(
Szczerze to nawet nie wiedziałem że na takiej zasadzie się to odbywa.
  • +
  • -
  • 0

#15 DarkGL

    Nie oddam ciasteczka !

  • Administrator

Reputacja: 6 554
Godlike

  • Postów:11 979
  • GG:
  • Steam:steam
  • Imię:Rafał
  • Lokalizacja:Warszawa
Offline

Napisano 27.10.2009 17:20

aj i tajemnica rozwiązana myślałem że get_playersnum() zwróci największe id a tu klops ;)
  • +
  • -
  • 0

#16 Arct

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 10
Początkujący

  • Postów:105
  • Lokalizacja:Szczecin
Offline

Napisano 28.10.2009 00:40

dobra to ktore rozwiazanie zastosowac ??
oba sie kompiluja ale jeszcze zadnego niesprawdzalem...
  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych