Thread: money shop
View Single Post
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-23-2020 , 17:50   Re: money shop
Reply With Quote #4

Quote:
Originally Posted by Napoleon_be View Post
i just don't think this dude knows how to code that plugin.
actually, this is how i tried to it by myself
Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#define CC_COLORS_TYPE CC_COLORS_SHORT
#include <cromchat>  

const MENU_KEYS = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9)

new bool:godmode[33] = false
new bool:respawn[33] = false

public plugin_init()
{
	register_plugin( "Simple Shop Menu", "1.0", "nutu.")
	
	register_menucmd(register_menuid("Shop Menu"), MENU_KEYS, "menu_handler")
	RegisterHam(Ham_Spawn,"player","SpawnPlayer",1)
	
	register_clcmd( "say /shop","ShopMenu" );
	register_clcmd( "say_team /shop","ShopMenu" );
}
public SpawnPlayer(id)
{
	godmode[id] = false
	respawn[id] = false
	
	if(is_user_alive(id))
	{
		set_user_maxspeed(id, 250.0)
		set_user_gravity(id,1.0)
		set_pev(id,pev_takedamage,DAMAGE_AIM)
		set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255)
	}
}
public ShopMenu( id )
{
	ShowMenu_Shop(id)
	return PLUGIN_HANDLED
}
public ShowMenu_Shop(id)
{
	new szMenu[256], n
	n += formatex(szMenu[n], charsmax(szMenu)-n, "\yhS | Deathrun Shop Menu^n^n")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "\r1\w. Greandes Pack \y500 hS$")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n\r3\w. Gravity \y700 hS$")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n\r3\w. Speed \y400 hS$")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n\r4\w. TMP \y300 hS$")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n\r5\w. Immortality \r[20 sec] \y800 hS$")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n\r6\w. Full Health \r[+AP] \y150 hS$")
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n\r7\w. Respawn \y500 hS$")
	
	n += formatex(szMenu[n], charsmax(szMenu)-n, "^n^n\r0\w. Exit")
	
	show_menu(id, MENU_KEYS, szMenu, -1, "Shop Menu")
}
public menu_handler( id, key )
{
	switch( key )
	{
		case 0:
		{
			new money = cs_get_user_money(id)
			if(money < 500)
			{
				CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")
			}
			else
			{
				
				give_item(id, "weapon_hegrenade")
				give_item(id, "weapon_flashbang")
				give_item(id, "weapon_flashbang")
				give_item(id, "weapon_smokegrenade")
				CromChat(id, "!g[hS Shop] !nYou have bought Grenade Pack with !g500 hS$")
				cs_get_user_money(money - 500)
			}
		}
		case 1:
		{
			new money = cs_get_user_money(id)
			if(money < 700)
			{
				CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")
			}
			else
			{
				if(!is_user_alive(id))
					return PLUGIN_HANDLED
				
				set_user_gravity(id, 0.6)
				CromChat(id, "!g[hS Shop] !nYou have bought Gravity with !g700 hS$")
				cs_get_user_money(money - 700)
			}
		}
		case 2:
		{
			new money = cs_get_user_money(id)
			if(money < 400)
			{
				CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")
			}
			else
			{
				if(!is_user_alive(id))
					return PLUGIN_HANDLED
				
				set_user_maxspeed(id, 350.0)
				CromChat(id, "!g[hS Shop] !nYou have bought Speed with !g400 hS$")
				cs_get_user_money(money - 400)
			}
		}
		case 3:
		{
			new money = cs_get_user_money(id)
			if(money < 300)
			{
				CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")
			}
			else
			{
				give_item(id,"weapon_tmp")
				cs_set_user_bpammo(id, CSW_TMP ,30)
				cs_get_user_money(money - 300)
			}
		}
		case 4:
		{
			if(!is_user_alive(id))
				return PLUGIN_HANDLED
			
			// Check is already in godmode
			if(!godmode[id]) 
			{
				new money = cs_get_user_money(id)
				if(money < 800)
				{
					CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")
				}
				else
				{
					// Set godmode
					set_pev(id,pev_takedamage,DAMAGE_NO)
					godmode[id] = true
					set_task(20.0, "removeGodmode", id+1332)
					CromChat(id, "!g[hS Shop] !nYou have bought Immortality for !g800 hS$")
					cs_get_user_money(money - 800)
				}
			}
			else
			{
				CromChat(id, "!g[hS Shop] !nYou aready have Immortality")
			}
			
		}
		case 5:
		{
			if(!is_user_alive(id))
				return PLUGIN_HANDLED
			new money = cs_get_user_money(id)
			if(money < 500)
			{
				CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")	
			}
			else
			{
				new health = get_user_health(id);
				if( health != 100 )
				{
					set_user_health(id, 100);
					set_user_armor(id, 100);
					CromChat(id, "!g[hS Shop]!n You have bought Full Health with !g150 hS$");
					cs_get_user_money(money - 500)
				}
				else
				{
					CromChat(id, "!g[hS Shop]!n You already have 100HP.");  
				}
			}
			
		}
		case 6:
		{
			
			
			new money = cs_get_user_money(id)
			if(money < 500)
			{
				CromChat(id, "!g[hS Shop] !nYou have insufficient funds to buy this.")
			}
			else
			{
				respawn[id] = true
				ExecuteHamB(Ham_CS_RoundRespawn, id)
				client_print(id, print_chat, "Respawned")
				CromChat(id, "!g[hS Shop] !nYou have bought Respawn for !g500 hS$")
				cs_get_user_money(money - 500)
			}
			
		}
		case MENU_EXIT:
		{
			CromChat(id, "!g[hS Shop] !nThank you for buying from the shop!")
		}
	}
	return PLUGIN_HANDLED;
}
public removeGodmode( id )
{
	id -= 1332
	set_pev(id,pev_takedamage,DAMAGE_AIM)
	CromChat(id, "!g[hS Shop] !nYour Immortality has ended!")
}
EDIT: on the plugin you made, it shows me only 1. Respawn and gives me grenades!
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 01-23-2020 at 18:02.
Nutu_ is offline