seb-c

Untitled

May 1st, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. function predBomb( player, _,name, meters )
  2.     local target = getPlayerFromPartialName ( name,player )
  3.     if not isElement ( target ) then return outputChatBox( "can't find player" ) end
  4.     local meters = tonumber( meters )
  5.     if not meters then
  6.         meters = 3
  7.     end
  8.     local posX , posY , posZ = getElementPosition ( target )
  9.     local  rotation = getPedRotation( target )
  10.     posX = posX - math.sin ( math.rad ( rotation ) ) * meters
  11.     posY = posY + math.cos ( math.rad ( rotation ) ) * meters
  12.     local bomb = createObject( 1337,posX+1,posY,posZ )
  13.     outputChatBox( "Bomb return: "..tostring( bomb ) )
  14.     setTimer( setElementPosition,50,1,bomb,posX+1,posY,posZ )
  15.     setTimer( setElementPosition,150,1,bomb,posX+3,posY,posZ )
  16.     setTimer( setElementPosition,250,1,bomb,posX+6,posY,posZ )
  17.     setTimer( setElementPosition,350,1,bomb,posX+9,posY,posZ )
  18.     local xo,yo,zo = getElementPosition( bomb )
  19.     setTimer( createExplosion,2000,1,xo,yo,zo, 0 )
  20. end
  21. addCommandHandler("bomb", predBomb)
  22.  
  23.  
  24. function getPlayerFromPartialName ( name , player )
  25.     if name then
  26.         local matches = { }
  27.         for index , _player in ipairs ( getElementsByType ( "player" ) ) do
  28.             if getPlayerName ( _player ) == name then
  29.                 return _player
  30.             end
  31.             if getPlayerName ( _player ) : gsub ( "#%x%x%x%x%x%x" , "" ) : lower ( ) : find ( name : lower ( ) ) then
  32.                 table.insert ( matches , _player )
  33.             end
  34.         end
  35.         if #matches == 1 then
  36.             return matches [ 1 ]
  37.         else
  38.             if player then
  39.                 outputChatBox ( "Found " .. #matches .. " matches" , player , 255 , 0 , 0 )
  40.             end
  41.         end
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment