Coversion done( not working in server)

Coding Help/Re-API Supported
Post Reply
Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

Coversion done( not working in server)

#1

Post by Rain1153 » 5 years ago

i converted the code fully but It doesn't drag humans Pls fix it
  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <engine>
  4.  
  5. #define PLUGIN "[ZP] Extra Drag"
  6. #define VERSION "1.1"
  7. #define AUTHOR "4eRT"
  8.  
  9. //Some vars
  10. new const g_extra_drag[] = { "Drag ability" }
  11. new const g_vmodel[] = { "models/barnacle/v_bgrap.mdl" }
  12. new const g_pmodel[] = { "models/barnacle/p_bgrap.mdl" }
  13. new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
  14. new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
  15. new g_hooked[33], g_hooksLeft[33], g_unable2move[33], g_over_dmg[33]
  16. new Float:g_lastHook[33]
  17. new g_Line, g_item_drag
  18. new cvar_enabled, cvar_cost, cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmgtostop, cvar_mates, cvar_extrahook, cvar_unb2move, cvar_reset
  19. new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
  20. new bool: g_has_drag[33], bool: g_bind_use[33], bool: g_bind_or_not[33], bool: g_drag_i[33]
  21.  
  22. public plugin_init()
  23. {
  24.     cvar_enabled = register_cvar("zp_extra_drag", "1")
  25.     cvar_cost = register_cvar("zp_extra_drag_cost", "40")
  26.     cvar_dragspeed = register_cvar("zp_extra_drag_dragspeed", "160")
  27.     cvar_maxdrags = register_cvar("zp_extra_drag_maxdrags", "10")
  28.     cvar_cooldown = register_cvar("zp_extra_drag_cooldown", "5")
  29.     cvar_dmgtostop = register_cvar("zp_extra_drag_dmg2stop", "300")
  30.     cvar_mates = register_cvar("zp_extra_drag_mates", "0")
  31.     cvar_extrahook = register_cvar("zp_extra_drag_extrahook", "2")
  32.     cvar_unb2move = register_cvar("zp_extra_drag_unable_move", "1")
  33.    
  34.     cvar_reset = register_cvar("zp_extra_drag_reset", "0")
  35.     register_event("HLTV", "newSpawn", "a", "1=0", "2=0")
  36.     register_event("DeathMsg", "player_death", "a")
  37.     register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
  38.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  39.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  40.     register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
  41.     register_clcmd("-drag","drag_end")
  42.     register_menucmd(register_menuid("Do you want to bind V +drag?"), keys, "bind_v_key")
  43.  
  44.     g_item_drag = ze_register_item(g_extra_drag, get_pcvar_num(cvar_cost), 0)
  45. }
  46.  
  47. public plugin_precache()
  48. {
  49.     register_plugin(PLUGIN, VERSION, AUTHOR)
  50.     precache_sound(g_sndDrag)
  51.     precache_sound(g_sndMiss)
  52.     g_Line = precache_model("sprites/zbeam4.spr")
  53.     engfunc(EngFunc_PrecacheModel, g_vmodel)
  54.     engfunc(EngFunc_PrecacheModel, g_pmodel)
  55. }
  56.  
  57. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  58.     replace_models(msg_entity);
  59.  
  60. public replace_models(id)
  61. {
  62.     if (!is_user_alive(id) || !ze_is_user_zombie(id))
  63.         return;
  64.    
  65.     if(get_user_weapon(id) == CSW_KNIFE && g_has_drag[id])
  66.     {
  67.         set_pev(id, pev_viewmodel2, g_vmodel);
  68.         set_pev(id, pev_weaponmodel2, g_pmodel);
  69.     }
  70. }
  71. public ze_select_item_pre(id, item)
  72. {
  73.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  74.     if (item != g_item_drag)
  75.         return ZE_ITEM_AVAILABLE
  76.    
  77.     // Available for Humans only, So don't show it for zombies
  78.     if (!ze_is_user_zombie(id))
  79.         return ZE_ITEM_DONT_SHOW
  80.    
  81.     return ZE_ITEM_AVAILABLE
  82. }
  83.  
  84. public ze_select_item_post(id, item)
  85. {
  86.     if (item == g_item_drag)
  87.     {
  88.         if(is_user_alive(id) && get_pcvar_num(cvar_enabled) == 1)
  89.         {
  90.             g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
  91.             g_has_drag[id] = true
  92.             client_print(id, print_chat, "You've bought drag ability. Now You can frag huamns!")
  93.             replace_models(id)
  94.            
  95.             if (!g_bind_or_not[id])
  96.             {
  97.                 new menu[192]
  98.                 format(menu, 191, "Do you want to bind V +drag?^n^n1. Yes^n2. No^n3. Drag on +USE")
  99.                 show_menu(id, keys, menu)
  100.             }
  101.         } else
  102.             return
  103.     }
  104. }
  105.  
  106. public ze_user_infected(id, infector)
  107.     if(g_has_drag[infector])
  108.         g_hooksLeft[infector] = g_hooksLeft[infector] + get_pcvar_num(cvar_extrahook)
  109.  
  110. public ze_user_humanized(id)
  111.     if(get_pcvar_num(cvar_reset) == 1)
  112.         g_has_drag[id] = false
  113.  
  114. public newSpawn()
  115. {
  116.     for (new id = 1; id <= 32; id++)
  117.     {
  118.         if (g_hooked[id])
  119.             drag_end(id)
  120.    
  121.         g_has_drag[id] = false
  122.     }
  123. }
  124.  
  125. public player_death()
  126. {
  127.     new attacker = read_data(1)
  128.     new id = read_data(2)
  129.    
  130.     if (g_hooked[attacker])
  131.         drag_end(id)
  132.    
  133.     g_has_drag[id] = false
  134. }
  135.  
  136. public client_connect(id)
  137.     g_has_drag[id] = false
  138.  
  139. public client_disconnected(id)
  140. {
  141.     if (g_hooked[id])
  142.         drag_end(id)
  143.    
  144.     if(g_unable2move[id])
  145.         g_unable2move[id] = false
  146.    
  147.     g_has_drag[id] = false
  148. }
  149.  
  150. public drag_start(id)
  151. {      
  152.     if (ze_is_user_zombie(id) && g_has_drag[id] && !g_drag_i[id]) {
  153.        
  154.         static Float:cdown
  155.         cdown = get_pcvar_float(cvar_cooldown)
  156.  
  157.         if (!is_user_alive(id)) {
  158.             client_print(id, print_chat, "[ZE] You can't drag if you are dead!")
  159.             return PLUGIN_HANDLED
  160.         }
  161.  
  162.         if (g_hooksLeft[id] <= 0) {
  163.             client_print(id, print_chat, "[ZE] You can't drag anymore!")
  164.             return PLUGIN_HANDLED
  165.         }
  166.  
  167.         if (get_gametime() - g_lastHook[id] < cdown) {
  168.             client_print(id, print_chat, "[ZE] Wait %.f0 sec. to drag again!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
  169.             return PLUGIN_HANDLED
  170.        
  171.         }
  172.  
  173.         new hooktarget, body
  174.         get_user_aiming(id, hooktarget, body)
  175.        
  176.         if (is_user_alive(hooktarget)) {
  177.             if (!ze_is_user_zombie(hooktarget))
  178.                 {
  179.                    
  180.            
  181.                     if (get_pcvar_num(cvar_mates) == 1)
  182.                     {
  183.                         g_hooked[id] = hooktarget
  184.                         emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
  185.                     }
  186.                     else
  187.                     {
  188.                         client_print(id, print_chat, "[ZP] You can't drag teammates!")
  189.                         return PLUGIN_HANDLED
  190.                     }
  191.                 }
  192.  
  193.             if (get_pcvar_float(cvar_dragspeed) <= 0.0)
  194.                 cvar_dragspeed = 1
  195.            
  196.             new parm[2]
  197.             parm[0] = id
  198.             parm[1] = hooktarget
  199.            
  200.             set_task(0.1, "reelin_player", id, parm, 2, "b")
  201.             harpoon_target(parm)
  202.            
  203.             g_hooksLeft[id]--
  204.             client_print(id, print_chat, "[ZE] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
  205.             g_drag_i[id] = true
  206.            
  207.             if(get_pcvar_num(cvar_unb2move) == 1)
  208.                 g_unable2move[hooktarget] = true
  209.                
  210.             if(get_pcvar_num(cvar_unb2move) == 2)
  211.                 g_unable2move[id] = true
  212.                
  213.             if(get_pcvar_num(cvar_unb2move) == 3)
  214.             {
  215.                 g_unable2move[hooktarget] = true
  216.                 g_unable2move[id] = true
  217.             }
  218.         } else {
  219.             g_hooked[id] = 33
  220.             noTarget(id)
  221.             emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
  222.             g_drag_i[id] = true
  223.             g_hooksLeft[id]--
  224.             client_print(id, print_chat, "[ZP] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
  225.         }
  226.     }
  227.     else
  228.         return PLUGIN_HANDLED
  229.    
  230.     return PLUGIN_CONTINUE
  231. }
  232.  
  233. public reelin_player(parm[])
  234. {
  235.     new id = parm[0]
  236.     new victim = parm[1]
  237.  
  238.     if (!g_hooked[id] || !is_user_alive(victim))
  239.     {
  240.         drag_end(id)
  241.         return
  242.     }
  243.  
  244.     new Float:fl_Velocity[3]
  245.     new idOrigin[3], vicOrigin[3]
  246.  
  247.     get_user_origin(victim, vicOrigin)
  248.     get_user_origin(id, idOrigin)
  249.  
  250.     new distance = get_distance(idOrigin, vicOrigin)
  251.  
  252.     if (distance > 1) {
  253.         new Float:fl_Time = distance / get_pcvar_float(cvar_dragspeed)
  254.  
  255.         fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
  256.         fl_Velocity[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
  257.         fl_Velocity[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
  258.     } else {
  259.         fl_Velocity[0] = 0.0
  260.         fl_Velocity[1] = 0.0
  261.         fl_Velocity[2] = 0.0
  262.     }
  263.  
  264.     entity_set_vector(victim, EV_VEC_velocity, fl_Velocity)
  265. }
  266.  
  267. public drag_end(id)
  268. {
  269.     g_hooked[id] = 0
  270.     beam_remove(id)
  271.     remove_task(id)
  272.    
  273.     if (g_drag_i[id])
  274.         g_lastHook[id] = get_gametime()
  275.    
  276.     g_drag_i[id] = false
  277.     g_unable2move[id] = false
  278. }
  279.  
  280. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  281. {
  282.     if (is_user_alive(attacker) && (get_pcvar_num(cvar_dmgtostop) > 0))
  283.     {
  284.         g_over_dmg[victim] = g_over_dmg[victim] + floatround(damage)
  285.         if (g_over_dmg[victim] >= get_pcvar_num(cvar_dmgtostop))
  286.         {
  287.             g_over_dmg[victim] = 0
  288.             drag_end(victim)
  289.             return HAM_IGNORED;
  290.         }
  291.     }
  292.  
  293.     return HAM_IGNORED;
  294. }
  295.  
  296. public fw_PlayerPreThink(id)
  297. {
  298.     if (!is_user_alive(id))
  299.         return FMRES_IGNORED
  300.    
  301.     new button = get_user_button(id)
  302.     new oldbutton = get_user_oldbutton(id)
  303.    
  304.     if (ze_is_user_zombie(id) && g_has_drag[id])
  305.     {
  306.         if(g_bind_use[id])
  307.         {
  308.             if (!(oldbutton & IN_USE) && (button & IN_USE))
  309.                 drag_start(id)
  310.        
  311.             if ((oldbutton & IN_USE) && !(button & IN_USE))
  312.                 drag_end(id)
  313.         }
  314.     }
  315.    
  316.     if (!g_drag_i[id])
  317.         g_unable2move[id] = false
  318.        
  319.     if (g_unable2move[id] && get_pcvar_num(cvar_unb2move) > 0)
  320.         set_pev(id, pev_maxspeed, 1.0)
  321.    
  322.     return PLUGIN_CONTINUE
  323. }
  324.  
  325. public harpoon_target(parm[])
  326. {
  327.     new id = parm[0]
  328.     new hooktarget = parm[1]
  329.  
  330.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  331.     write_byte(8)
  332.     write_short(id)
  333.     write_short(hooktarget)
  334.     write_short(g_Line)
  335.     write_byte(0)
  336.     write_byte(0)
  337.     write_byte(200)
  338.     write_byte(8)
  339.     write_byte(1)
  340.     write_byte(255)
  341.     write_byte(0)
  342.     write_byte(0)
  343.     write_byte(90)
  344.     write_byte(10)
  345.     message_end()
  346. }
  347.  
  348. public bind_v_key(id, keys)
  349. {
  350.     g_bind_or_not[id] = true
  351.     switch(keys)
  352.     {
  353.         case 0:
  354.             client_cmd(id, "bind v ^"+drag^"")
  355.    
  356.         case 1:
  357.             client_print(id, print_chat, "[ZE] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
  358.            
  359.         case 2:
  360.             g_bind_use[id] = true
  361.            
  362.         default:
  363.             g_bind_or_not[id] = false
  364.     }
  365.    
  366.     return PLUGIN_HANDLED
  367. }
  368.  
  369. public noTarget(id)
  370. {
  371.     new endorigin[3]
  372.  
  373.     get_user_origin(id, endorigin, 3)
  374.  
  375.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  376.     write_byte( TE_BEAMENTPOINT );
  377.     write_short(id)
  378.     write_coord(endorigin[0])
  379.     write_coord(endorigin[1])
  380.     write_coord(endorigin[2])
  381.     write_short(g_Line)
  382.     write_byte(0)
  383.     write_byte(0)
  384.     write_byte(200)
  385.     write_byte(8)
  386.     write_byte(1)
  387.     write_byte(255)
  388.     write_byte(0)
  389.     write_byte(0)
  390.     write_byte(75)
  391.     write_byte(0)
  392.     message_end()
  393. }
  394.  
  395. public beam_remove(id)
  396. {
  397.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  398.     write_byte(99)
  399.     write_short(id)
  400.     message_end()
  401. }
  402. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  403. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  404. */
LOL

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

#2

Post by Raheem » 5 years ago

The ZP plugin works for ZP? If yes so maybe you made something wrong while converting so post the original zp item and i'll convert it.
He who fails to plan is planning to fail

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#3

Post by Rain1153 » 5 years ago

ok
Last edited by Rain1153 5 years ago, edited 1 time in total.
LOL

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#4

Post by Rain1153 » 5 years ago

that's the original code..i don't think i did something wrong with the plugin it worked in all aspects except the fact that i cant drag a human. Ofc i cant drag teammates (zombies) but for humans idk why it didn't work/
Last edited by Rain1153 5 years ago, edited 1 time in total.
LOL

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#5

Post by Rain1153 » 5 years ago

and bro you should at least test it just to be sure if it works or not ..thanks ..here is the original link (zp_extra_drag_ability is the plugin) https://forums.alliedmods.net/showthrea ... 09?t=90309
LOL

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

#6

Post by Raheem » 5 years ago

I think you post the converted one, Also i don't test right now as i'm lazy to open local server and install the item. SORRY :lol:

TRY:
  • Code: Select all

    #include <zombie_escape>
    #include <engine>
    
    #define PLUGIN "[ZE] Extra Drag"
    #define VERSION "1.1"
    #define AUTHOR "4eRT"
    
    //Some vars
    new const g_extra_drag[] = { "Drag ability" } 
    new const g_vmodel[] = { "models/barnacle/v_bgrap.mdl" }
    new const g_pmodel[] = { "models/barnacle/p_bgrap.mdl" }
    new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
    new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
    new g_hooked[33], g_hooksLeft[33], g_unable2move[33], g_over_dmg[33]
    new Float:g_lastHook[33]
    new g_Line, g_item_drag
    new cvar_enabled, cvar_cost, cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmgtostop, cvar_mates, cvar_extrahook, cvar_unb2move, cvar_nemesis, cvar_survivor, cvar_reset
    new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
    new bool: g_has_drag[33], bool: g_bind_use[33], bool: g_bind_or_not[33], bool: g_drag_i[33]
    
    public plugin_init()
    {
    	cvar_enabled = register_cvar("ze_extra_drag", "1")
    	cvar_cost = register_cvar("ze_extra_drag_cost", "10")
    	cvar_dragspeed = register_cvar("ze_extra_drag_dragspeed", "160")
    	cvar_maxdrags = register_cvar("ze_extra_drag_maxdrags", "10")
    	cvar_cooldown = register_cvar("ze_extra_drag_cooldown", "5")
    	cvar_dmgtostop = register_cvar("ze_extra_drag_dmg2stop", "300")
    	cvar_mates = register_cvar("ze_extra_drag_mates", "0")
    	cvar_extrahook = register_cvar("ze_extra_drag_extrahook", "2")
    	cvar_unb2move = register_cvar("ze_extra_drag_unable_move", "1")
    	cvar_nemesis = register_cvar("ze_extra_drag_nemesis", "0")
    	cvar_survivor = register_cvar("ze_extra_drag_survivor", "1")
    	cvar_reset = register_cvar("ze_extra_drag_reset", "0")
    	register_event("HLTV", "newSpawn", "a", "1=0", "2=0")
    	register_event("DeathMsg", "player_death", "a")
    	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
    	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
    	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    	register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
    	register_clcmd("-drag","drag_end")
    	register_menucmd(register_menuid("Do you want to bind V +drag?"), keys, "bind_v_key")
    	g_item_drag = ze_register_item(g_extra_drag, get_pcvar_num(cvar_cost), 0)
    }
    
    public plugin_precache()
    {
    	register_plugin(PLUGIN, VERSION, AUTHOR)
    	precache_sound(g_sndDrag)
    	precache_sound(g_sndMiss)
    	g_Line = precache_model("sprites/zbeam4.spr")
    	engfunc(EngFunc_PrecacheModel, g_vmodel)
    	engfunc(EngFunc_PrecacheModel, g_pmodel)
    }
    
    public message_cur_weapon(msg_id, msg_dest, msg_entity)
    	replace_models(msg_entity);
    
    public replace_models(id)
    {
    	if (!is_user_alive(id) || !ze_is_user_zombie(id))
    		return;
    	
    	if(get_user_weapon(id) == CSW_KNIFE && g_has_drag[id])
    	{
    		set_pev(id, pev_viewmodel2, g_vmodel);
    		set_pev(id, pev_weaponmodel2, g_pmodel);
    	}
    }
    
    public ze_select_item_pre(id, itemid)
    {
    	// Return Available and we will block it in Post, So it dosen't affect other plugins
    	if (itemid != g_item_drag)
    		return ZE_ITEM_AVAILABLE
    	
    	// Available for Zombies only, So don't show it for Humans
    	if (!ze_is_user_zombie(id))
    		return ZE_ITEM_DONT_SHOW
    	
    	return ZE_ITEM_AVAILABLE
    }
    
    public ze_select_item_post(id, itemid)
    {
    	// This is not our item, Block it here
    	if (itemid != g_item_drag)
    		return
    	
    	g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
    	g_has_drag[id] = true
    	client_print(id, print_chat, "You've bought drag ability. Now have fun with barnacle hand!")
    	replace_models(id)
    	
    	if (!g_bind_or_not[id])
    	{
    		new menu[192]
    		format(menu, 191, "Do you want to bind V +drag?^n^n1. Yes^n2. No^n3. Drag on +USE")
    		show_menu(id, keys, menu)
    	}
    }
    
    public ze_user_infected(id, infector)
    	if(g_has_drag[infector])
    		g_hooksLeft[infector] = g_hooksLeft[infector] + get_pcvar_num(cvar_extrahook)
    
    public ze_user_humanized(id)
    	if(get_pcvar_num(cvar_reset) == 1)
    		g_has_drag[id] = false
    
    public newSpawn()
    {
    	for (new id = 1; id <= 32; id++)
    	{
    		if (g_hooked[id])
    			drag_end(id)
    	
    		g_has_drag[id] = false
    	}
    }
    
    public player_death()
    {
    	new attacker = read_data(1)
    	new id = read_data(2)
    	
    	if (g_hooked[attacker])
    		drag_end(id)
    	
    	g_has_drag[id] = false
    }
    
    public client_connect(id)
    	g_has_drag[id] = false
    
    public client_disconnect(id)
    {
    	if (g_hooked[id])
    		drag_end(id)
    	
    	if(g_unable2move[id])
    		g_unable2move[id] = false
    	
    	g_has_drag[id] = false
    }
    
    public drag_start(id)
    {		
    	if (ze_is_user_zombie(id) && g_has_drag[id] && !g_drag_i[id]) {
    		
    		static Float:cdown
    		cdown = get_pcvar_float(cvar_cooldown)
    
    		if (!is_user_alive(id)) {
    			client_print(id, print_chat, "[ZE] You can't drag if you are dead!")
    			return PLUGIN_HANDLED
    		}
    
    		if (g_hooksLeft[id] <= 0) {
    			client_print(id, print_chat, "[ZE] You can't drag anymore!")
    			return PLUGIN_HANDLED
    		}
    
    		if (get_gametime() - g_lastHook[id] < cdown) {
    			client_print(id, print_chat, "[ZE] Wait %.f0 sec. to drag again!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
    			return PLUGIN_HANDLED
    		}
    		
    		if (get_pcvar_num(cvar_nemesis) == 0) {
    			client_print(id, print_chat, "[ZE] You can't drag in Nemesis mode!")
    			return PLUGIN_HANDLED
    		}
    
    		new hooktarget, body
    		get_user_aiming(id, hooktarget, body)
    		
    		if (is_user_alive(hooktarget)) {
    			if (!ze_is_user_zombie(hooktarget))
    				{
    					if ( get_pcvar_num(cvar_survivor) == 0 ) {
    						client_print(id, print_chat, "[ZE] You can't drag Survivor!")
    						return PLUGIN_HANDLED
    					}
    					
    					g_hooked[id] = hooktarget
    					emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
    				}
    			else
    				{
    					if (get_pcvar_num(cvar_mates) == 1)
    					{
    						g_hooked[id] = hooktarget
    						emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
    					}
    					else
    					{
    						client_print(id, print_chat, "[ZP] You can't drag teammates!")
    						return PLUGIN_HANDLED
    					}
    				}
    
    			if (get_pcvar_float(cvar_dragspeed) <= 0.0)
    				cvar_dragspeed = 1
    			
    			new parm[2]
    			parm[0] = id
    			parm[1] = hooktarget
    			
    			set_task(0.1, "reelin_player", id, parm, 2, "b")
    			harpoon_target(parm)
    			
    			g_hooksLeft[id]--
    			client_print(id, print_chat, "[ZE] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
    			g_drag_i[id] = true
    			
    			if(get_pcvar_num(cvar_unb2move) == 1)
    				g_unable2move[hooktarget] = true
    				
    			if(get_pcvar_num(cvar_unb2move) == 2)
    				g_unable2move[id] = true
    				
    			if(get_pcvar_num(cvar_unb2move) == 3)
    			{
    				g_unable2move[hooktarget] = true
    				g_unable2move[id] = true
    			}
    		} else {
    			g_hooked[id] = 33
    			noTarget(id)
    			emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
    			g_drag_i[id] = true
    			g_hooksLeft[id]--
    			client_print(id, print_chat, "[ZE] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
    		}
    	}
    	else
    		return PLUGIN_HANDLED
    	
    	return PLUGIN_CONTINUE
    }
    
    public reelin_player(parm[])
    {
    	new id = parm[0]
    	new victim = parm[1]
    
    	if (!g_hooked[id] || !is_user_alive(victim))
    	{
    		drag_end(id)
    		return
    	}
    
    	new Float:fl_Velocity[3]
    	new idOrigin[3], vicOrigin[3]
    
    	get_user_origin(victim, vicOrigin)
    	get_user_origin(id, idOrigin)
    
    	new distance = get_distance(idOrigin, vicOrigin)
    
    	if (distance > 1) {
    		new Float:fl_Time = distance / get_pcvar_float(cvar_dragspeed)
    
    		fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
    		fl_Velocity[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
    		fl_Velocity[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
    	} else {
    		fl_Velocity[0] = 0.0
    		fl_Velocity[1] = 0.0
    		fl_Velocity[2] = 0.0
    	}
    
    	entity_set_vector(victim, EV_VEC_velocity, fl_Velocity)
    }
    
    public drag_end(id)
    {
    	g_hooked[id] = 0
    	beam_remove(id)
    	remove_task(id)
    	
    	if (g_drag_i[id])
    		g_lastHook[id] = get_gametime()
    	
    	g_drag_i[id] = false
    	g_unable2move[id] = false
    }
    
    public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
    {
    	if (is_user_alive(attacker) && (get_pcvar_num(cvar_dmgtostop) > 0))
    	{
    		g_over_dmg[victim] = g_over_dmg[victim] + floatround(damage)
    		if (g_over_dmg[victim] >= get_pcvar_num(cvar_dmgtostop))
    		{
    			g_over_dmg[victim] = 0
    			drag_end(victim)
    			return HAM_IGNORED;
    		}
    	}
    
    	return HAM_IGNORED;
    }
    
    public fw_PlayerPreThink(id)
    {
    	if (!is_user_alive(id))
    		return FMRES_IGNORED
    	
    	new button = get_user_button(id)
    	new oldbutton = get_user_oldbutton(id)
    	
    	if (ze_is_user_zombie(id) && g_has_drag[id])
    	{
    		if(g_bind_use[id])
    		{
    			if (!(oldbutton & IN_USE) && (button & IN_USE))
    				drag_start(id)
    		
    			if ((oldbutton & IN_USE) && !(button & IN_USE))
    				drag_end(id)
    		}
    	}
    	
    	if (!g_drag_i[id])
    		g_unable2move[id] = false
    		
    	if (g_unable2move[id] && get_pcvar_num(cvar_unb2move) > 0)
    		set_pev(id, pev_maxspeed, 1.0)
    	
    	return PLUGIN_CONTINUE
    }
    
    public harpoon_target(parm[])
    {
    	new id = parm[0]
    	new hooktarget = parm[1]
    
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    	write_byte(8)
    	write_short(id)
    	write_short(hooktarget)
    	write_short(g_Line)
    	write_byte(0)
    	write_byte(0)
    	write_byte(200)
    	write_byte(8)
    	write_byte(1)
    	write_byte(255)
    	write_byte(0)
    	write_byte(0)
    	write_byte(90)
    	write_byte(10)
    	message_end()
    }
    
    public bind_v_key(id, keys)
    {
    	g_bind_or_not[id] = true
    	switch(keys)
    	{
    		case 0:
    			client_cmd(id, "bind v ^"+drag^"")
    	
    		case 1:
    			client_print(id, print_chat, "[ZE] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
    			
    		case 2:
    			g_bind_use[id] = true
    			
    		default:
    			g_bind_or_not[id] = false
    	}
    	
    	return PLUGIN_HANDLED
    }
    
    public noTarget(id)
    {
    	new endorigin[3]
    
    	get_user_origin(id, endorigin, 3)
    
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    	write_byte( TE_BEAMENTPOINT );
    	write_short(id)
    	write_coord(endorigin[0])
    	write_coord(endorigin[1])
    	write_coord(endorigin[2])
    	write_short(g_Line)
    	write_byte(0)
    	write_byte(0)
    	write_byte(200)
    	write_byte(8)
    	write_byte(1)
    	write_byte(255)
    	write_byte(0)
    	write_byte(0)
    	write_byte(75)
    	write_byte(0)
    	message_end()
    }
    
    public beam_remove(id)
    {
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    	write_byte(99)
    	write_short(id)
    	message_end()
    }
He who fails to plan is planning to fail

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#7

Post by Rain1153 » 5 years ago

Oh ok bro ill test this
LOL

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#8

Post by Rain1153 » 5 years ago

not working there is nemesis round and suvivor round in ze wth --
LOL

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#9

Post by Rain1153 » 5 years ago

please exclude all the unnecessary codes bro like nemesis round and survivor
LOL

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

#10

Post by Raheem » 5 years ago

Here it's:
  • Code: Select all

    #include <zombie_escape>
    #include <engine>
    
    #define PLUGIN "[ZE] Extra Drag"
    #define VERSION "1.1"
    #define AUTHOR "4eRT"
    
    //Some vars
    new const g_extra_drag[] = { "Drag ability" } 
    new const g_vmodel[] = { "models/barnacle/v_bgrap.mdl" }
    new const g_pmodel[] = { "models/barnacle/p_bgrap.mdl" }
    new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
    new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
    new g_hooked[33], g_hooksLeft[33], g_unable2move[33], g_over_dmg[33]
    new Float:g_lastHook[33]
    new g_Line, g_item_drag
    new cvar_enabled, cvar_cost, cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmgtostop, cvar_mates, cvar_extrahook, cvar_unb2move, cvar_reset
    new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
    new bool: g_has_drag[33], bool: g_bind_use[33], bool: g_bind_or_not[33], bool: g_drag_i[33]
    
    public plugin_init()
    {
    	cvar_enabled = register_cvar("ze_extra_drag", "1")
    	cvar_cost = register_cvar("ze_extra_drag_cost", "10")
    	cvar_dragspeed = register_cvar("ze_extra_drag_dragspeed", "160")
    	cvar_maxdrags = register_cvar("ze_extra_drag_maxdrags", "10")
    	cvar_cooldown = register_cvar("ze_extra_drag_cooldown", "5")
    	cvar_dmgtostop = register_cvar("ze_extra_drag_dmg2stop", "300")
    	cvar_mates = register_cvar("ze_extra_drag_mates", "0")
    	cvar_extrahook = register_cvar("ze_extra_drag_extrahook", "2")
    	cvar_unb2move = register_cvar("ze_extra_drag_unable_move", "1")
    	cvar_reset = register_cvar("ze_extra_drag_reset", "0")
    	register_event("HLTV", "newSpawn", "a", "1=0", "2=0")
    	register_event("DeathMsg", "player_death", "a")
    	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
    	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
    	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    	register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
    	register_clcmd("-drag","drag_end")
    	register_menucmd(register_menuid("Do you want to bind V +drag?"), keys, "bind_v_key")
    	g_item_drag = ze_register_item(g_extra_drag, get_pcvar_num(cvar_cost), 0)
    }
    
    public plugin_precache()
    {
    	register_plugin(PLUGIN, VERSION, AUTHOR)
    	precache_sound(g_sndDrag)
    	precache_sound(g_sndMiss)
    	g_Line = precache_model("sprites/zbeam4.spr")
    	engfunc(EngFunc_PrecacheModel, g_vmodel)
    	engfunc(EngFunc_PrecacheModel, g_pmodel)
    }
    
    public message_cur_weapon(msg_id, msg_dest, msg_entity)
    	replace_models(msg_entity);
    
    public replace_models(id)
    {
    	if (!is_user_alive(id) || !ze_is_user_zombie(id))
    		return;
    	
    	if(get_user_weapon(id) == CSW_KNIFE && g_has_drag[id])
    	{
    		set_pev(id, pev_viewmodel2, g_vmodel);
    		set_pev(id, pev_weaponmodel2, g_pmodel);
    	}
    }
    
    public ze_select_item_pre(id, itemid)
    {
    	// Return Available and we will block it in Post, So it dosen't affect other plugins
    	if (itemid != g_item_drag)
    		return ZE_ITEM_AVAILABLE
    	
    	// Available for Zombies only, So don't show it for Humans
    	if (!ze_is_user_zombie(id))
    		return ZE_ITEM_DONT_SHOW
    	
    	return ZE_ITEM_AVAILABLE
    }
    
    public ze_select_item_post(id, itemid)
    {
    	// This is not our item, Block it here
    	if (itemid != g_item_drag)
    		return
    	
    	g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
    	g_has_drag[id] = true
    	client_print(id, print_chat, "You've bought drag ability. Now have fun with barnacle hand!")
    	replace_models(id)
    	
    	if (!g_bind_or_not[id])
    	{
    		new menu[192]
    		format(menu, 191, "Do you want to bind V +drag?^n^n1. Yes^n2. No^n3. Drag on +USE")
    		show_menu(id, keys, menu)
    	}
    }
    
    public ze_user_infected(id, infector)
    	if(g_has_drag[infector])
    		g_hooksLeft[infector] = g_hooksLeft[infector] + get_pcvar_num(cvar_extrahook)
    
    public ze_user_humanized(id)
    	if(get_pcvar_num(cvar_reset) == 1)
    		g_has_drag[id] = false
    
    public newSpawn()
    {
    	for (new id = 1; id <= 32; id++)
    	{
    		if (g_hooked[id])
    			drag_end(id)
    	
    		g_has_drag[id] = false
    	}
    }
    
    public player_death()
    {
    	new attacker = read_data(1)
    	new id = read_data(2)
    	
    	if (g_hooked[attacker])
    		drag_end(id)
    	
    	g_has_drag[id] = false
    }
    
    public client_connect(id)
    	g_has_drag[id] = false
    
    public client_disconnect(id)
    {
    	if (g_hooked[id])
    		drag_end(id)
    	
    	if(g_unable2move[id])
    		g_unable2move[id] = false
    	
    	g_has_drag[id] = false
    }
    
    public drag_start(id)
    {		
    	if (ze_is_user_zombie(id) && g_has_drag[id] && !g_drag_i[id]) {
    		
    		static Float:cdown
    		cdown = get_pcvar_float(cvar_cooldown)
    
    		if (!is_user_alive(id)) {
    			client_print(id, print_chat, "[ZE] You can't drag if you are dead!")
    			return PLUGIN_HANDLED
    		}
    
    		if (g_hooksLeft[id] <= 0) {
    			client_print(id, print_chat, "[ZE] You can't drag anymore!")
    			return PLUGIN_HANDLED
    		}
    
    		if (get_gametime() - g_lastHook[id] < cdown) {
    			client_print(id, print_chat, "[ZE] Wait %.f0 sec. to drag again!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
    			return PLUGIN_HANDLED
    		}
    
    		new hooktarget, body
    		get_user_aiming(id, hooktarget, body)
    		
    		if (is_user_alive(hooktarget)) {
    			if (!ze_is_user_zombie(hooktarget))
    				{
    					
    					g_hooked[id] = hooktarget
    					emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
    				}
    			else
    				{
    					if (get_pcvar_num(cvar_mates) == 1)
    					{
    						g_hooked[id] = hooktarget
    						emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
    					}
    					else
    					{
    						client_print(id, print_chat, "[ZP] You can't drag teammates!")
    						return PLUGIN_HANDLED
    					}
    				}
    
    			if (get_pcvar_float(cvar_dragspeed) <= 0.0)
    				cvar_dragspeed = 1
    			
    			new parm[2]
    			parm[0] = id
    			parm[1] = hooktarget
    			
    			set_task(0.1, "reelin_player", id, parm, 2, "b")
    			harpoon_target(parm)
    			
    			g_hooksLeft[id]--
    			client_print(id, print_chat, "[ZE] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
    			g_drag_i[id] = true
    			
    			if(get_pcvar_num(cvar_unb2move) == 1)
    				g_unable2move[hooktarget] = true
    				
    			if(get_pcvar_num(cvar_unb2move) == 2)
    				g_unable2move[id] = true
    				
    			if(get_pcvar_num(cvar_unb2move) == 3)
    			{
    				g_unable2move[hooktarget] = true
    				g_unable2move[id] = true
    			}
    		} else {
    			g_hooked[id] = 33
    			noTarget(id)
    			emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
    			g_drag_i[id] = true
    			g_hooksLeft[id]--
    			client_print(id, print_chat, "[ZE] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
    		}
    	}
    	else
    		return PLUGIN_HANDLED
    	
    	return PLUGIN_CONTINUE
    }
    
    public reelin_player(parm[])
    {
    	new id = parm[0]
    	new victim = parm[1]
    
    	if (!g_hooked[id] || !is_user_alive(victim))
    	{
    		drag_end(id)
    		return
    	}
    
    	new Float:fl_Velocity[3]
    	new idOrigin[3], vicOrigin[3]
    
    	get_user_origin(victim, vicOrigin)
    	get_user_origin(id, idOrigin)
    
    	new distance = get_distance(idOrigin, vicOrigin)
    
    	if (distance > 1) {
    		new Float:fl_Time = distance / get_pcvar_float(cvar_dragspeed)
    
    		fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
    		fl_Velocity[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
    		fl_Velocity[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
    	} else {
    		fl_Velocity[0] = 0.0
    		fl_Velocity[1] = 0.0
    		fl_Velocity[2] = 0.0
    	}
    
    	entity_set_vector(victim, EV_VEC_velocity, fl_Velocity)
    }
    
    public drag_end(id)
    {
    	g_hooked[id] = 0
    	beam_remove(id)
    	remove_task(id)
    	
    	if (g_drag_i[id])
    		g_lastHook[id] = get_gametime()
    	
    	g_drag_i[id] = false
    	g_unable2move[id] = false
    }
    
    public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
    {
    	if (is_user_alive(attacker) && (get_pcvar_num(cvar_dmgtostop) > 0))
    	{
    		g_over_dmg[victim] = g_over_dmg[victim] + floatround(damage)
    		if (g_over_dmg[victim] >= get_pcvar_num(cvar_dmgtostop))
    		{
    			g_over_dmg[victim] = 0
    			drag_end(victim)
    			return HAM_IGNORED;
    		}
    	}
    
    	return HAM_IGNORED;
    }
    
    public fw_PlayerPreThink(id)
    {
    	if (!is_user_alive(id))
    		return FMRES_IGNORED
    	
    	new button = get_user_button(id)
    	new oldbutton = get_user_oldbutton(id)
    	
    	if (ze_is_user_zombie(id) && g_has_drag[id])
    	{
    		if(g_bind_use[id])
    		{
    			if (!(oldbutton & IN_USE) && (button & IN_USE))
    				drag_start(id)
    		
    			if ((oldbutton & IN_USE) && !(button & IN_USE))
    				drag_end(id)
    		}
    	}
    	
    	if (!g_drag_i[id])
    		g_unable2move[id] = false
    		
    	if (g_unable2move[id] && get_pcvar_num(cvar_unb2move) > 0)
    		set_pev(id, pev_maxspeed, 1.0)
    	
    	return PLUGIN_CONTINUE
    }
    
    public harpoon_target(parm[])
    {
    	new id = parm[0]
    	new hooktarget = parm[1]
    
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    	write_byte(8)
    	write_short(id)
    	write_short(hooktarget)
    	write_short(g_Line)
    	write_byte(0)
    	write_byte(0)
    	write_byte(200)
    	write_byte(8)
    	write_byte(1)
    	write_byte(255)
    	write_byte(0)
    	write_byte(0)
    	write_byte(90)
    	write_byte(10)
    	message_end()
    }
    
    public bind_v_key(id, keys)
    {
    	g_bind_or_not[id] = true
    	switch(keys)
    	{
    		case 0:
    			client_cmd(id, "bind v ^"+drag^"")
    	
    		case 1:
    			client_print(id, print_chat, "[ZE] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
    			
    		case 2:
    			g_bind_use[id] = true
    			
    		default:
    			g_bind_or_not[id] = false
    	}
    	
    	return PLUGIN_HANDLED
    }
    
    public noTarget(id)
    {
    	new endorigin[3]
    
    	get_user_origin(id, endorigin, 3)
    
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    	write_byte( TE_BEAMENTPOINT );
    	write_short(id)
    	write_coord(endorigin[0])
    	write_coord(endorigin[1])
    	write_coord(endorigin[2])
    	write_short(g_Line)
    	write_byte(0)
    	write_byte(0)
    	write_byte(200)
    	write_byte(8)
    	write_byte(1)
    	write_byte(255)
    	write_byte(0)
    	write_byte(0)
    	write_byte(75)
    	write_byte(0)
    	message_end()
    }
    
    public beam_remove(id)
    {
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    	write_byte(99)
    	write_short(id)
    	message_end()
    }
He who fails to plan is planning to fail

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