julib5432112345

Sniper

Jan 8th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.83 KB | None | 0 0
  1. PLUGIN = nil
  2.  
  3. function Initialize(Plugin)
  4.  Plugin:SetName("Sniper")
  5.  Plugin:SetVersion(2)
  6.  
  7.   --Hooks
  8. cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, using_item)
  9. cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_ANIMATION, animation)
  10. cPluginManager:AddHook(cPluginManager.HOOK_PROJECTILE_HIT_ENTITY, OnProjectileHitEntity)
  11.  PLUGIN = Plugin
  12.   --Command Bindings
  13.  cPluginManager.BindCommand("/sniper", "sniper.get", getsniper, " - /sniper - to get sniper")
  14.  
  15.  LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
  16.  return true -- the trueth is out there
  17. end
  18.  
  19. function OnDisable()
  20.  LOG("Sniper shots itself...")
  21. end
  22.  -- BEFHELAUSFÜRHUNG UND BEKOMMEN DER SNIPER-----------------------------------------
  23. function getsniper(Split, Player)
  24.  local sniper = cItem(E_ITEM_DIAMOND_HORSE_ARMOR, 1, 0, "")
  25.  --local sniper = cItem(ItemType, Count, Damage, EnchantmentString, CustomName, Lore)
  26.    local sniper = cItem(E_ITEM_DIAMOND_HORSE_ARMOR, 1, 0, "", "§aSNIPER", "")
  27.    Player:GetInventory():AddItem( sniper )
  28.    return true
  29. end
  30.  
  31. --RECHTKLICK UND DAMIT ANVISIEREN----------------------------------------------------------
  32. function using_item(Shooter, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType, BlockMeta)
  33.  local sniper = cItem(E_ITEM_DIAMOND_HORSE_ARMOR, 1, 0, "", "§aSNIPER", "")
  34.  local inhand = Shooter:GetEquippedItem()
  35.  if ( sniper:IsEqual( inhand ) == true ) then
  36.    
  37.      if (not Shooter:HasEntityEffect( 2 ) )  then
  38.         -- Does not have entity effect    
  39.         Shooter:SendMessageFatal("Look!")
  40.         local Client = Shooter:GetClientHandle()
  41.         --Client:SendSoundEffect("tile.piston.in", Shooter:GetPosX(), Shooter:GetPosY(), Shooter:GetPosZ(), 1.0, 63)
  42.  
  43.         Shooter:AddEntityEffect( 16, 90000, 1 ) -- night vision
  44.         Shooter:AddEntityEffect( 2, 9000, 7 ) -- slowness
  45.         --Player:AddEntit...
  46.      else
  47.         -- Has entity effect
  48.         Shooter:RemoveEntityEffect( 16 )
  49.         Shooter:RemoveEntityEffect( 2 )
  50.         Shooter:SendMessageFatal("Stop to look!")
  51.      end
  52.      
  53.  
  54.      return false
  55.  else
  56.    return false
  57.  end
  58. end
  59.  
  60. --LINKSKLICK UND SCHIEßEN--------------------------------------------
  61. function left_click(Shooter)
  62.  
  63.  local sniper = cItem(E_ITEM_DIAMOND_HORSE_ARMOR, 1, 0, "", "§aSNIPER", "")
  64.  local inhand = Shooter:GetEquippedItem()
  65.  if ( sniper:IsEqual( inhand ) == true ) then
  66.    local world = Shooter:GetWorld()
  67.    --world:CreateProjectile(X, Y, Z, ProjectileKind, Creator, Originating Item, [Speed]) -- speed as vector!!!
  68.    snowball = world:CreateProjectile(Shooter:GetPosX(), Shooter:GetPosY() + 1.5, Shooter:GetPosZ(), cProjectileEntity.pkSnowball, Shooter, Shooter:GetEquippedItem(), Shooter:GetLookVector() * 300)
  69.  --[[ world:DoWithEntityById(snowball,
  70.    function(a_Projectile)
  71.       a_Projectile:SetGravity(0)
  72.    end
  73. )]]
  74.    
  75.   local Client = Shooter:GetClientHandle()
  76.   Client:SendSoundEffect("tile.piston.in", Shooter:GetPosX(), Shooter:GetPosY() , Shooter:GetPosZ(), 1.0, 63)
  77.   return false
  78.  end
  79. end
  80.  
  81. -- LINKSKLICKVERWEIS--------------------------------------------------------------
  82. function animation(a_Player, a_Animation)
  83.     -- In 1.8.x the left click has a value of 0, while in 1.7.x it\'s 1
  84.     local LeftClickAnimation = (a_Player:GetClientHandle():GetProtocolVersion() > 5) and 0 or 1
  85.     if (a_Animation ~= LeftClickAnimation) then
  86.         return false
  87.     end
  88.     left_click(a_Player)
  89. end
  90.  
  91. --PROJEKTILEINSCHLAG-------------------------------------------------------------
  92. function OnProjectileHitEntity(ProjectileEntity, Entity)
  93.  ShooterName = ProjectileEntity:GetCreatorName()
  94.  --Entity:TakeDamage(DamageType, AttackerEntity, RawDamage, KnockbackAmount)
  95.   Entity:GetWorld():DoWithPlayer(ShooterName,
  96.     function(a_Player)
  97.         Entity:TakeDamage(dtArrow, a_Player, 18, 4)
  98.     end
  99. )
  100. end
Advertisement
Add Comment
Please, Sign In to add comment