Available Vip extra Item Discounts

Unpaid Requests, Public Plugins
User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#21

Post by Mark » 5 years ago

Raheem wrote: 5 years ago So if anyone need to add discount for VIPs on any item he should follow the following:

1. Update your ze_items_manager.sma with:
    1. #include <zombie_escape>
    2.  
    3. // Setting File
    4. new const ZE_EXTRAITEM_FILE[] = "ze_extraitems.ini"
    5.  
    6. // Defines
    7. #define MENU_PAGE_ITEMS g_iMenuData[id]
    8.  
    9. // Const
    10. const OFFSET_CSMENUCODE = 205
    11.  
    12. // Forwards
    13. enum _:TOTAL_FORWARDS
    14. {
    15.     FW_ITEM_SELECT_PRE = 0,
    16.     FW_ITEM_SELECT_POST
    17. }
    18.  
    19. new g_iForwards[TOTAL_FORWARDS],
    20.     g_iForwardReturn
    21.  
    22. // Variables
    23. new Array:g_szItemRealName,
    24.     Array:g_szItemName,  
    25.     Array:g_iItemCost,
    26.     Array:g_iItemLimit
    27.  
    28. new g_iItemCount,
    29.     g_szAdditionalMenuText[32],
    30.     g_iMenuData[33],
    31.     bool:g_bHasDiscount[MAX_EXTRA_ITEMS],
    32.     Float:g_flDiscountValue[MAX_EXTRA_ITEMS]
    33.  
    34. public plugin_init()
    35. {
    36.     register_plugin("[ZE] Items Manager", ZE_VERSION, AUTHORS)
    37.    
    38.     // Commands
    39.     register_clcmd("say /items", "Cmd_Items")
    40.    
    41.     // Forwards (In Pre Return Values important)
    42.     g_iForwards[FW_ITEM_SELECT_PRE] = CreateMultiForward("ze_select_item_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
    43.     g_iForwards[FW_ITEM_SELECT_POST] = CreateMultiForward("ze_select_item_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
    44. }
    45.  
    46. public plugin_natives()
    47. {
    48.     register_native("ze_register_item", "native_ze_register_item")
    49.     register_native("ze_show_items_menu", "native_ze_show_items_menu")
    50.     register_native("ze_force_buy_item", "native_ze_force_buy_item")
    51.     register_native("ze_get_item_id", "native_ze_get_item_id")
    52.     register_native("ze_get_item_cost", "native_ze_get_item_cost")
    53.     register_native("ze_add_text_to_item", "native_ze_add_text_to_item")
    54.     register_native("ze_get_item_limit", "native_ze_get_item_limit")
    55.     register_native("ze_is_valid_itemid", "native_ze_is_valid_itemid")
    56.     register_native("ze_get_item_name", "native_ze_get_item_name")
    57.     register_native("ze_set_vip_discount", "native_ze_set_vip_discount", 1)
    58.     register_native("ze_has_vip_discount", "native_ze_has_vip_discount", 1)
    59.     register_native("ze_has_vip_discount", "native_ze_has_vip_discount", 1)
    60.     register_native("ze_get_item_discount", "native_ze_get_item_discount", 1)
    61.    
    62.     g_szItemRealName = ArrayCreate(32, 1)
    63.     g_szItemName = ArrayCreate(32, 1)
    64.     g_iItemCost = ArrayCreate(1, 1)
    65.     g_iItemLimit = ArrayCreate(1, 1)
    66. }
    67.  
    68. public client_disconnected(id)
    69. {
    70.     MENU_PAGE_ITEMS = 0
    71. }
    72.  
    73. public Cmd_Items(id)
    74. {
    75.     if (!is_user_alive(id))
    76.         return
    77.    
    78.     Show_Items_Menu(id)
    79. }
    80.  
    81. // Items Menu
    82. Show_Items_Menu(id)
    83. {
    84.     static menu[128], name[32], cost, transkey[64]
    85.     new menuid, index, itemdata[2]
    86.    
    87.     // Title
    88.     formatex(menu, charsmax(menu), "%L:\r", id, "BUY_EXTRAITEM")
    89.     menuid = menu_create(menu, "Extra_Items_Menu")
    90.    
    91.     // Item List
    92.     for (index = 0; index < g_iItemCount; index++)
    93.     {
    94.         // Additional text to display
    95.         g_szAdditionalMenuText[0] = 0
    96.        
    97.         // Execute item select attempt forward
    98.         ExecuteForward(g_iForwards[FW_ITEM_SELECT_PRE], g_iForwardReturn, id, index, 0)
    99.        
    100.         // Show item to player?
    101.         if (g_iForwardReturn >= ZE_ITEM_DONT_SHOW)
    102.             continue;
    103.        
    104.         // Add Item Name and Cost
    105.         ArrayGetString(g_szItemName, index, name, charsmax(name))
    106.         cost = ArrayGetCell(g_iItemCost, index)
    107.        
    108.         // ML support for item name
    109.         formatex(transkey, charsmax(transkey), "ITEMNAME %s", name)
    110.         if (GetLangTransKey(transkey) != TransKey_Bad) formatex(name, charsmax(name), "%L", id, transkey)
    111.        
    112.         // Item available to player?
    113.         if (g_iForwardReturn >= ZE_ITEM_UNAVAILABLE)
    114.             formatex(menu, charsmax(menu), "\d%s %d %s", name, cost, g_szAdditionalMenuText)
    115.         else
    116.             formatex(menu, charsmax(menu), "%s \y%d \w%s", name, cost, g_szAdditionalMenuText)
    117.        
    118.         itemdata[0] = index
    119.         itemdata[1] = 0
    120.         menu_additem(menuid, menu, itemdata)
    121.     }
    122.    
    123.     // No items to display?
    124.     if (menu_items(menuid) <= 0)
    125.     {
    126.         ze_colored_print(id, "%L", id, "NO_EXTRA_ITEMS")
    127.         menu_destroy(menuid)
    128.         return;
    129.     }
    130.    
    131.     // Back - Next - Exit
    132.     formatex(menu, charsmax(menu), "%L", id, "BACK")
    133.     menu_setprop(menuid, MPROP_BACKNAME, menu)
    134.     formatex(menu, charsmax(menu), "%L", id, "NEXT")
    135.     menu_setprop(menuid, MPROP_NEXTNAME, menu)
    136.     formatex(menu, charsmax(menu), "%L", id, "EXIT")
    137.     menu_setprop(menuid, MPROP_EXITNAME, menu)
    138.    
    139.     // If remembered page is greater than number of pages, clamp down the value
    140.     MENU_PAGE_ITEMS = min(MENU_PAGE_ITEMS, menu_pages(menuid)-1)
    141.    
    142.     // Fix for AMXX custom menus
    143.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    144.     menu_display(id, menuid, MENU_PAGE_ITEMS)
    145. }
    146.  
    147. // Items Menu
    148. public Extra_Items_Menu(id, menuid, item)
    149. {
    150.     // Menu was closed
    151.     if (item == MENU_EXIT)
    152.     {
    153.         MENU_PAGE_ITEMS = 0
    154.         menu_destroy(menuid)
    155.         return PLUGIN_HANDLED;
    156.     }
    157.    
    158.     // Remember items menu page
    159.     MENU_PAGE_ITEMS = item / 7
    160.    
    161.     // Dead players are not allowed to buy items
    162.     if (!is_user_alive(id))
    163.     {
    164.         menu_destroy(menuid)
    165.         return PLUGIN_HANDLED;
    166.     }
    167.    
    168.     // Retrieve item id
    169.     new itemdata[2], dummy, itemid
    170.     menu_item_getinfo(menuid, item, dummy, itemdata, charsmax(itemdata), _, _, dummy)
    171.     itemid = itemdata[0]
    172.    
    173.     // Attempt to buy the item
    174.     Buy_Item(id, itemid)
    175.     menu_destroy(menuid)
    176.     return PLUGIN_HANDLED;
    177. }
    178.  
    179. // Buy Item
    180. Buy_Item(id, itemid, ignorecost = 0)
    181. {
    182.     // Execute item select attempt forward
    183.     ExecuteForward(g_iForwards[FW_ITEM_SELECT_PRE], g_iForwardReturn, id, itemid, ignorecost)
    184.    
    185.     // Item available to player?
    186.     if (g_iForwardReturn >= ZE_ITEM_UNAVAILABLE)
    187.         return;
    188.    
    189.     // Execute item selected forward
    190.     ExecuteForward(g_iForwards[FW_ITEM_SELECT_POST], g_iForwardReturn, id, itemid, ignorecost)
    191. }
    192.  
    193. // Natives
    194. public native_ze_register_item(plugin_id, num_params)
    195. {
    196.     new szItem_Name[32], iItem_Cost, iItem_Limit
    197.    
    198.     // Get the Data from first Parameter in the native (Item Name)
    199.     get_string(1, szItem_Name, charsmax(szItem_Name))
    200.    
    201.     // Get the Second Parameter (Item Cost)
    202.     iItem_Cost = get_param(2)
    203.    
    204.     // Get limit third parameter
    205.     iItem_Limit = get_param(3)
    206.    
    207.     if (strlen(szItem_Name) < 1)
    208.     {
    209.         // Can't leave item name empty
    210.         log_error(AMX_ERR_NATIVE, "[ZE] Can't register item with an empty name")
    211.         return ZE_WRONG_ITEM // Same as return -1
    212.     }
    213.    
    214.     new iIndex, szItemName[32]
    215.    
    216.     // Loop from 0 to max items amount
    217.     for (iIndex = 0; iIndex < g_iItemCount; iIndex++)
    218.     {
    219.         ArrayGetString(g_szItemRealName, iIndex, szItemName, charsmax(szItemName))
    220.        
    221.         if (equali(szItem_Name, szItemName))
    222.         {
    223.             log_error(AMX_ERR_NATIVE, "[ZE] Item already registered (%s)", szItemName)
    224.             return ZE_WRONG_ITEM; // Return -1
    225.         }
    226.     }
    227.    
    228.     // Load settings from extra items file
    229.     new szItemRealName[32]
    230.     copy(szItemRealName, charsmax(szItemRealName), szItem_Name)
    231.     ArrayPushString(g_szItemRealName, szItemRealName)
    232.    
    233.     // Name
    234.     if (!amx_load_setting_string(ZE_EXTRAITEM_FILE, szItemRealName, "NAME", szItem_Name, charsmax(szItem_Name)))
    235.         amx_save_setting_string(ZE_EXTRAITEM_FILE, szItemRealName, "NAME", szItem_Name)
    236.     ArrayPushString(g_szItemName, szItem_Name)
    237.    
    238.     // Cost
    239.     if (!amx_load_setting_int(ZE_EXTRAITEM_FILE, szItemRealName, "COST", iItem_Cost))
    240.         amx_save_setting_int(ZE_EXTRAITEM_FILE, szItemRealName, "COST", iItem_Cost)
    241.     ArrayPushCell(g_iItemCost, iItem_Cost)
    242.    
    243.     // Limit
    244.     if (!amx_load_setting_int(ZE_EXTRAITEM_FILE, szItemRealName, "LIMIT", iItem_Limit))
    245.         amx_save_setting_int(ZE_EXTRAITEM_FILE, szItemRealName, "LIMIT", iItem_Limit)
    246.     ArrayPushCell(g_iItemLimit, iItem_Limit)
    247.    
    248.     g_iItemCount++
    249.     return g_iItemCount - 1
    250. }
    251.  
    252. public native_ze_show_items_menu(plugin_id, num_params)
    253. {
    254.     new id = get_param(1)
    255.    
    256.     if (!is_user_connected(id))
    257.     {
    258.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    259.         return false;
    260.     }
    261.    
    262.     Cmd_Items(id)
    263.     return true
    264. }
    265.  
    266. public native_ze_force_buy_item(plugin_id, num_params)
    267. {
    268.     new id = get_param(1)
    269.    
    270.     if (!is_user_connected(id))
    271.     {
    272.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    273.         return false;
    274.     }
    275.    
    276.     new item_id = get_param(2)
    277.    
    278.     if (item_id < 0 || item_id >= g_iItemCount)
    279.     {
    280.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid item id (%d)", item_id)
    281.         return false;
    282.     }
    283.    
    284.     new ignorecost = get_param(3)
    285.    
    286.     Buy_Item(id, item_id, ignorecost)
    287.     return true;
    288. }
    289.  
    290. public native_ze_get_item_id(plugin_id, num_params)
    291. {
    292.     new szRealName[32]
    293.     get_string(1, szRealName, charsmax(szRealName))
    294.  
    295.     new index, szItemName[32]
    296.    
    297.     for (index = 0; index < g_iItemCount; index++)
    298.     {
    299.         ArrayGetString(g_szItemRealName, index, szItemName, charsmax(szItemName))
    300.        
    301.         if (equali(szRealName, szItemName))
    302.             return index
    303.     }
    304.    
    305.     return ZE_WRONG_ITEM
    306. }
    307.  
    308. public native_ze_get_item_cost(plugin_id, num_params)
    309. {
    310.     new item_id = get_param(1)
    311.    
    312.     if (item_id < 0 || item_id >= g_iItemCount)
    313.     {
    314.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid item id (%d)", item_id)
    315.         return ZE_WRONG_ITEM;
    316.     }
    317.    
    318.     return ArrayGetCell(g_iItemCost, item_id);
    319. }
    320.  
    321. public native_ze_add_text_to_item(plugin_id, num_params)
    322. {
    323.     new szText[32]
    324.     get_string(1, szText, charsmax(szText))
    325.     format(g_szAdditionalMenuText, charsmax(g_szAdditionalMenuText), "%s%s", g_szAdditionalMenuText, szText)
    326. }
    327.  
    328. public native_ze_get_item_limit(plugin_id, num_params)
    329. {
    330.     new item_id = get_param(1)
    331.    
    332.     if (item_id < 0 || item_id >= g_iItemCount)
    333.     {
    334.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid item id (%d)", item_id)
    335.         return ZE_WRONG_ITEM;
    336.     }
    337.    
    338.     return ArrayGetCell(g_iItemLimit, item_id);
    339. }
    340.  
    341. public native_ze_is_valid_itemid(plugin_id, num_params)
    342. {
    343.     new item_id = get_param(1)
    344.    
    345.     if (item_id < 0 || item_id >= g_iItemCount)
    346.     {
    347.         return false;
    348.     }
    349.    
    350.     return true;
    351. }
    352.  
    353. public native_ze_get_item_name(plugin_id, num_params)
    354. {
    355.     new item_id = get_param(1)
    356.    
    357.     if (item_id < 0 || item_id >= g_iItemCount)
    358.     {
    359.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid item id (%d)", item_id)
    360.         return ZE_WRONG_ITEM;
    361.     }
    362.    
    363.     new szName[32]
    364.     ArrayGetString(g_szItemName, item_id, szName, charsmax(szName))
    365.    
    366.     new iLen = get_param(3)
    367.     set_string(2, szName, iLen)
    368.     return true;
    369. }
    370.  
    371. public native_ze_set_vip_discount(iItemid, bool:bSet, Float:flDiscount)
    372. {
    373.     g_bHasDiscount[iItemid] = bSet;
    374.     g_flDiscountValue[iItemid] = flDiscount;
    375. }
    376.  
    377. public native_ze_has_vip_discount(iItemid)
    378. {
    379.     return g_bHasDiscount[iItemid]
    380. }
    381.  
    382. public Float:native_ze_get_item_discount(iItemid)
    383. {
    384.     return g_flDiscountValue[iItemid]
    385. }
2. Update your ze_items_escape_coins.sma with:
    1. #include <zombie_escape>
    2. #include <ze_vip>
    3.  
    4. native ze_has_vip_discount(iItemid)
    5. native Float:ze_get_item_discount(iItemid)
    6.  
    7. new g_iCurrentEC,
    8.     g_iRequiredEC
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
    13. }
    14.  
    15. public ze_select_item_pre(id, itemid, ignorecost)
    16. {
    17.     if (ignorecost)
    18.         return ZE_ITEM_AVAILABLE
    19.    
    20.     g_iCurrentEC = ze_get_escape_coins(id)
    21.    
    22.     if (ze_is_user_vip(id) && ze_has_vip_discount(itemid))
    23.     {
    24.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - ze_get_item_discount(itemid)))
    25.        
    26.         new szText[32]
    27.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(ze_get_item_discount(itemid) * 100))
    28.         ze_add_text_to_item(szText)
    29.     }
    30.     else
    31.     {
    32.         g_iRequiredEC = ze_get_item_cost(itemid)
    33.     }
    34.    
    35.     if (g_iCurrentEC < g_iRequiredEC)
    36.         return ZE_ITEM_UNAVAILABLE
    37.    
    38.     return ZE_ITEM_AVAILABLE
    39. }
    40.  
    41. public ze_select_item_post(id, itemid, ignorecost)
    42. {
    43.     if (ignorecost)
    44.         return
    45.    
    46.     g_iCurrentEC = ze_get_escape_coins(id)
    47.    
    48.     if (ze_is_user_vip(id) && ze_has_vip_discount(itemid))
    49.     {
    50.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * ze_get_item_discount(itemid))
    51.     }
    52.     else
    53.     {
    54.         g_iRequiredEC = ze_get_item_cost(itemid)
    55.     }
    56.    
    57.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
    58. }
Now to add discount to any item for VIPs you will need to use this native:
  • bSet - set discount to this item or not. Make it true.
  • flDiscount - from 0 to 1, to make discount 10% use 0.1 to make 80 % use 0.8 and so on.
Now let's make 40 % discount on Fire nades for VIPs:
    1. #include <zombie_escape>
    2.  
    3. native ze_set_vip_discount(iItemid, bool:bSet, Float:flDiscount);
    4.  
    5. // Default Sound
    6. new const g_szBuyAmmoSound[] = "items/9mmclip1.wav"
    7.  
    8. // Variables
    9. new g_iItemID
    10.  
    11. public plugin_init()
    12. {
    13.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
    14.    
    15.     // Register our item
    16.     g_iItemID = ze_register_item("Fire Nade", 30, 0)
    17.     ze_set_vip_discount(g_iItemID, true, 0.4)
    18. }
    19.  
    20. public ze_select_item_pre(id, itemid)
    21. {
    22.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    23.     if (itemid != g_iItemID)
    24.         return ZE_ITEM_AVAILABLE
    25.    
    26.     // Available for Humans only, So don't show it for zombies
    27.     if (ze_is_user_zombie(id))
    28.         return ZE_ITEM_DONT_SHOW
    29.    
    30.     return ZE_ITEM_AVAILABLE
    31. }
    32.  
    33. public ze_select_item_post(id, itemid)
    34. {
    35.     // This is not our item, Block it here
    36.     if (itemid != g_iItemID)
    37.         return
    38.    
    39.     // Get Weapon ID
    40.     new iWpnID = get_weaponid("weapon_hegrenade")
    41.    
    42.     // Player Don't have Frost Grenade then give him
    43.     if (rg_get_user_bpammo(id, WeaponIdType:iWpnID) == 0)
    44.     {
    45.         rg_give_item(id, "weapon_hegrenade", GT_APPEND)
    46.     }
    47.     else
    48.     {
    49.         // Player have, Increase his Back Pack Ammo, And play buy BP sound + Hud Flash
    50.         rg_set_user_bpammo(id, WeaponIdType:iWpnID, rg_get_user_bpammo(id, WeaponIdType:iWpnID) + 1)
    51.         emit_sound(id, CHAN_ITEM, g_szBuyAmmoSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    52.         Show_Given_BPAmmo(id, 12, 1) // HE Grenade AmmoType Const = 12
    53.     }
    54. }
Just added ze_set_vip_discount(g_iItemID, true, 0.4) under g_iItemID = ze_register_item("Fire Nade", 30, 0).

Important: You must run latest VIP System in order this to run!
is this possible?
  1. public ze_discounts
  2. {
  3.     if ((ze_get_vip_flags(id) & VIP_A) && (ze_get_vip_flags(id) & VIP_B) && (ze_get_vip_flags(id) & VIP_C))
  4.     {
  5.         ze_set_vip_discount(g_iItemID, true, 0.1)
  6.         return;
  7.     }
  8.     else if ((ze_get_vip_flags(id) & VIP_A) && (ze_get_vip_flags(id) & VIP_B))
  9.     {
  10.         ze_set_vip_discount(g_iItemID, true, 0.2)
  11.         return;
  12.     }
  13.     else if (ze_get_vip_flags(id) & VIP_A)
  14.     {
  15.         ze_set_vip_discount(g_iItemID, true, 0.3)
  16.         return;
  17.     }
  18. }

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#22

Post by Raheem » 5 years ago

No, what you try to do?
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#23

Post by Mark » 5 years ago

Raheem wrote: 5 years ago No, what you try to do?
I want to be able to set different prices based off flags lol.

I have 3 tiers

VIP 10%
VIP+ 20%
VIP++ 30%

if this is alot of work dont worry.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#24

Post by Raheem » 5 years ago

What we did will make it just for all vips. So in this case we will need to edit the natives. Maybe 3 natives required for your idea.

Will give you example soon.
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#25

Post by Mark » 5 years ago

Raheem wrote: 5 years ago What we did will make it just for all vips. So in this case we will need to edit the natives. Maybe 3 natives required for your idea.

Will give you example soon.
I think the percents not right


Bought a firenade with cost set to 100 with a 10% discount

20180916203809_1.jpg
20180916203816_1.jpg
in pics you will see it cost 100 but it takes 10 off which is 90% yes?


so now i set it to 100 percent off by 1.0
20180916204437_1.jpg
20180916204441_1.jpg
Last edited by Mark 5 years ago, edited 1 time in total.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#26

Post by Raheem » 5 years ago

Yes i fixed it here: viewtopic.php?p=8396#p8396

Update yours.
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#27

Post by Mark » 5 years ago

Raheem wrote: 5 years ago Yes i fixed it here: viewtopic.php?p=8396#p8396

Update yours.
I did like 3x lol still same also file size was same that i had on server :D

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#28

Post by Raheem » 5 years ago

Wait i forget something
He who fails to plan is planning to fail

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#29

Post by Raheem » 5 years ago

This hardcode for the 3 cases:
    1. #include <zombie_escape>
    2. #include <ze_vip>
    3.  
    4. native ze_has_vip_discount(iItemid)
    5. native Float:ze_get_item_discount(iItemid)
    6.  
    7. new g_iCurrentEC,
    8.     g_iRequiredEC
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
    13. }
    14.  
    15. public ze_select_item_pre(id, itemid, ignorecost)
    16. {
    17.     if (ignorecost)
    18.         return ZE_ITEM_AVAILABLE
    19.    
    20.     g_iCurrentEC = ze_get_escape_coins(id)
    21.    
    22.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
    23.     {
    24.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
    25.        
    26.         new szText[32]
    27.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.1 * 100))
    28.         ze_add_text_to_item(szText)
    29.     }
    30.     else if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
    31.     {
    32.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
    33.        
    34.         new szText[32]
    35.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.2 * 100))
    36.         ze_add_text_to_item(szText)
    37.     }
    38.     else if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
    39.     {
    40.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
    41.        
    42.         new szText[32]
    43.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.3 * 100))
    44.         ze_add_text_to_item(szText)
    45.     }
    46.     else
    47.     {
    48.         g_iRequiredEC = ze_get_item_cost(itemid)
    49.     }
    50.    
    51.     if (g_iCurrentEC < g_iRequiredEC)
    52.         return ZE_ITEM_UNAVAILABLE
    53.    
    54.     return ZE_ITEM_AVAILABLE
    55. }
    56.  
    57. public ze_select_item_post(id, itemid, ignorecost)
    58. {
    59.     if (ignorecost)
    60.         return
    61.    
    62.     g_iCurrentEC = ze_get_escape_coins(id)
    63.    
    64.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
    65.     {
    66.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
    67.     }
    68.     if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
    69.     {
    70.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
    71.     }
    72.     if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
    73.     {
    74.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
    75.     }
    76.     else
    77.     {
    78.         g_iRequiredEC = ze_get_item_cost(itemid)
    79.     }
    80.    
    81.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
    82. }
Try it.

Edit: Also i updated this: viewtopic.php?p=8396#p8396
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#30

Post by Mark » 5 years ago

Raheem wrote: 5 years ago This hardcode for the 3 cases:
    1. #include <zombie_escape>
    2. #include <ze_vip>
    3.  
    4. native ze_has_vip_discount(iItemid)
    5. native Float:ze_get_item_discount(iItemid)
    6.  
    7. new g_iCurrentEC,
    8.     g_iRequiredEC
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
    13. }
    14.  
    15. public ze_select_item_pre(id, itemid, ignorecost)
    16. {
    17.     if (ignorecost)
    18.         return ZE_ITEM_AVAILABLE
    19.    
    20.     g_iCurrentEC = ze_get_escape_coins(id)
    21.    
    22.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
    23.     {
    24.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
    25.        
    26.         new szText[32]
    27.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.1 * 100))
    28.         ze_add_text_to_item(szText)
    29.     }
    30.     else if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
    31.     {
    32.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
    33.        
    34.         new szText[32]
    35.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.2 * 100))
    36.         ze_add_text_to_item(szText)
    37.     }
    38.     else if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
    39.     {
    40.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
    41.        
    42.         new szText[32]
    43.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.3 * 100))
    44.         ze_add_text_to_item(szText)
    45.     }
    46.     else
    47.     {
    48.         g_iRequiredEC = ze_get_item_cost(itemid)
    49.     }
    50.    
    51.     if (g_iCurrentEC < g_iRequiredEC)
    52.         return ZE_ITEM_UNAVAILABLE
    53.    
    54.     return ZE_ITEM_AVAILABLE
    55. }
    56.  
    57. public ze_select_item_post(id, itemid, ignorecost)
    58. {
    59.     if (ignorecost)
    60.         return
    61.    
    62.     g_iCurrentEC = ze_get_escape_coins(id)
    63.    
    64.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
    65.     {
    66.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
    67.     }
    68.     if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
    69.     {
    70.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
    71.     }
    72.     if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
    73.     {
    74.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
    75.     }
    76.     else
    77.     {
    78.         g_iRequiredEC = ze_get_item_cost(itemid)
    79.     }
    80.    
    81.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
    82. }
Try it.

Edit: Also i updated this: viewtopic.php?p=8396#p8396
ok percent works now ill try vip flags

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#31

Post by Mark » 5 years ago

Raheem wrote: 5 years ago This hardcode for the 3 cases:
    1. #include <zombie_escape>
    2. #include <ze_vip>
    3.  
    4. native ze_has_vip_discount(iItemid)
    5. native Float:ze_get_item_discount(iItemid)
    6.  
    7. new g_iCurrentEC,
    8.     g_iRequiredEC
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
    13. }
    14.  
    15. public ze_select_item_pre(id, itemid, ignorecost)
    16. {
    17.     if (ignorecost)
    18.         return ZE_ITEM_AVAILABLE
    19.    
    20.     g_iCurrentEC = ze_get_escape_coins(id)
    21.    
    22.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
    23.     {
    24.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
    25.        
    26.         new szText[32]
    27.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.1 * 100))
    28.         ze_add_text_to_item(szText)
    29.     }
    30.     else if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
    31.     {
    32.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
    33.        
    34.         new szText[32]
    35.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.2 * 100))
    36.         ze_add_text_to_item(szText)
    37.     }
    38.     else if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
    39.     {
    40.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
    41.        
    42.         new szText[32]
    43.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.3 * 100))
    44.         ze_add_text_to_item(szText)
    45.     }
    46.     else
    47.     {
    48.         g_iRequiredEC = ze_get_item_cost(itemid)
    49.     }
    50.    
    51.     if (g_iCurrentEC < g_iRequiredEC)
    52.         return ZE_ITEM_UNAVAILABLE
    53.    
    54.     return ZE_ITEM_AVAILABLE
    55. }
    56.  
    57. public ze_select_item_post(id, itemid, ignorecost)
    58. {
    59.     if (ignorecost)
    60.         return
    61.    
    62.     g_iCurrentEC = ze_get_escape_coins(id)
    63.    
    64.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
    65.     {
    66.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
    67.     }
    68.     if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
    69.     {
    70.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
    71.     }
    72.     if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
    73.     {
    74.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
    75.     }
    76.     else
    77.     {
    78.         g_iRequiredEC = ze_get_item_cost(itemid)
    79.     }
    80.    
    81.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
    82. }
Try it.

Edit: Also i updated this: viewtopic.php?p=8396#p8396
Now the menu when you hit M wont open :D

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#32

Post by Raheem » 5 years ago

Any error in the console?
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#33

Post by Mark » 5 years ago

Raheem wrote: 5 years ago Any error in the console?
  1. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_main_menu.amxx" failed to load: Plugin uses an unknown function (name "ze_show_items_menu") - check your modules.ini.
  2. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_items_manager.amxx" failed to load: Plugin uses an unknown function (name "ze_add_text_to_item") - check your modules.ini.
  3. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_items_escape_coins.amxx" failed to load: Plugin uses an unknown function (name "ze_add_text_to_item") - check your modules.ini.
  4. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_items_limit.amxx" failed to load: Plugin uses an unknown function (name "ze_add_text_to_item") - check your modules.ini.
  5. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_items_level.amxx" failed to load: Plugin uses an unknown function (name "ze_get_item_name") - check your modules.ini.
  6. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_items_vip.amxx" failed to load: Plugin uses an unknown function (name "ze_get_item_name") - check your modules.ini.
  7. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_tuacannon.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  8. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_fire_nade.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  9. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_frost_nade.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  10. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_b_extra_compound_bow.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  11. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_dual_uzi.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  12. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_ak47_paladin.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  13. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_coilgun.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  14. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_plasmagun.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  15. L 09/16/2018 - 21:06:32: [AMXX] Plugin "force_shield_grenade.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  16. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_unlimited_clip.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  17. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_no_recoil.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  18. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_paintball_gun.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  19. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_madness.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  20. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_multijump.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  21. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_jumpnade.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  22. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_knockback_bomb.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  23. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_kill_bomb_v3.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  24. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_confused.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  25. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_antidote.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  26. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_tvirus.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  27. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_leap.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  28. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_extra_zombie_blind_bomb.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  29. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_a_extra_mw2-auto.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  30. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_a_extra_cyclone.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  31. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_a_extra_railcannon.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  32. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_a_extra_tact_knife.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  33. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_b_extra_dual_infinity.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  34. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_b_extra_frost_m4a1.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  35. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_b_extra_balrog11.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  36. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_b_extra_thanatos3.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  37. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_c_extra_stun_rifle.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  38. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_c_extra_fglauncher.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  39. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_c_extra_starchasersr.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  40. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_c_extra_thanatos7.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  41. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_c_extra_janus7.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.
  42. L 09/16/2018 - 21:06:32: [AMXX] Plugin "ze_vip_a_extra_wallclimb.amxx" failed to load: Plugin uses an unknown function (name "ze_register_item") - check your modules.ini.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#34

Post by Raheem » 5 years ago

Hmm, strange. What you did?
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#35

Post by Mark » 5 years ago

Raheem wrote: 5 years ago Hmm, strange. What you did?
Used this
  1. #include <zombie_escape>
  2. #include <ze_vip>
  3.  
  4. native ze_has_vip_discount(iItemid)
  5. native Float:ze_get_item_discount(iItemid)
  6.  
  7. new g_iCurrentEC,
  8.     g_iRequiredEC
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
  13. }
  14.  
  15. public ze_select_item_pre(id, itemid, ignorecost)
  16. {
  17.     if (ignorecost)
  18.         return ZE_ITEM_AVAILABLE
  19.    
  20.     g_iCurrentEC = ze_get_escape_coins(id)
  21.    
  22.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
  23.     {
  24.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
  25.        
  26.         new szText[32]
  27.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.1 * 100))
  28.         ze_add_text_to_item(szText)
  29.     }
  30.     else if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
  31.     {
  32.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
  33.        
  34.         new szText[32]
  35.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.2 * 100))
  36.         ze_add_text_to_item(szText)
  37.     }
  38.     else if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
  39.     {
  40.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
  41.        
  42.         new szText[32]
  43.         formatex(szText, charsmax(szText), " \w(\r%i %% OFF\w)", floatround(0.3 * 100))
  44.         ze_add_text_to_item(szText)
  45.     }
  46.     else
  47.     {
  48.         g_iRequiredEC = ze_get_item_cost(itemid)
  49.     }
  50.    
  51.     if (g_iCurrentEC < g_iRequiredEC)
  52.         return ZE_ITEM_UNAVAILABLE
  53.    
  54.     return ZE_ITEM_AVAILABLE
  55. }
  56.  
  57. public ze_select_item_post(id, itemid, ignorecost)
  58. {
  59.     if (ignorecost)
  60.         return
  61.    
  62.     g_iCurrentEC = ze_get_escape_coins(id)
  63.    
  64.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
  65.     {
  66.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
  67.     }
  68.     if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
  69.     {
  70.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
  71.     }
  72.     if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
  73.     {
  74.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
  75.     }
  76.     else
  77.     {
  78.         g_iRequiredEC = ze_get_item_cost(itemid)
  79.     }
  80.    
  81.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
  82. }

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#36

