View Single Post
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-29-2012 , 12:23   Re: Give velocity when buy
Reply With Quote #5

Quote:
Originally Posted by xfire97 View Post
I want help not comments, i see the shop menu api dont help me in nothing because i dont understand pro scripting.
The API makes it easier to make shops, not harder.
For example:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <shop>

// enumerate our items
enum _:Items {
    
Item_Polen,
    
Item_Erva,
    
Item_Cogumelos,
    
Item_LSD,
    
Item_Cocaina,
    
Item_Heroina,
    
Item_Crack,
    
Item_Marijuana
};

// create the names for each
new const gItemNames[Items][] = {
    
"Polen",
    
"Erva",
    
"Cogumelos",
    
"LSD",
    
"Cocaina",
    
"Heroina",
    
"Crack",
    
"Marijuana"
};

// setup the short names of the items
new const gItemShortNames[Items][] = {
    
"polen",
    
"erva",
    
"cogumelos",
    
"lsd",
    
"cocaina",
    
"heroina",
    
"crack",
    
"marijuana"
};

// registered item id's
new gItems[Items];

public 
plugin_init() {
    
// prepare items
    
for(new 0Itemsi++) {
        
// register item to shop
        
gItems[i] = shop_add_item(gItemNames[i], gItemShortNames[i]);
    }
}

public 
CallbackItemAllowed(itemid) {
    
// get item constant from item id
    
for(new 0Itemsi++) {
        
// check if found item
        
if(gItems[i] == item) {
            
// can only use these items while alive
            
if(!is_user_alive(id)) {
                return 
SHOP_ITEM_DISABLED;
            }
            
            
// if an admin reserved item and not an admin
            
if((== Item_Heroina || == Item_Crack || == Item_Marijuana) && !access(idADMIN_RESERVATION)) {
                return 
SHOP_ITEM_DISABLED;
            }
            
            
// player is allowed this item
            
return SHOP_ITEM_ENABLED;
        }
    }
    
    
// player not allowed item, so hide item from menu
    
return SHOP_ITEM_HIDDEN;
}

public 
shop_item_selected(itemid) {
    
// find which item was selected, if one from this plugin
    
for(new 0Itemsi++) {
        
// check if found item
        
if(gItems[i] == item) {
            
// switch item for specific giving
            
switch(i) {
                case 
Item_Polen: {
                    
// handle selection
                    
set_user_health(idget_user_health(id) + 10);
                }
                case 
Item_Erva: {
                    
// handle selection
                    
set_user_health(idget_user_health(id) + 15);
                }
                case 
Item_Cogumelos: {
                    
// handle selection
                    
set_user_frags(idget_user_frags(id) + 1);
                }
                case 
Item_LSD: {
                    
// handle selection
                    
cs_set_user_money(idcs_get_user_money(id) + 750);
                }
                case 
Item_Cocaina: {
                    
// handle selection
                    
set_user_maxspeed(id310.0);
                }
                case 
Item_Heroina: {
                    
// handle selection
                    
set_user_maxspeed(id350.0);
                    
set_user_health(idget_user_health(id) + 25);
                }
                case 
Item_Crack: {
                    
// handle selection
                    
set_user_health(idget_user_health(id) + 25);
                    
cs_set_user_money(idcs_get_user_money(id) + 850);
                }
                case 
Item_Marijuana: {
                    
// handle selection
                    
set_user_maxspeed(id360.0);
                    
set_user_health(idget_user_health(id) + 30);
                    
cs_set_user_money(idcs_get_user_money(id) + 1000);
                }
            }
            
            
// found item, so don't look anymore
            
break;
        }
    }

Then just change these cvars:
Code:
shop_spawn_menu 1
shop_menu_title "\r[Drogas Menu]\yEscolhe a tua Droga:"
It takes away the part of having to know menus and all of that.
All you need to handle is preparing items and when player selects one.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline