Advertisement
NanoBob

mta tagging

Jan 13th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. local tagTextures={
  2.     ["Sons of Anarchy"]="images/Reaper.png"
  3.     ["Tuga Turks"]="images/TugaTurks.png",
  4.     ["Hell soldiers"]="images/Nigger.png",
  5. }
  6.  
  7. local tags={}
  8. local tagShaders={}
  9. local tagModel=1528
  10. local tagTexture="seville"
  11. local selectedTag=nil
  12. local screenx,screeny=guiGetScreenSize()
  13.  
  14. local acceptableAmmo={[5]=true,[125]=true,[250]=true,[375]=true,[450]=true}
  15.  
  16. function selectTag(fileName)
  17.     if fileExists(fileName) then
  18.         selectedTag=fileName
  19.         return true
  20.     end
  21. end
  22.  
  23. function selectTagCommand(command,index)
  24.     local index=tonumber(index)
  25.     if tagTextures[index]~=nil then
  26.         selectedTag=tagTextures[index]
  27.     end
  28. end
  29. addCommandHandler("tag",selectTagCommand)
  30. selectTag("images/Anarchy.png")
  31. selectTag("images/SoA.png")
  32. selectTag("images/Reaper.png")
  33.  
  34. function applyShaderToTag(tag)
  35.     if isElement(tag) then
  36.         local correspondingShader=tagShaders[selectedTag]
  37.         if correspondingShader~=nil then
  38.             engineApplyShaderToWorldTexture(correspondingShader,tagTexture,tag)
  39.         end
  40.     end
  41. end
  42.  
  43. function spraycan(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)
  44.     if weapon==41 and acceptableAmmo[ammoInClip]==true then
  45.         local player=source
  46.         if hitElement==nil then
  47.             local midX,midY=screenx*0.5,screeny*0.5
  48.             local x,y,z=getWorldFromScreenPosition(midX,midY,3)
  49.             local x2,y2,z2=getWorldFromScreenPosition(midX,midY,6)
  50.             local hit,hx,hy,hz,element=processLineOfSight(x,y,z,x2,y2,z2,true,true,false,true)
  51.             local deltaX,deltaY=hx-x,hy-y
  52.             local x,y=x+deltaX*0.95,y+deltaY*0.95
  53.             if hit==true and x and y and z then
  54.                 local rx,ry,rz=getElementRotation(player)
  55.                 local rz=rz+83
  56.                 local tag=createObject(tagModel,x,y,z,rx,ry,rz)
  57.                 applyShaderToTag(tag)
  58.                 --local tagMarker=createMarker(x,y,z,"corona")
  59.             end
  60.         end
  61.     end
  62. end
  63. addEventHandler("onClientPlayerWeaponFire",getRootElement(),spraycan)
  64.  
  65.  
  66. function setupAllShaders()
  67.     for id,textureName in pairs(tagTextures) do
  68.         local myShader
  69.         myShader, tec = dxCreateShader ( "tagShader.fx" )
  70.         local myTexture = dxCreateTexture (textureName)
  71.         dxSetShaderValue ( myShader, "CUSTOMTEX0", myTexture );
  72.         tagShaders[textureName]=myShader
  73.     end
  74. end
  75. addEventHandler( "onClientResourceStart",resourceRoot,setupAllShaders)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement