Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- INCLUDE shop.inc
- enum _:TEAMS
- {
- TEAM_TT = 1,
- TEAM_CT,
- TEAM_ALL
- }
- native shop_add_item(const name[], cost, team, const function[])
- native get_user_points(id)
- native set_user_points(id, puntos)
- */
- #include <amxmodx>
- #define PLUGIN "SHOP"
- #define VERSION "1.0 FIX 1"
- #define AUTHOR "Sugisaki"
- #define MAX_ITEM 20
- enum _:ITEMS
- {
- ITEM_NAME[32],
- ITEM_COST,
- ITEM_TEAM,
- ITEM_FORWARD[32],
- ITEM_FUNC_ID,
- ITEM_PLUGIN_ID
- }
- enum _:TEAMS
- {
- TEAM_TT = 1,
- TEAM_CT,
- TEAM_ALL
- }
- new points[33]
- new const AVAILABLE[] = "y"
- new const UNAVAILABLE[] = "r"
- new g_szItem[MAX_ITEM][ITEMS], g_TotalItems, g_Item_Team_count[TEAMS]
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_clcmd("chooseteam", "open_shop")
- }
- public client_connect(id)
- {
- points[id] = 0
- }
- public client_disconnect(id)
- {
- points[id] = 0
- }
- public plugin_natives()
- {
- register_native("shop_add_item", "_native_add_item")
- register_native("get_user_points", "_native_get_user_points")
- register_native("set_user_points", "_native_set_user_points")
- }
- public _native_add_item(pid, par)
- {
- // shop_add_item(const name[], cost, team, const function[])
- if(g_TotalItems >= MAX_ITEM)
- {
- log_amx("[SHOP] Maximo de items ( %i ) alcanzado, Modifica el plugin %s", MAX_ITEM, PLUGIN)
- return PLUGIN_HANDLED
- }
- get_string(1, g_szItem[g_TotalItems][ITEM_NAME], 31)
- get_string(4, g_szItem[g_TotalItems][ITEM_FORWARD], 31)
- g_szItem[g_TotalItems][ITEM_COST] = get_param(2)
- g_szItem[g_TotalItems][ITEM_TEAM] = get_param(3)
- g_szItem[g_TotalItems][ITEM_PLUGIN_ID] = pid
- g_szItem[g_TotalItems][ITEM_FUNC_ID] = get_func_id(g_szItem[g_TotalItems][ITEM_FORWARD], pid)
- g_TotalItems++
- g_Item_Team_count[get_param(3)] ++
- return PLUGIN_CONTINUE
- }
- public open_shop(id)
- {
- new team = get_user_team(id)
- if(!(g_Item_Team_count[team]) && !(g_Item_Team_count[TEAM_ALL]))
- {
- client_print(id, print_chat, "No hay Items para tu equipo")
- return PLUGIN_HANDLED
- }
- static item[128], num[3]
- formatex(item, charsmax(item), "\yTienda^n\wPuntos disponibles \r%i", points[id])
- new menu = menu_create(item, "buymenu_handle")
- for(new i = 0; i < g_TotalItems; i++)
- {
- if(team == g_szItem[i][ITEM_TEAM] || g_szItem[i][ITEM_TEAM] == TEAM_ALL)
- {
- formatex(item, charsmax(item), "\w%s [\%s%i Pts\w]", g_szItem[i][ITEM_NAME], (points[id] < g_szItem[i][ITEM_COST] ? UNAVAILABLE : AVAILABLE), g_szItem[i][ITEM_COST]);
- num_to_str(i, num, charsmax(num));
- menu_additem(menu, item, num);
- }
- }
- menu_display(id, menu)
- return PLUGIN_HANDLED
- }
- public buymenu_handle(id, menu, item)
- {
- if(item == MENU_EXIT || !is_user_alive(id) || !is_user_connected(id))
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- new access, callback, num[3];
- menu_item_getinfo(menu, item, access, num, charsmax(num), _, _, callback);
- menu_destroy(menu);
- new itemid = str_to_num(num);
- //new money = cs_get_user_money(id)
- if(g_szItem[itemid][ITEM_COST] > points[id])
- {
- client_print(id, print_chat, "[TIENDA] Puntos insuficientes")
- return PLUGIN_HANDLED
- }
- points[id] -= g_szItem[itemid][ITEM_COST]
- /*
- new ret, g_forward
- g_forward = CreateMultiForward(g_szItem[itemid][ITEM_FORWARD], ET_STOP, FP_CELL, FP_STRING)
- ExecuteForward(g_forward, ret, id, g_szItem[itemid][ITEM_NAME])
- DestroyForward(g_forward)
- if(ret == PLUGIN_HANDLED) return PLUGIN_HANDLED
- cs_set_user_money(id, money- g_szItem[itemid][ITEM_COST])*/
- callfunc_begin_i(g_szItem[itemid][ITEM_FUNC_ID], g_szItem[itemid][ITEM_PLUGIN_ID])
- callfunc_push_int(id)
- callfunc_end()
- return PLUGIN_HANDLED
- }
- public _native_get_user_points(pid, pr)
- {
- return points[get_param(1)]
- }
- public _native_set_user_points(pid, pr)
- {
- points[get_param(1)] = get_param(2)
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement