[Преработка]Gold shop за Respawn - ReCSDM

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от YankoNL » 07 Апр 2021, 17:34

Здравейте,
пробвах няколко плъгина за златни оръжия обаче повечето не станаха. Този който работи - оръжията остават за винаги и нямат бонус щета.
Също така този ми дава грешка при компилиране с reapi, а без него се компилира без проблем.
Screenshot_11.png
с reapi
Screenshot_11.png (28.64 KiB) Преглеждано 2388 пъти
с reapi
с reapi
Screenshot_11.png (28.64 KiB) Преглеждано 2388 пъти
Screenshot_12.png
без reapi
Screenshot_12.png (8.99 KiB) Преглеждано 2388 пъти
без reapi
без reapi
Screenshot_12.png (8.99 KiB) Преглеждано 2388 пъти
Може ли някой да преработи този код? Искам оръжието да е валидно докато не умреш, да има мултипликатор на щетата х2 и по възможност да е reapi.

Ето го и въпросния "този" плъгин:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0-Gold"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[64],
	PModel[64]
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model" */
	{ "Golden AK47", 	1, 	"weapon_ak47", 	90, 	CSW_AK47, 	"models/chrom_gold/v_ak47.mdl", 	"models/chrom_gold/p_ak47.mdl" },
	{ "Golden M4A1", 	1, 	"weapon_m4a1", 	90, 	CSW_M4A1, 	"models/chrom_gold/v_m4a1.mdl", 	"models/chrom_gold/p_m4a1.mdl" }
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Simple Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXSimpleShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	
	register_dictionary("gold_shop.txt")
	
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("&x04[&x03Gold Shop&x04]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}

public OnPlayerSpawn(id)
{
	if(!is_user_alive(id))
	{
		g_iWeapon[id] = NO_WEAPON
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "%l", "GOLD_ALIVE")	// You need to be alive.
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
				
			menu_additem(iMenu, szItem)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		if(g_iWeapon[id] == iItem)
			CC_SendMessage(id, "%l", "GOLD_HAVE")	// You already have that!
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_NOMONEY")	// You don't have enough money to purchase this item.
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_BUY", g_eItems[iItem][Name], g_eItems[iItem][Price]) // You have bought ^3%s ^1for ^4%i$
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iItem
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iItem][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iItem][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iItem][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iItem][Ammo], g_eItems[iItem][Csw])
				OnChangeWeapon(id)
			}
		}
	}
	
	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

Аватар
hackera457
Извън линия
Модератор
Модератор
Мнения: 768
Регистриран на: 01 Ное 2016, 09:46
Местоположение: София
Се отблагодари: 1 път
Получена благодарност: 124 пъти
Обратна връзка:

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от hackera457 » 07 Апр 2021, 20:28

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0-Gold"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[64],
	PModel[64]
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model" */
	{ "Golden AK47", 	1, 	"weapon_ak47", 	90, 	CSW_AK47, 	"models/chrom_gold/v_ak47.mdl", 	"models/chrom_gold/p_ak47.mdl" },
	{ "Golden M4A1", 	1, 	"weapon_m4a1", 	90, 	CSW_M4A1, 	"models/chrom_gold/v_m4a1.mdl", 	"models/chrom_gold/p_m4a1.mdl" }
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Simple Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXSimpleShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	
	register_dictionary("gold_shop.txt")
	
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	//RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	RegisterHam(Ham_Killed, "player", "OnPlayerKilled")
	CC_SetPrefix("&x04[&x03Gold Shop&x04]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}

public OnPlayerSpawn(id)
{
	if(!is_user_alive(id))
	{
		g_iWeapon[id] = NO_WEAPON
	}
}

public OnPlayerKilled(iVicim,iAttacker,iSHoudGib)
{
	if(g_iWeapon[iVictim] != NO_WEAPON)
		g_iWeapon[iVicim] = NO_WEAPON
}

public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(iInflictor == iAttacker)
	{
		if(g_iWeapon[iAttacker] != NO_WEAPON)
			SetHamParamFloat(4, fDamage * 2)
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "%l", "GOLD_ALIVE")	// You need to be alive.
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
				
			menu_additem(iMenu, szItem)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		if(g_iWeapon[id] == iItem)
			CC_SendMessage(id, "%l", "GOLD_HAVE")	// You already have that!
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_NOMONEY")	// You don't have enough money to purchase this item.
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_BUY", g_eItems[iItem][Name], g_eItems[iItem][Price]) // You have bought ^3%s ^1for ^4%i$
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iItem
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iItem][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iItem][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iItem][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iItem][Ammo], g_eItems[iItem][Csw])
				OnChangeWeapon(id)
			}
		}
	}
	
	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}
Моите плъгини

Код за потвърждение: Избери целия код

#include <hambeer>

RegisterHamBeer(HamBeer_Spawn, "player", "GivePlayerBeer", 1);

public GivePlayerBeer(Pl){
    if(!is_user_alive(Pl)){
        ham_give_beer(Pl, 5)
        client_print(Pl, print_chat, "Go Go Go"){
}  


Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от YankoNL » 08 Апр 2021, 02:19

Балгодаря,
ще го тествам в петък. Така че за сега темата ако може да остане отворена, за да пиша ако имам някакъв пробелм. :tnx:

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от YankoNL » 09 Апр 2021, 12:47

Грешка на 83 ред.
Screenshot_13.png
Screenshot_13.png (8.92 KiB) Преглеждано 2293 пъти
Screenshot_13.png
Screenshot_13.png (8.92 KiB) Преглеждано 2293 пъти

Аватар
illusion
Извън линия
Developer
Developer
Мнения: 1796
Регистриран на: 27 Ное 2016, 17:47
Местоположение: CraftVision
Се отблагодари: 151 пъти
Получена благодарност: 358 пъти
Обратна връзка:

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от illusion » 09 Апр 2021, 13:02

Тествай

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0-Gold"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[64],
	PModel[64]
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model" */
	{ "Golden AK47", 	1, 	"weapon_ak47", 	90, 	CSW_AK47, 	"models/chrom_gold/v_ak47.mdl", 	"models/chrom_gold/p_ak47.mdl" },
	{ "Golden M4A1", 	1, 	"weapon_m4a1", 	90, 	CSW_M4A1, 	"models/chrom_gold/v_m4a1.mdl", 	"models/chrom_gold/p_m4a1.mdl" }
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Simple Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXSimpleShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	
	register_dictionary("gold_shop.txt")
	
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	//RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	RegisterHam(Ham_Killed, "player", "OnPlayerKilled")
	CC_SetPrefix("&x04[&x03Gold Shop&x04]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}

public OnPlayerSpawn(id)
{
	if(!is_user_alive(id))
	{
		g_iWeapon[id] = NO_WEAPON
	}
}

public OnPlayerKilled(iVictim, iVicim, iAttacker,iSHoudGib)
{
	if(g_iWeapon[iVictim] != NO_WEAPON)
	g_iWeapon[iVicim] = NO_WEAPON
}

public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(iInflictor == iAttacker)
	{
		if(g_iWeapon[iAttacker] != NO_WEAPON)
			SetHamParamFloat(4, fDamage * 2)
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "%l", "GOLD_ALIVE")	// You need to be alive.
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
				
			menu_additem(iMenu, szItem)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		if(g_iWeapon[id] == iItem)
			CC_SendMessage(id, "%l", "GOLD_HAVE")	// You already have that!
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_NOMONEY")	// You don't have enough money to purchase this item.
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_BUY", g_eItems[iItem][Name], g_eItems[iItem][Price]) // You have bought ^3%s ^1for ^4%i$
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iItem
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iItem][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iItem][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iItem][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iItem][Ammo], g_eItems[iItem][Csw])
				OnChangeWeapon(id)
			}
		}
	}
	
	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от YankoNL » 09 Апр 2021, 13:14

