Quote:
Originally Posted by xfire97
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 i = 0; i < Items; i++) {
// register item to shop
gItems[i] = shop_add_item(gItemNames[i], gItemShortNames[i]);
}
}
public CallbackItemAllowed(item, id) {
// get item constant from item id
for(new i = 0; i < Items; i++) {
// 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((i == Item_Heroina || i == Item_Crack || i == Item_Marijuana) && !access(id, ADMIN_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(item, id) {
// find which item was selected, if one from this plugin
for(new i = 0; i < Items; i++) {
// check if found item
if(gItems[i] == item) {
// switch item for specific giving
switch(i) {
case Item_Polen: {
// handle selection
set_user_health(id, get_user_health(id) + 10);
}
case Item_Erva: {
// handle selection
set_user_health(id, get_user_health(id) + 15);
}
case Item_Cogumelos: {
// handle selection
set_user_frags(id, get_user_frags(id) + 1);
}
case Item_LSD: {
// handle selection
cs_set_user_money(id, cs_get_user_money(id) + 750);
}
case Item_Cocaina: {
// handle selection
set_user_maxspeed(id, 310.0);
}
case Item_Heroina: {
// handle selection
set_user_maxspeed(id, 350.0);
set_user_health(id, get_user_health(id) + 25);
}
case Item_Crack: {
// handle selection
set_user_health(id, get_user_health(id) + 25);
cs_set_user_money(id, cs_get_user_money(id) + 850);
}
case Item_Marijuana: {
// handle selection
set_user_maxspeed(id, 360.0);
set_user_health(id, get_user_health(id) + 30);
cs_set_user_money(id, cs_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.
__________________