Jump to content

why isnt this working..


xTravax

Recommended Posts

i have made a resource which should work perfectly but for unknown reasons it doesnt

function createPaintballEffect(hitElement,hitX,hitY,hitZ) 
  
      daMarker = createMarker(hitX,hitY,hitZ,"corona",0.2,math.random(0,255),math.random(0,255),math.random(0,255),255) 
      outputDebugString("made a marker") 
      if getElementType(hitElement) == "player" or getElementType(hitElement) == "ped" or getElementType(hitElement) == "object" or getElementType(hitElement) == "vehicle" then 
      attachElements(daMarker,hitElement) 
      outputDebugString("attached elements") 
      setTimer(destroyElement,5000,1,daMarker) 
   else outputDebugString("wtf") return end 
end 
addEventHandler("onClientWeaponFire",root,createPaintballEffect) 

custom and built in debug methods dont show anything.

Link to comment

sorry for doublepost, i have rewritten the script and got this

function createPaintballEffect(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) 
  
      local daMarker = createMarker(hitX,hitY,hitZ,"corona",0.2,math.random(0,255),math.random(0,255),math.random(0,255),255) 
      outputDebugString("made a marker") 
      if getElementType(hitElement) == "player" or getElementType(hitElement) == "ped" or getElementType(hitElement) == "object" or getElementType(hitElement) == "vehicle" then 
      attachElements(daMarker,hitElement) 
      else return end 
   setTimer(destroyElement,5000,1,daMarker) 
end 
addEventHandler("onClientPlayerWeaponFire",root,createPaintballEffect) 

it works fine but it outputs to debug that element is nil when i dont hit any object or vehicle or player or ped

i thought ' else return end ' would prevent the debug messages?

whats alternative to stop this debug warnings?

also only attached markers are getting destroyed..

Link to comment
  
function createPaintballEffect(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) 
    if hitElement then 
      local daMarker = createMarker(hitX,hitY,hitZ,"corona",0.2,math.random(0,255),math.random(0,255),math.random(0,255),255) 
      outputDebugString("made a marker") 
      if getElementType(hitElement) == "player" or getElementType(hitElement) == "ped" or getElementType(hitElement) == "object" or getElementType(hitElement) == "vehicle" then 
      attachElements(daMarker,hitElement) 
      else return end 
   setTimer(destroyElement,5000,1,daMarker) 
end 
end 
addEventHandler("onClientPlayerWeaponFire",root,createPaintballEffect) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...