Работи! :tnx:
Само че не маха старите оръжия и като си купиш голд оръжие няма backpack ammo за него.
summertime vibes написа: 09 Апр 2021, 13:02 Тествай

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0-Gold"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[64],
	PModel[64]
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model" */
	{ "Golden AK47", 	1, 	"weapon_ak47", 	90, 	CSW_AK47, 	"models/chrom_gold/v_ak47.mdl", 	"models/chrom_gold/p_ak47.mdl" },
	{ "Golden M4A1", 	1, 	"weapon_m4a1", 	90, 	CSW_M4A1, 	"models/chrom_gold/v_m4a1.mdl", 	"models/chrom_gold/p_m4a1.mdl" }
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Simple Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXSimpleShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	
	register_dictionary("gold_shop.txt")
	
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	//RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	RegisterHam(Ham_Killed, "player", "OnPlayerKilled")
	CC_SetPrefix("&x04[&x03Gold Shop&x04]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}

public OnPlayerSpawn(id)
{
	if(!is_user_alive(id))
	{
		g_iWeapon[id] = NO_WEAPON
	}
}

public OnPlayerKilled(iVictim, iVicim, iAttacker,iSHoudGib)
{
	if(g_iWeapon[iVictim] != NO_WEAPON)
	g_iWeapon[iVicim] = NO_WEAPON
}

public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(iInflictor == iAttacker)
	{
		if(g_iWeapon[iAttacker] != NO_WEAPON)
			SetHamParamFloat(4, fDamage * 2)
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "%l", "GOLD_ALIVE")	// You need to be alive.
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
				
			menu_additem(iMenu, szItem)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		if(g_iWeapon[id] == iItem)
			CC_SendMessage(id, "%l", "GOLD_HAVE")	// You already have that!
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_NOMONEY")	// You don't have enough money to purchase this item.
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iItem][Price])
				CC_SendMessage(id, "%l", "GOLD_BUY", g_eItems[iItem][Name], g_eItems[iItem][Price]) // You have bought ^3%s ^1for ^4%i$
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iItem
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iItem][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iItem][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iItem][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iItem][Ammo], g_eItems[iItem][Csw])
				OnChangeWeapon(id)
			}
		}
	}
	
	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

[Преработка]Gold shop за Respawn - ReCSDM

Мнение от YankoNL » 11 Май 2021, 12:38

Ако някой случайно търси Gold Shop който да работи без грешка, ето:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[64],
	PModel[64],
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model" */
	{ "Golden M4A1", 6000, "weapon_m4a1", 90, CSW_M4A1, "models/v_m4a1_gold.mdl", "models/p_m4a1_gold.mdl"},
	{ "Golden AK47", 6000, "weapon_ak47", 90, CSW_AK47, "models/v_ak47_gold.mdl", "models/p_ak47_gold.mdl"}
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("&x04[&x03Gold Shop&x04]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
public OnPlayerSpawn(id)
	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * 2)		// Damage Control - Настройка на щетата
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\r[Custom] \yGolden Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[Owned]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
				
			num_to_str(i, szKey, charsmax(szKey))
			menu_additem(iMenu, szItem, szKey)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, " You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
					
				give_item(id, g_eItems[iKey][Weapon])
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}
Ето и вариант с .txt файл в data/lang за различни езици:

Код за потвърждение: Избери целия код

/*
	Original plugin writen by OciXCrom
	
	* Version 1.0 - First Release
	* Version 1.1 - Added language file for messages (edited by YankoNL)
*/
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

#define PLUGIN_VERSION "1.1"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[64],
	PModel[64],
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model" */
	{ "Golden M4A1", 6000, "weapon_m4a1", 90, CSW_M4A1, "models/v_m4a1_gold.mdl", "models/p_m4a1_gold.mdl"},
	{ "Golden AK47", 6000, "weapon_ak47", 90, CSW_AK47, "models/v_ak47_gold.mdl", "models/p_ak47_gold.mdl"}
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom (edit: YankoNL)")
	register_dictionary("gold_shop.txt");
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("&x04[&x03Gold Shop&x04]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
public OnPlayerSpawn(id)
	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * 2)
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "%l", "GOLD_SHOP_ALIVE")	// You need to be alive.
	else
	{
		new iMenu = menu_create("\r[Custom] \yGolden Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[Owned]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
				
			num_to_str(i, szKey, charsmax(szKey))
			menu_additem(iMenu, szItem, szKey)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "%l", "GOLD_SHOP_OWNED")	// You already have this item.
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, "%l", "GOLD_SHOP_NO_MONEY")	// You don't have enough money to purchase this item.
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "%l", "GOLD_SHOP_BUY", g_eItems[iKey][Name], g_eItems[iKey][Price])	// You have bought ^3%s ^1for ^4%i$
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
					
				give_item(id, g_eItems[iKey][Weapon])
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}
Може да локвате! :lock:
Прикачени файлове
gold_shop.txt
Езиков файл за съобщенията
(388 Байта) Свалено 93 пъти
gold_shop.txt
Езиков файл за съобщенията
(388 Байта) Свалено 93 пъти

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 6 госта