Approved Buy VIP

Plug-ins compatibility with Zombie Escape 1.x only!


Post Reply
Zjox
Member
Member
Austria
Posts: 23
Joined: 5 years ago
Contact:

#11

Post by Zjox » 5 years ago

Raheem wrote: 5 years ago You are using GitHub latest stocks include and in it the IsPlayerInArray() function already defined so no need again to be defined in code, this what the error tells:
    1. #include <zombie_escape>
    2. #include <ze_vip>
    3.  
    4. // Const.
    5. static const g_szLocalFile[] = "addons/amxmodx/configs/ze_vips.ini"
    6.  
    7. // CVARs
    8. new g_pCvarOneWeekPrice,
    9.     g_pCvarTwoWeekPrice,
    10.     g_pCvarVIPFlags,
    11.     g_pCvarAutoUpdatePW
    12.  
    13. // Variables
    14. new g_iOneOrTwo, Array:g_aBought;
    15.  
    16. public plugin_natives()
    17. {
    18.     register_native("ze_open_buy_vip_menu", "native_ze_open_buy_vip_menu", 1)
    19. }
    20.  
    21. public plugin_init()
    22. {
    23.     register_plugin("Buy VIP", "1.0", "Raheem")
    24.    
    25.     // Commands
    26.     register_clcmd("say /buy_vip", "ShowBuyVIPMenu")
    27.     register_clcmd("say_team /buy_vip", "ShowBuyVIPMenu")
    28.     register_clcmd("Enter_Password", "cmdEnterPassword")
    29.    
    30.     // CVARs
    31.     g_pCvarOneWeekPrice = register_cvar("one_week_vip_price", "25000")
    32.     g_pCvarTwoWeekPrice = register_cvar("two_week_vip_price", "40000")
    33.     g_pCvarVIPFlags = register_cvar("buy_vip_flags", "abcde")
    34.     g_pCvarAutoUpdatePW = register_cvar("auto_update_setinfo", "1")
    35.    
    36.     // Create dynamic arrays
    37.     g_aBought = ArrayCreate(34)
    38. }
    39.  
    40. public native_ze_open_buy_vip_menu(id)
    41. {
    42.     ShowBuyVIPMenu(id)
    43. }
    44.  
    45. public ze_game_started()
    46. {
    47.     ArrayClear(g_aBought)
    48. }
    49.  
    50. public ShowBuyVIPMenu(id)
    51. {
    52.     if (!is_user_connected(id))
    53.         return PLUGIN_CONTINUE
    54.  
    55.     if (IsPlayerInArray(g_aBought, id))
    56.     {
    57.         client_print_color(id, print_team_default, "^3You will be VIP next round^1, ^3please be patient^1!")
    58.         return PLUGIN_HANDLED
    59.     }
    60.  
    61.     if (ze_is_user_vip(id))
    62.     {
    63.         client_print_color(id, print_team_default, "^3You are already VIP^1!")
    64.         return PLUGIN_HANDLED
    65.     }
    66.    
    67.     new iMenu = menu_create("\rChoose V.I.P Plan\w:", "BuyVIP_Menu_Handler")
    68.    
    69.     new iPlayerEC
    70.     iPlayerEC = ze_get_escape_coins(id)
    71.    
    72.     new szItemText[128]
    73.    
    74.     if (iPlayerEC >= get_pcvar_num(g_pCvarOneWeekPrice))
    75.     {
    76.         formatex(szItemText, charsmax(szItemText), "\yOne Week \w- \r%i", get_pcvar_num(g_pCvarOneWeekPrice))
    77.         menu_additem(iMenu, szItemText, "", 0)
    78.     }
    79.     else
    80.     {
    81.         formatex(szItemText, charsmax(szItemText), "\dOne Week - \r%i", get_pcvar_num(g_pCvarOneWeekPrice))
    82.         menu_additem(iMenu, szItemText, "", 0)
    83.     }
    84.    
    85.     if (iPlayerEC >= get_pcvar_num(g_pCvarTwoWeekPrice))
    86.     {
    87.         formatex(szItemText, charsmax(szItemText), "\yTwo Weeks \w- \r%i^n^n\rNOTE: Your VIP will be saved with SteamID.", get_pcvar_num(g_pCvarTwoWeekPrice))
    88.         menu_additem(iMenu, szItemText, "", 0)
    89.     }
    90.     else
    91.     {
    92.         formatex(szItemText, charsmax(szItemText), "\dTwo Weeks - \r%i^n^n\rNOTE: Your VIP will be saved with SteamID.", get_pcvar_num(g_pCvarTwoWeekPrice))
    93.         menu_additem(iMenu, szItemText, "", 0)
    94.     }
    95.    
    96.     menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL)
    97.     menu_display(id, iMenu, 0)
    98.    
    99.     return PLUGIN_CONTINUE
    100. }
    101.  
    102. public BuyVIP_Menu_Handler(id, iMenu, iItem)
    103. {
    104.     if(!is_user_connected(id) || ze_is_user_vip(id))
    105.         return PLUGIN_HANDLED
    106.    
    107.     new iPlayerEC
    108.     iPlayerEC = ze_get_escape_coins(id)
    109.        
    110.     switch(iItem)
    111.     {
    112.         case 0:
    113.         {
    114.             if (iPlayerEC >= get_pcvar_num(g_pCvarOneWeekPrice))
    115.             {
    116.                 client_cmd(id, "messagemode Enter_Password")
    117.                 g_iOneOrTwo = 1;
    118.             }
    119.             else
    120.             {
    121.                 client_print_color(id, print_team_red, "^3WARNING^1: ^4Insufficient Funds^1!")
    122.                 PlaySound(id, "vox/warning.wav")
    123.             }
    124.         }
    125.         case 1:
    126.         {
    127.             if (iPlayerEC >= get_pcvar_num(g_pCvarTwoWeekPrice))
    128.             {
    129.                 client_cmd(id, "messagemode Enter_Password")
    130.                 g_iOneOrTwo = 2;
    131.             }
    132.             else
    133.             {
    134.                 client_print_color(id, print_team_red, "^3WARNING^1: ^4Insufficient Funds^1!")
    135.                 PlaySound(id, "vox/warning.wav")
    136.             }
    137.         }
    138.     }
    139.  
    140.     menu_destroy(iMenu)
    141.     return PLUGIN_HANDLED
    142. }
    143.  
    144. public cmdEnterPassword(id)
    145. {
    146.     new szPassword[32]
    147.     read_args(szPassword, charsmax(szPassword))
    148.     remove_quotes(szPassword)
    149.    
    150.     if (strlen(szPassword) <= 0)
    151.     {
    152.         client_print_color(id, print_team_red, "^3ERROR^1: ^4You can't use empty password^1!")
    153.         return
    154.     }
    155.    
    156.     new szAuthId[34], szName[32]
    157.     get_user_authid(id, szAuthId, charsmax(szAuthId))
    158.     get_user_name(id, szName, charsmax(szName))
    159.    
    160.     new szFlags[30]
    161.     get_pcvar_string(g_pCvarVIPFlags, szFlags, charsmax(szFlags))
    162.    
    163.     new szExpireDate[16]
    164.    
    165.     if (g_iOneOrTwo == 1)
    166.     {
    167.         get_date(7, szExpireDate, charsmax(szExpireDate))
    168.     }
    169.     else if (g_iOneOrTwo == 2)
    170.     {
    171.         get_date(14, szExpireDate, charsmax(szExpireDate))
    172.     }
    173.    
    174.     // Format line to be added to ze_vips.ini
    175.     new szAddLine[128], iFileHandler
    176.    
    177.     formatex(szAddLine, charsmax(szAddLine), "^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ;%s", szAuthId, szPassword, szFlags, szExpireDate, szName)
    178.    
    179.     iFileHandler = fopen(g_szLocalFile, "at")
    180.     fputs(iFileHandler, szAddLine)
    181.     fclose(iFileHandler)
    182.    
    183.     if (get_pcvar_num(g_pCvarAutoUpdatePW) == 1)
    184.     {
    185.         new szFormatPW[64]
    186.         formatex(szFormatPW, charsmax(szFormatPW), "setinfo _pw ^"%s^"", szPassword)
    187.        
    188.         Send_Cmd(id, szFormatPW)
    189.     }
    190.    
    191.     client_print_color(id, print_team_default, "^3Successfully bought^1, ^3your VIP will expire in^1: ^4%s^1!", szExpireDate)
    192.    
    193.     if (g_iOneOrTwo == 1)
    194.     {
    195.         ze_set_escape_coins(id, ze_get_escape_coins(id) - get_pcvar_num(g_pCvarOneWeekPrice))
    196.     }
    197.     else if (g_iOneOrTwo == 2)
    198.     {
    199.         ze_set_escape_coins(id, ze_get_escape_coins(id) - get_pcvar_num(g_pCvarTwoWeekPrice))
    200.     }
    201.    
    202.     ArrayPushString(g_aBought, szAuthId)
    203. }
    204.  
    205. // Not written by me
    206. stock get_date(days, string[], chars)
    207. {
    208.     new y, m, d
    209.     date(y, m ,d)
    210.    
    211.     d+=days
    212.    
    213.     new go = true
    214.     while(go) {
    215.         switch(m) {
    216.             case 1,3, 5, 7, 8, 10: {
    217.                 if(d>31) { d=d-31; m++; }
    218.                 else go = false
    219.             }
    220.             case 2: {
    221.                 if(d>28) { d=d-28; m++; }
    222.                 else go = false
    223.             }
    224.             case 4, 6, 9, 11: {
    225.                 if(d>30) { d=d-30; m++; }
    226.                 else go = false
    227.             }
    228.             case 12: {
    229.                 if(d>31) { d=d-31; y++; m=1; }
    230.                 else go = false
    231.             }
    232.         }
    233.     }
    234.    
    235.     formatex(string, chars, "%d-%d-%d", d, m, y)
    236. }
    237.  
    238. // Useful slow hacking to auto set pw for users
    239. stock Send_Cmd(id, szCmd[])
    240. {
    241.     message_begin(MSG_ONE, 51, _, id)
    242.     write_byte(strlen(szCmd) + 2)
    243.     write_byte(10)
    244.     write_string(szCmd)
    245.     message_end()
    246. }
Thanks a lot @Raheem, It worked! You are the best :D

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#12

Post by Night Fury » 5 years ago

Zjox wrote: 5 years ago
Hey,
Same problem...
https://github.com/raheem-cs/Zombie-Esc ... stocks.inc
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

Zjox
Member
Member
Austria
Posts: 23
Joined: 5 years ago
Contact:

#13

Post by Zjox » 5 years ago

Jack GamePlay wrote: 5 years ago
Zjox wrote: 5 years ago
Hey,
Same problem...
https://github.com/raheem-cs/Zombie-Esc ... stocks.inc
I already have latest one, and thanks anyway because @Raheem fixed it!
Make me the unstuck by aim (Bind) it's not compiling please!

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 0 guests