Raised This Month: $51 Target: $400
 12% 

Auction House


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-21-2017 , 12:19   Auction House
Reply With Quote #1

Hey, I was trying to create an auction plugin in which players can submit items for sale but I failed. In this plugin you can submit weapons like AK47, M4A1 etc.. ( Only if you already own them ) with a specific price and time, if someone has enough money to buy that item he can buy (The person who submitted it can't), when time has expired the item should be removed from the Auction House. Thanks !

Here's the plugin I tried coding
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Auction House"
#define VERSION "1.0"
#define AUTHOR "DoNii"

new Array: g_AuctionItem;
new Array: 
g_AuctionPrice;

new 
g_AuctionMenu;

new const 
AVAILABLE_COMMANDS[][] = {
    
    
"say auction",
    
"say /auction",
    
"say_team auction",
    
"say_team /auction"
}

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_AuctionMenu menu_create"\rAuction Options""auction_handler" );

    
g_AuctionItem ArrayCreate(32)
    
g_AuctionPrice ArrayCreate(1)
    
    for (new 
isizeof AVAILABLE_COMMANDSi++)
    
register_clcmd(AVAILABLE_COMMANDS[i], "show_auction_menu");
    
}

public 
show_auction_menu(id) {
    
    
menu_additem(g_AuctionMenu"Open Auction House"__);
    
menu_additem(g_AuctionMenu"Submit An Item"__);
    
    
menu_setpropg_AuctionMenuMPROP_EXITMEXIT_ALL );
    
    if(
is_user_alive(id))
    
menu_display(idg_AuctionMenu0);
}

public 
auction_handler(idmenuitem) {
    
    switch(
item) {
        
    case 
0: {
            
            
OpenAuctionHouse(id)
        }
        
    case 
1: {
            
            
SubmitItem(id)
        }
    }
    
    return 
PLUGIN_HANDLED;
}

OpenAuctionHouse(id) {
    
    new 
menu menu_create"\rAvailable Items To Buy""auction_house_handler" );
    
    new 
szTemp15 ], buffer[128]
    
    for( new 
iArraySizeg_AuctionItem ); i++ ) {
        
ArrayGetStringg_AuctionItemiszTempcharsmaxszTemp ) );

        for ( 
ArraySize(g_AuctionPrice); i++; )     
        
formatex(buffer127"%s %d"szTempArrayGetCellg_AuctionPrice))
    }

    
menu_additem(menubuffer__);
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    if(
is_user_alive(id))
    
menu_display(idmenu0);
}

public 
auction_house_handler(idmenuitem) {

    switch(
item) {

    case 
0: {

            
client_print(idprint_chat"You Just Bought Deagle");
        }
    }
}

SubmitItem(id) {
    
    new 
menu menu_create"\rChoose The Item You Want To Submit For Auction""submit_handler" );
    
    
menu_additem(menu"Deagle"__)
    
menu_additem(menu"M4A1"__)
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    if(
is_user_alive(id))
    
menu_display(idmenu0);
}

public 
submit_handler(idmenuitem) {
    
    switch(
item) {
        
    case 
0: {
            
            if(!
user_has_weapon(idCSW_DEAGLE)) {
                
client_print(idprint_chat"You Can't Submit Items That You Don't Own");
                return 
PLUGIN_HANDLED;
            }
            
            
ArrayPushString(g_AuctionItem"Deagle")
            
ArrayPushCell(g_AuctionItem30)
            
            
ham_strip_weapon(id"weapon_deagle")
        }
        
    case 
1: {
            
            if(!
user_has_weapon(idCSW_M4A1)) {
                
client_print(idprint_chat"You Can't Submit Items That You Don't Own");
                return 
PLUGIN_HANDLED;
            }
            
            
ArrayPushString(g_AuctionItem"M4A1")
            
ArrayPushCell(g_AuctionItem50)
            
            
ham_strip_weapon(id"weapon_m4a1")
            
        }
    }
    
    return 
PLUGIN_HANDLED;
}

stock ham_strip_weapon(id,weapon[])
{
    if(!
equal(weapon,"weapon_",7)) return 0;
    
    new 
wId get_weaponid(weapon);
    if(!
wId) return 0;
    
    new 
wEnt;
    while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!
wEnt) return 0;
    
    if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
    
    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    
ExecuteHamB(Ham_Item_Kill,wEnt);
    
    
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
    
    return 
1;

__________________

Last edited by edon1337; 02-21-2017 at 13:04.
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-21-2017 , 15:21   Re: Auction House
Reply With Quote #2

PHP Code:


public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_AuctionMenu menu_create"\rAuction Options""auction_handler" );
    
menu_additem(g_AuctionMenu"Open Auction House"__);
    
menu_additem(g_AuctionMenu"Submit An Item"__);
    
menu_setpropg_AuctionMenuMPROP_EXITMEXIT_ALL );

    
g_AuctionItem ArrayCreate(32)
    
g_AuctionPrice ArrayCreate(1)
    
    for (new 
isizeof AVAILABLE_COMMANDSi++)
    
register_clcmd(AVAILABLE_COMMANDS[i], "show_auction_menu");
    
}

public 
show_auction_menu(id) {
    if(
is_user_alive(id))
    
menu_display(idg_AuctionMenu0);


bro i already told you to create the whole menu in plugin init since its a constant menu...



PHP Code:
SubmitItem(id) {
    
    new 
menu menu_create"\rChoose The Item You Want To Submit For Auction""submit_handler" );
    
    new 
sWeapons[32], wnum
    get_user_weapons
(idsWeaponswnum)
    
    if(
wnum == && sWeapons[0] == CSW_KNIFE || !wnum)
    return;
    
    new 
sWpn[24];
    
    for(new 
0wnumi++)
    {
        if(
sWeapon[i] == CSW_KNIFE) continue;
        
get_weaponname(sWeapons[i], sWpncharsmax(sWpn))
    
replace(sWpncharsmax(sWpn), "weapon_""")
    
menu_additem(menusWpnsWeapons[i], _)
    }
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    if(
is_user_alive(id))
    
menu_display(idmenu0);

here how to SubmitItem player items in a menu...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-21-2017 at 15:42.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



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 00:48.


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