Peršokti į turinį
  • ŽAIDIMAI
  • , ŽAIDIMAI
  • ŽAIDIMAI

[PAMOKA]Pasidarom savo shopą.


Guest .iJust

Ši tema yra neaktyvi. Paskutinis pranešimas šioje temoje buvo prieš 5251 dienas (-ų). Patariame sukurti naują temą, o ne rašyti naują pranešimą.

Už neaktyvių temų prikėlimą galite sulaukti įspėjimo ir pranešimo pašalinimo!

Recommended Posts

Svečias

  • Dėmesio jai nemokate pakeisti paprašykite čia kad pakeisčiau.
    Šitoje pamokoje parodysiu kaip susikūrti savo norimą shopą.
     healthpotion = register_cvar("price_hp", "4000")
    speedpotion = register_cvar("price_sp", "4000")
    gravitypotion = register_cvar("price_gp", "4000")
    imortalitypotion = register_cvar("price_ip", "16000")

    //Special Shop Cost
    randomgun = register_cvar("price_gun", "16000")
    armor = register_cvar("price_armor", "4000")
    randomgrenade = register_cvar("price_grenade", "5000")


Skaičiai reiškia kainas jai norite pakeiskite.
Specialus shopas!
Pradedame:
1.Susikuriame tekstinį dokumentą.
2.Įsijungiame jį.
3.Ir pradedam
Moduliai:

#include 
#include 
#include 
#include 


Defainai:

#define PLUGIN "Pavadinimas"
#define VERSION "Versija"
#define AUTHOR "Autorius"


New constai:

new const gSpecialBuy[] = "Shop/Buy.wav"
new const gPotionDrink[] = "Shop/PotionDrink.wav"
new const gNoMoney[] = "Shop/NoMoney.wav"

//Guns
new const Grenades[][] = {
"weapon_hegrenade",
"weapon_flashbang",
"weapon_smokegrenade"
};

new const Primary[][] = {
"weapon_ak47",
"weapon_m4a1",
"weapon_m3",
"weapon_xm1014",
"weapon_mac10"
};

new const Secondary[][] = {
"weapon_deagle",
"weapon_usp",
"weapon_glock18",
"weapon_elite"
};


Variables:

//Potion Shop
new healthpotion
new speedpotion
new gravitypotion
new imortalitypotion

//Special Shop
new randomgun
new armor
new randomgrenade 

//Other stuff
new hp
new sp
new gp


initas ir precache:

public plugin_init()
{
 	register_plugin( PLUGIN, VERSION, AUTHOR );

          register_logevent( "round_start", 2, "1=Round_Start" );

 	register_clcmd("say /shop", "Shop")
 	register_clcmd("say_team /shop", "Shop")

//Other stuff
hp = register_cvar("amx_potion_health", "100");
sp = register_cvar("amx_potion_speed", "100");
gp = register_cvar("amx_potion_gravity", "0.6");

//Potion Cost
 	healthpotion = register_cvar("price_hp", "4000")
 	speedpotion = register_cvar("price_sp", "4000")
 	gravitypotion = register_cvar("price_gp", "4000")
imortalitypotion = register_cvar("price_ip", "16000")

//Special Shop Cost
randomgun = register_cvar("price_gun", "16000")
armor = register_cvar("price_armor", "4000")
randomgrenade = register_cvar("price_grenade", "5000")

//Dictionary
 	register_dictionary("shop.txt");
}

public plugin_precache()
{	
precache_sound(gPotionDrink)
precache_sound(gSpecialBuy)
precache_sound(gNoMoney)
}


Ir dadedam toki

public Shop(id)
{
new menu = menu_create("\yShop!", "menu_handler")

menu_additem(menu, "Potion Shop", "1", 0)
menu_additem(menu, "Special Shop", "2", 0)

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}

public menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
	menu_destroy(menu)
	return PLUGIN_HANDLED
}

new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)

new key = str_to_num(data)

switch(key)
{
	case 1: 
	{
           		new secmenu = menu_create("\wPotions:", "potmenu_handler") 
           		menu_additem(secmenu, "\wHealth Potion", "1", 0) 
           		menu_additem(secmenu, "\wSpeed Potion", "2", 0) 
           		menu_additem(secmenu, "\wGravity Potion", "3", 0) 
           		menu_additem(secmenu, "\wImortality Potion", "4", 0) 

           		menu_setprop(secmenu, MPROP_EXIT, MEXIT_ALL) 
           		menu_display(id, secmenu, 0) 
           		return PLUGIN_HANDLED
	}

	case 2: 
	{
           		new secmenu = menu_create("\wSpecial Shop:", "spemenu_handler") 
           		menu_additem(secmenu, "\wRandom Gun", "1", 0) 
           		menu_additem(secmenu, "\wArmor", "2", 0) 
           		menu_additem(secmenu, "\wRandom Grenade", "3", 0)  

           		menu_setprop(secmenu, MPROP_EXIT, MEXIT_ALL) 
           		menu_display(id, secmenu, 0) 
           		return PLUGIN_HANDLED
	}
}
menu_destroy(menu)
return PLUGIN_HANDLED;
}

