Raised This Month: $32 Target: $400
 8% 

money shop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-23-2020 , 12:27   money shop
Reply With Quote #1

I've tried to do it by myself and it worked but the only problem i got was that the money didnt took from player when he bought something, i wanted to solve by myself but i had to reinstall my windows and i forgot to save it and now its gone, and since it gave me headache trying to fix it, maybe its simplier for you, i just need a simple shop with money

cmd /shop

1. Grenades (he, flash) - 400$
2. Gravity (a higher gravity like 700,650)(for 30 seconds) - 600$
3. Speed (a bit faster, for 100 seconds as well) - 400$
4. TMP (ct only) - 300$
5. Immorality (godmode, 20 seconds) - 800$
6. Health: 150HP - 500$
7. Armor+Helmet - 200$
8. Invisibility (not 100%)(30 seconds) - 700$
9. Respawn, 700$
10. Random Item (here i'd like if possible to give something random like noclip (for few seconds), godmode (for few seconds), double jump, and fun stuff, and VIP (flag t, for 24 hours, with 1% chance ) - 6500$

thanks
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-23-2020 , 13:54   Re: money shop
Reply With Quote #2

This will do the trick - https://forums.alliedmods.net/showthread.php?t=284603

You can quickly and easily add new items in the shop if you already know how to script.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-23-2020 , 17:07   Re: money shop
Reply With Quote #3

Plugin is finished, should be tested. Waiting for feedback.

Spoiler
__________________

Last edited by Napoleon_be; 01-26-2020 at 08:10.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-24-2020 , 07:17   Re: money shop
Reply With Quote #5

I updated my code, it should be working now. Finished it all while i was at it. Keep me uptodate and notify me if bugs occure.
__________________

Last edited by Napoleon_be; 01-24-2020 at 08:04.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-24-2020 , 13:20   Re: money shop
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#define CC_COLORS_TYPE CC_COLORS_SHORT
#include <cromchat> 


#define PLUGIN "Shop"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

#define TASKGRAV 15643
#define TASKSPEED 6451
#define TASKINV 2156
#define TASKGOD 89641

new const szMenuItems[][] = {
    
"Grenades \r(2 grenades)",
    
"Gravity \r(30 sec)",
    
"Speed \r(30 sec)",
    
"TMP \r(CT Only)",
    
"Immortality\r (20 sec)",
    
"Health \r(+150HP)",
    
"Kevlar+Helmet \r(100AP)",
    
"Respawn \r(Dead only)",
    
"Invisibility \r(30 sec)",
    
"Full Health \r(100HP)",
    
"Big Surprise \r(Random) (UNAVAIBLE)"
    
};

new 
iMenuPrices[] = {
    
400,
    
600,
    
400,
    
300,
    
800,
    
500,
    
200,
    
700,
    
700,
    
100,
    
7500
};

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /shop""ShowShop");
    
    
register_event("CurWeapon""WeaponChange""be""1=1");
}