Post by Raheem » 5 years ago

Try (NOT SURE :?):

  1. #include <zombie_escape>
  2. #include <ze_vip>
  3.  
  4. native ze_has_vip_discount(iItemid)
  5.  
  6. new g_iCurrentEC,
  7.     g_iRequiredEC
  8.  
  9. public plugin_init()
  10. {
  11.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
  12. }
  13.  
  14. public ze_select_item_pre(id, itemid, ignorecost)
  15. {
  16.     if (ignorecost)
  17.         return ZE_ITEM_AVAILABLE
  18.    
  19.     g_iCurrentEC = ze_get_escape_coins(id)
  20.    
  21.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
  22.     {
  23.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
  24.        
  25.         new szText[32]
  26.         formatex(szText, charsmax(szText), " \w(\r10 %% OFF\w)")
  27.         ze_add_text_to_item(szText)
  28.     }
  29.     else if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
  30.     {
  31.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
  32.        
  33.         new szText[32]
  34.         formatex(szText, charsmax(szText), " \w(\r20 %% OFF\w)")
  35.         ze_add_text_to_item(szText)
  36.     }
  37.     else if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
  38.     {
  39.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
  40.        
  41.         new szText[32]
  42.         formatex(szText, charsmax(szText), " \w(\r30 %% OFF\w)")
  43.         ze_add_text_to_item(szText)
  44.     }
  45.     else
  46.     {
  47.         g_iRequiredEC = ze_get_item_cost(itemid)
  48.     }
  49.    
  50.     if (g_iCurrentEC < g_iRequiredEC)
  51.         return ZE_ITEM_UNAVAILABLE
  52.    
  53.     return ZE_ITEM_AVAILABLE
  54. }
  55.  
  56. public ze_select_item_post(id, itemid, ignorecost)
  57. {
  58.     if (ignorecost)
  59.         return
  60.    
  61.     g_iCurrentEC = ze_get_escape_coins(id)
  62.    
  63.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
  64.     {
  65.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * 0.9)
  66.     }
  67.     if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
  68.     {
  69.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * 0.8)
  70.     }
  71.     if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
  72.     {
  73.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * 0.7)
  74.     }
  75.     else
  76.     {
  77.         g_iRequiredEC = ze_get_item_cost(itemid)
  78.     }
  79.    
  80.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
  81. }
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#37

Post by Mark » 5 years ago

Raheem wrote: 5 years ago Try (NOT SURE :?):

  1. #include <zombie_escape>
  2. #include <ze_vip>
  3.  
  4. native ze_has_vip_discount(iItemid)
  5.  
  6. new g_iCurrentEC,
  7.     g_iRequiredEC
  8.  
  9. public plugin_init()
  10. {
  11.     register_plugin("[ZE] Items Manager: Escape Coins", ZE_VERSION, AUTHORS)
  12. }
  13.  
  14. public ze_select_item_pre(id, itemid, ignorecost)
  15. {
  16.     if (ignorecost)
  17.         return ZE_ITEM_AVAILABLE
  18.    
  19.     g_iCurrentEC = ze_get_escape_coins(id)
  20.    
  21.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
  22.     {
  23.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.1))
  24.        
  25.         new szText[32]
  26.         formatex(szText, charsmax(szText), " \w(\r10 %% OFF\w)")
  27.         ze_add_text_to_item(szText)
  28.     }
  29.     else if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
  30.     {
  31.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.2))
  32.        
  33.         new szText[32]
  34.         formatex(szText, charsmax(szText), " \w(\r20 %% OFF\w)")
  35.         ze_add_text_to_item(szText)
  36.     }
  37.     else if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
  38.     {
  39.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * (1.0 - 0.3))
  40.        
  41.         new szText[32]
  42.         formatex(szText, charsmax(szText), " \w(\r30 %% OFF\w)")
  43.         ze_add_text_to_item(szText)
  44.     }
  45.     else
  46.     {
  47.         g_iRequiredEC = ze_get_item_cost(itemid)
  48.     }
  49.    
  50.     if (g_iCurrentEC < g_iRequiredEC)
  51.         return ZE_ITEM_UNAVAILABLE
  52.    
  53.     return ZE_ITEM_AVAILABLE
  54. }
  55.  
  56. public ze_select_item_post(id, itemid, ignorecost)
  57. {
  58.     if (ignorecost)
  59.         return
  60.    
  61.     g_iCurrentEC = ze_get_escape_coins(id)
  62.    
  63.     if ((ze_get_vip_flags(id) & VIP_A) && ze_has_vip_discount(itemid))
  64.     {
  65.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * 0.9)
  66.     }
  67.     if ((ze_get_vip_flags(id) & VIP_B) && ze_has_vip_discount(itemid))
  68.     {
  69.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * 0.8)
  70.     }
  71.     if ((ze_get_vip_flags(id) & VIP_C) && ze_has_vip_discount(itemid))
  72.     {
  73.         g_iRequiredEC = floatround(ze_get_item_cost(itemid) * 0.7)
  74.     }
  75.     else
  76.     {
  77.         g_iRequiredEC = ze_get_item_cost(itemid)
  78.     }
  79.    
  80.     ze_set_escape_coins(id, g_iCurrentEC - g_iRequiredEC)
  81. }
same

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#38

Post by Raheem » 5 years ago

No, i tested it and working for me. But there is issue in numbers but not all these errors.
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#39

Post by Mark » 5 years ago

Raheem wrote: 5 years ago No, i tested it and working for me. But there is issue in numbers but not all these errors.
What all did you do just add the above to the sma? or more with an item?

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#40

Post by Mark » 5 years ago

Raheem wrote: 5 years ago No, i tested it and working for me. But there is issue in numbers but not all these errors.
LOL if would help if i added it to the right sma ahahahahha

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 6 guests