public potmenu_handler(id, potmenu, item) 
{ 
   if (item == MENU_EXIT) 
   { 
       menu_destroy(potmenu) 
       return PLUGIN_HANDLED 
   } 

   new data[6], iName[64] 
   new access, callback 
   menu_item_getinfo(potmenu, item, access, data, 5, iName, 63, callback) 
   new key = str_to_num(data) 
   switch(key) 
   { 
       case 1: 
{
		new Cost = get_pcvar_num(healthpotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED;
		} 
		else 
		{

			set_user_health(id, get_user_health(id) + get_pcvar_num(hp));
			client_print(id, print_chat, "%L", LANG_PLAYER, "HP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);	

			Money -= Cost;

			cs_set_user_money(id, Money);
		}
}

       case 2: 
       { 
	{
		new Cost = get_pcvar_num(speedpotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
			set_user_maxspeed(id, get_user_maxspeed(id) + get_pcvar_num(sp));
			client_print(id, print_chat, "%L", LANG_PLAYER, "SP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);

			Money -= Cost;

			cs_set_user_money(id, Money);

		}
	}
       } 
       case 3: 
{
		new Cost = get_pcvar_num(gravitypotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
			set_user_gravity(id, get_user_gravity(id) + get_pcvar_num(gp));
			client_print(id, print_chat, "%L", LANG_PLAYER, "GP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);

			Money -= Cost;

			cs_set_user_money(id, Money);	

		}
}
case 4: 
{
		new Cost = get_pcvar_num(imortalitypotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
         			set_hudmessage( 225, 225, 225, -1.0, 0.29, 1, 6.0, 12.0 );
         			show_hudmessage( 0, "Congratz! You are now imortal for 1 round!" );
			set_user_godmode(id, 1)
			client_print(id, print_chat, "%L", LANG_PLAYER, "IP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);

			Money -= Cost;

			cs_set_user_money(id, Money);	

		}
}
   } 
   menu_destroy(potmenu) 
   return PLUGIN_HANDLED 
} 

public spemenu_handler(id, spemenu, item) 
{ 
   if (item == MENU_EXIT) 
   { 
       menu_destroy(spemenu) 
       return PLUGIN_HANDLED 
   } 

   new data[6], iName[64] 
   new access, callback 
   menu_item_getinfo(spemenu, item, access, data, 5, iName, 63, callback) 
   new key = str_to_num(data) 
   switch(key) 
   { 
       case 1: 
{
		new Cost = get_pcvar_num(randomgun);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED;
		} 
		else 
		{
        		strip_user_weapons(id)
       			give_item(id, Primary[random_num(0, sizeof Primary - 1)])
       			give_item(id, Secondary[random_num(0, sizeof Secondary - 1)])
       			give_item(id, "weapon_knife")
			client_print(id, print_chat, "%L", LANG_PLAYER, "RANDOM_GUN", Cost);
           			client_cmd( 0, "spk %s", gSpecialBuy);	

			Money -= Cost;

			cs_set_user_money(id, Money);
		}
}

       case 2: 
       { 
	{
		new Cost = get_pcvar_num(armor);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
			set_user_armor(id, 100)
			client_print(id, print_chat, "%L", LANG_PLAYER, "ARMOR", Cost);
           			client_cmd( 0, "spk %s", gSpecialBuy);

			Money -= Cost;

			cs_set_user_money(id, Money);

		}
	}
       } 
       case 3: 
{
		new Cost = get_pcvar_num(randomgrenade);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
       			give_item(id, Grenades[random_num(0, sizeof Grenades - 1)])
			client_print(id, print_chat, "%L", LANG_PLAYER, "RANDOM_GRENADE", Cost);
           			client_cmd( 0, "spk %s", gSpecialBuy);
			Money -= Cost;

			cs_set_user_money(id, Money);	

		}
}
   } 
   menu_destroy(spemenu) 
   return PLUGIN_HANDLED 
} 


Pilnas Kodas:

#include 
#include 
#include 
#include 

#define PLUGIN "Pavadinimas"
#define VERSION "Versija"
#define AUTHOR "Autorius"

new const gSpecialBuy[] = "Shop/Buy.wav"
new const gPotionDrink[] = "Shop/PotionDrink.wav"
new const gNoMoney[] = "Shop/NoMoney.wav"


//Guns
new const Grenades[][] = {
"weapon_hegrenade",
"weapon_flashbang",
"weapon_smokegrenade"
};

new const Primary[][] = {
"weapon_ak47",
"weapon_m4a1",
"weapon_m3",
"weapon_xm1014",
"weapon_mac10"
};

new const Secondary[][] = {
"weapon_deagle",
"weapon_usp",
"weapon_glock18",
"weapon_elite"
};


//Potion Shop
new healthpotion
new speedpotion
new gravitypotion
new imortalitypotion

//Special Shop
new randomgun
new armor
new randomgrenade 

//Other stuff
new hp
new sp
new gp

public plugin_init()
{
 	register_plugin( PLUGIN, VERSION, AUTHOR );

          register_logevent( "round_start", 2, "1=Round_Start" );

 	register_clcmd("say /shop", "Shop")
 	register_clcmd("say_team /shop", "Shop")

//Other stuff
hp = register_cvar("amx_potion_health", "100");
sp = register_cvar("amx_potion_speed", "100");
gp = register_cvar("amx_potion_gravity", "0.6");

//Potion Cost
 	healthpotion = register_cvar("price_hp", "4000")
 	speedpotion = register_cvar("price_sp", "4000")
 	gravitypotion = register_cvar("price_gp", "4000")
imortalitypotion = register_cvar("price_ip", "16000")

//Special Shop Cost
randomgun = register_cvar("price_gun", "16000")
armor = register_cvar("price_armor", "4000")
randomgrenade = register_cvar("price_grenade", "5000")

//Dictionary
 	register_dictionary("shop.txt");
}

public plugin_precache()
{	
precache_sound(gPotionDrink)
precache_sound(gSpecialBuy)
precache_sound(gNoMoney)
}

public Shop(id)
{
new menu = menu_create("\yShop!", "menu_handler")

menu_additem(menu, "Potions Shop", "1", 0)
menu_additem(menu, "Special Shop", "2", 0)

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}

public menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
	menu_destroy(menu)
	return PLUGIN_HANDLED
}

new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)

new key = str_to_num(data)

switch(key)
{
	case 1: 
	{
           		new secmenu = menu_create("\wPotions:", "potmenu_handler") 
           		menu_additem(secmenu, "\wHealth Potion", "1", 0) 
           		menu_additem(secmenu, "\wSpeed Potion", "2", 0) 
           		menu_additem(secmenu, "\wGravity Potion", "3", 0) 
           		menu_additem(secmenu, "\wImortality Potion", "4", 0) 

           		menu_setprop(secmenu, MPROP_EXIT, MEXIT_ALL) 
           		menu_display(id, secmenu, 0) 
           		return PLUGIN_HANDLED
	}

	case 2: 
	{
           		new secmenu = menu_create("\wSpecial Shop:", "spemenu_handler") 
           		menu_additem(secmenu, "\wRandom Gun", "1", 0) 
           		menu_additem(secmenu, "\wArmor", "2", 0) 
           		menu_additem(secmenu, "\wRandom Grenade", "3", 0)  

           		menu_setprop(secmenu, MPROP_EXIT, MEXIT_ALL) 
           		menu_display(id, secmenu, 0) 
           		return PLUGIN_HANDLED
	}
}
menu_destroy(menu)
return PLUGIN_HANDLED;
}

public potmenu_handler(id, potmenu, item) 
{ 
   if (item == MENU_EXIT) 
   { 
       menu_destroy(potmenu) 
       return PLUGIN_HANDLED 
   } 

   new data[6], iName[64] 
   new access, callback 
   menu_item_getinfo(potmenu, item, access, data, 5, iName, 63, callback) 
   new key = str_to_num(data) 
   switch(key) 
   { 
       case 1: 
{
		new Cost = get_pcvar_num(healthpotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED;
		} 
		else 
		{

			set_user_health(id, get_user_health(id) + get_pcvar_num(hp));
			client_print(id, print_chat, "%L", LANG_PLAYER, "HP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);	

			Money -= Cost;

			cs_set_user_money(id, Money);
		}
}

       case 2: 
       { 
	{
		new Cost = get_pcvar_num(speedpotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
			set_user_maxspeed(id, get_user_maxspeed(id) + get_pcvar_num(sp));
			client_print(id, print_chat, "%L", LANG_PLAYER, "SP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);

			Money -= Cost;

			cs_set_user_money(id, Money);

		}
	}
       } 
       case 3: 
{
		new Cost = get_pcvar_num(gravitypotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
			set_user_gravity(id, get_user_gravity(id) + get_pcvar_num(gp));
			client_print(id, print_chat, "%L", LANG_PLAYER, "GP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);

			Money -= Cost;

			cs_set_user_money(id, Money);	

		}
}
case 4: 
{
		new Cost = get_pcvar_num(imortalitypotion);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
         			set_hudmessage( 225, 225, 225, -1.0, 0.29, 1, 6.0, 12.0 );
         			show_hudmessage( 0, "Congratz! You are now imortal for 1 round!" );
			set_user_godmode(id, 1)
			client_print(id, print_chat, "%L", LANG_PLAYER, "IP", Cost);
           			client_cmd( 0, "spk %s", gPotionDrink);

			Money -= Cost;

			cs_set_user_money(id, Money);	

		}
}
   } 
   menu_destroy(potmenu) 
   return PLUGIN_HANDLED 
} 

public spemenu_handler(id, spemenu, item) 
{ 
   if (item == MENU_EXIT) 
   { 
       menu_destroy(spemenu) 
       return PLUGIN_HANDLED 
   } 

   new data[6], iName[64] 
   new access, callback 
   menu_item_getinfo(spemenu, item, access, data, 5, iName, 63, callback) 
   new key = str_to_num(data) 
   switch(key) 
   { 
       case 1: 
{
		new Cost = get_pcvar_num(randomgun);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED;
		} 
		else 
		{
        		strip_user_weapons(id)
       			give_item(id, Primary[random_num(0, sizeof Primary - 1)])
       			give_item(id, Secondary[random_num(0, sizeof Secondary - 1)])
       			give_item(id, "weapon_knife")
			client_print(id, print_chat, "%L", LANG_PLAYER, "RANDOM_GUN", Cost);
           			client_cmd( 0, "spk %s", gSpecialBuy);	

			Money -= Cost;

			cs_set_user_money(id, Money);
		}
}

       case 2: 
       { 
	{
		new Cost = get_pcvar_num(armor);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
			set_user_armor(id, 100)
			client_print(id, print_chat, "%L", LANG_PLAYER, "ARMOR", Cost);
           			client_cmd( 0, "spk %s", gSpecialBuy);

			Money -= Cost;

			cs_set_user_money(id, Money);

		}
	}
       } 
       case 3: 
{
		new Cost = get_pcvar_num(randomgrenade);
		new Money = cs_get_user_money(id);

		if (Money < Cost)
		{
			client_print(id, print_chat, "%L", LANG_PLAYER, "NO_MONEY", Cost);
			client_cmd( 0, "spk %s", gNoMoney);
			return PLUGIN_HANDLED
		} 
		else 
		{
       			give_item(id, Grenades[random_num(0, sizeof Grenades - 1)])
			client_print(id, print_chat, "%L", LANG_PLAYER, "RANDOM_GRENADE", Cost);
           			client_cmd( 0, "spk %s", gSpecialBuy);
			Money -= Cost;

			cs_set_user_money(id, Money);	

		}
}
   } 
   menu_destroy(spemenu) 
   return PLUGIN_HANDLED 
} 


Nuoroda į komentarą
Dalintis per kitą puslapį

  • Parašė po 1 mėnesio...

Ši tema yra neaktyvi. Paskutinis pranešimas šioje temoje buvo prieš 5251 dienas (-ų). Patariame sukurti naują temą, o ne rašyti naują pranešimą.

Už neaktyvių temų prikėlimą galite sulaukti įspėjimo ir pranešimo pašalinimo!

Prisijungti prie diskusijos

Palikti atsakymą galite iš karto, o užsiregistruoti vėliau. Jeigu jau turite paskyrą mūsų forume, Prisijunkite.

Svečias
Atsakyti šioje temoje...

×   Įklijuotas tekstas turi teksto formatavimą.   Pašalinti teksto formatavimą

  Galimi tik 75 veidukai.

×   Nuoroda buvo automatiškai įterpta.   Įterpti nuorodą paprastai

×   Jūsų ankstesnis pranešimas buvo atkurtas.   Išvalyti redaktorių

×   Jūs negalite įkelti nuotraukas tiesiogiai.Įkelkite arba įdėkite nuotraukas iš URL.

  • Šiame puslapyje naršo:   0 nariai

    • Nėra registruotų narių peržiūrinčių šį forumą.

Skelbimai


×
×
  • Sukurti naują...