public 
WeaponChange(id// Used to maintain the maxspeed when player switches weapons.
{
    if(
task_exists(id TASKSPEED))
    {
        
set_user_maxspeed(id400.0);
    }
}

public 
client_disconnect(id)
{
    if(
task_exists(id TASKGRAV)) 
        
remove_task(id TASKGRAV);
    
    if(
task_exists(id TASKSPEED))
        
remove_task(id TASKSPEED);
    
    if(
task_exists(id TASKINV))
        
remove_task(id TASKINV);
    
    if(
task_exists(id TASKGOD))
        
remove_task(id TASKGOD);
}

public 
ShowShop(id)
{
    if(
is_user_alive(id))
    {
        new 
szTemp[250];
        new 
menu menu_create("\yhS | DeathRun \rShop Menu""ShopHandler");
        
        for(new 
isizeof(szMenuItems); i++)
        {
            
formatex(szTempcharsmax(szTemp), "%s \y%i hS$"szMenuItems[i], iMenuPrices[i]);
            
menu_additem(menuszTemp);
        }
        
menu_display(idmenu);
    }
}

public 
ShopHandler(idmenuitem)
{
    switch(
item) {
        case 
0:
        {
            
give_item(id"weapon_hegrenade");
            
give_item(id"weapon_flashbang");
            
CromChat(id"!g[hS Shop] !nYou have bought Grenades Pack")
        }
        case 
1:
        {
            if(!
task_exists(id TASKGRAV))
            {
                new 
Float:fGravity 650.0 800.0;
                
set_user_gravity(idFloat:fGravity);
                
set_task(30.0"ResetGravity"id TASKGRAV);
                
CromChat(id"!g[hS Shop] !nYou have purchased Gravity for 30 seconds")
            }
            else
            {
                
CromChat(id"!g[hS Shop] !nYou already have Gravity")
            }
        }
        case 
2:
        {
            if(!
task_exists(id TASKSPEED))
            {
                
set_user_maxspeed(id400.0);
                
set_task(30.0"ResetSpeed"id TASKSPEED);
                
CromChat(id"!g[hS Shop] !nYou have purchased speed for 30 seconds")
            }
            else
            {
                
CromChat(id"!g[hS Shop] !nYou already have speed")
            }
        }
        case 
3:
        {
            if(
cs_get_user_team(id) == CS_TEAM_CT)
            {
                
give_item(id"weapon_tmp");
                
cs_set_user_bpammo(idCSW_TMP90);
                
CromChat(id"!g[hS Shop] !nYou have purchased TMP")
            }
            else
            {
                
CromChat(id"!g[hS Shop] !tTerrorists !ncannot buy this item")
            }
        }
        case 
4:
        {
            if(!
task_exists(id TASKGOD))
            {
                
set_user_godmode(id1);
                
set_task(20.0"ResetGodmode"id TASKGOD);
                
CromChat(id"!g[hS Shop] !nYou have purchased Immortality for 20 seconds")
            }
            else
            {
                
CromChat(id"!g[hS Shop] !nYou already have Immortality")
            }
        }
        case 
5:
        {
            
set_user_health(id, (get_user_health(id) + 150))
            
CromChat(id"!g[hS Shop] !nYou have purchased Health !t+150 HP")
        }
        case 
6:
        {
            
set_user_armor(id100);
            
CromChat(id"!g[hS Shop] !nYou have purchased Armor + Helmet !t+100 AP")
        }
        case 
7:
        {
            if(!
is_user_alive(id))
            {
                
ExecuteHamB(Ham_CS_RoundRespawnid);
                
CromChat(id"!g[hS Shop] !nYou have purchased Respawn")
            }
            else
            {
                
CromChat(id"!g[hS Shop] !nYou are not dead, you can't buy Respawn if you're alive")
            }
        }
        case 
8:
        {
            if(!
task_exists(id TASKINV))
            {
                
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha50);
                
set_task(30.0"ResetInvis"id TASKINV);
                
CromChat(id"!g[hS Shop] !nYou have purchased Invisibility for 30 seconds")
            }
            else
            {
                
CromChat(id"!g[hS Shop] !nYou already have Invisibility")
            }
        }
        case 
9:
        {
            
set_user_health(id100);
            
CromChat(id"!g[hS Shop] !nYou have purchased Full Health !t+100 HP")
        }
        case 
10:
        {
            
CromChat(id"!g[hS Shop] !nThis item is unavaible yet")
        }
    }
    (
cs_get_user_money(id) >= iMenuPrices[item] ? cs_set_user_money(idcs_get_user_money(id) - iMenuPrices[item]) : CromChat(id"!g[hS Shop]!n You have insufficient funds to buy this."));
    
menu_destroy(menu)
}

public 
ResetGravity(id)
{
    
id -= TASKGRAV;
    if(
is_user_connected(id) && task_exists(id TASKGRAV))
    {
        
set_user_gravity(id);
    }
}

public 
ResetSpeed(id)
{
    
id -= TASKSPEED;
    if(
is_user_connected(id) && task_exists(id TASKSPEED))
    {
        
set_user_maxspeed(id);
    }
}

public 
ResetGodmode(id)
{
    
id -= TASKGOD;
    if(
is_user_connected(id) && task_exists(id TASKGOD))
    {
        
set_user_godmode(id);
    }
}

public 
ResetInvis(id)
{
    
id -= TASKINV;
    if(
is_user_connected(id) && task_exists(id TASKSPEED))
    {
        
set_user_rendering(id);
    }

okay i did some changes and here are the bugs
1. when speed is finished, player can't move anymore!
2. when i dont have enough cash, it still gives me the items!
3. at Big Surpirse, hopefully OciXCrom can help because i saw Roll the Dice (rtd) and maybe it can be added here, i dont want to add /rtd to server, for all the players, only when someone buys form shop Big Surprise, to get random such as in rtd plugin! if it work and its not that hard to make, if not then leave it so until i got some new ideas!

thanks amigo!
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 01-24-2020 at 13:27.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-24-2020 , 13:42   Re: money shop
Reply With Quote #7

1) Should be fixed.
2) That's weird, i tested it and it worked fine with me.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-26-2020 , 08:08   Re: money shop
Reply With Quote #8

Updated my code again, removed is_user_connected() checks in the reset functions since i already remove tasks in client_disconnect(). Also if u modify the plugin, please leave the "if(is_user_alive(id))" check in the shophandler since the player needs to be alive to receive an item. If u don't do this, items will be given to a dead player which is not possible, and money will get decreased of the player buying from the shop.
__________________

Last edited by Napoleon_be; 01-26-2020 at 08:10.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-26-2020 , 08:12   Re: money shop
Reply With Quote #9

Here's a rather simplified format I made a while ago that you can take advantage of.
Pay attention to how I defined the list that holds the items.

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fun>
#include <hamsandwich>

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"

enum _:ItemInfo
{
    
Name[32],
    
Price,
    
CsTeams:Team
}

new 
g_eItems[][ItemInfo] =
{
    { 
"AWP {Sniper} sus 1 patron!"16000CS_TEAM_CT },
    { 
"Deagle sus 1 patron!"10000CS_TEAM_CT },
    { 
"Edna granata!"5000CS_TEAM_UNASSIGNED },
    { 
"Noclip"16000CS_TEAM_CT },
    { 
"Godmode"16000CS_TEAM_CT },
    { 
"Invisible"16000CS_TEAM_CT }
}

new 
bool:g_bInvis[33]

public 
plugin_init()
{
    
register_plugin("Simple Shop"PLUGIN_VERSION"OciXCrom")
    
register_cvar("CRXSimpleShop"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawn"1)
    
register_clcmd("say /shop""Cmd_Shop")
    
register_clcmd("say_team /shop""Cmd_Shop")
    
CC_SetPrefix("&x04[HNS Shop]")
}

public 
plugin_precache()
    
precache_sound(SOUND_BUY)

public 
client_putinserver(id)
    
g_bInvis[id] = false

public OnPlayerSpawn(id)
{
    if(
is_user_alive(id) && g_bInvis[id])
    {
        
g_bInvis[id] = false
        set_user_rendering
(idkRenderFxNone000kRenderNormal0)
    }
}

public 
Cmd_Shop(id)
{
    if(!
is_user_alive(id))
        
CC_SendMessage(id"You need to be alive.")
    else
    {
        new 
szItem[64], iMoney cs_get_user_money(id)
        
formatex(szItemcharsmax(szItem), "\rHNS Shop^nMoney: \y%i"iMoney)

        new 
iMenu menu_create(szItem"Shop_Handler")

        for(new 
CsTeams:iTeam cs_get_user_team(id), isizeof(g_eItems); i++)
        {
            if(
g_eItems[i][Team] == CS_TEAM_UNASSIGNED || g_eItems[i][Team] == iTeam)
                
formatex(szItemcharsmax(szItem), "%s %s[%i$]"g_eItems[i][Name], iMoney >= g_eItems[i][Price] ? "\r" "\d"g_eItems[i][Price])
            else
                
formatex(szItemcharsmax(szItem), "\d%s \r[%s ONLY]"g_eItems[i][Name], g_eItems[i][Team] == CS_TEAM_CT "CT" "T")

            
menu_additem(iMenuszItem)
        }

        
menu_display(idiMenu)
    }

    return 
PLUGIN_HANDLED
}

public 
Shop_Handler(idiMenuiItem)
{
    if(
iItem != MENU_EXIT && is_user_alive(id))
    {
        new 
iMoney cs_get_user_money(id)

        if(
g_eItems[iItem][Team] != CS_TEAM_UNASSIGNED && cs_get_user_team(id) != g_eItems[iItem][Team])
            
CC_SendMessage(id"This item is not available for your team.")
        else if(
iMoney g_eItems[iItem][Price])
            
CC_SendMessage(id"You don't have enough money to purchase this item.")
        else
        {
            
cs_set_user_money(idiMoney g_eItems[iItem][Price])
            
CC_SendMessage(id"You have bought ^3%s ^1for ^4%i$"g_eItems[iItem][Name], g_eItems[iItem][Price])
            
emit_sound(idCHAN_ITEMSOUND_BUY1.0ATTN_NORM0PITCH_NORM)

            switch(
iItem)
            {
                case 
0:
                {
                    
cs_set_weapon_ammo(give_item(id"weapon_awp"), 1)
                    
cs_set_user_bpammo(idCSW_AWP0)
                }
                case 
1:
                {
                    
cs_set_weapon_ammo(give_item(id"weapon_deagle"), 1)
                    
cs_set_user_bpammo(idCSW_DEAGLE0)
                }
                case 
2give_item(id"weapon_hegrenade")
                case 
3set_user_noclip(id1)
                case 
4set_user_godmode(id1)
                case 
5:
                {
                    
g_bInvis[id] = true
                    set_user_rendering
(idkRenderFxNone000kRenderTransAlpha0)
                }
            }
        }
    }

    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED

__________________

Last edited by OciXCrom; 01-26-2020 at 08:16.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-26-2020 , 08:18   Re: money shop
Reply With Quote #10

Looks good, thanks for sharing, will defenitely use this in the future.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode