Jump to content

createEffect - Vector3


ds1-e

Recommended Posts

  • Scripting Moderators

Hey, i can't make this function works.

It's all about position in Vector3, no idea why this don't wanna work.

Working code:

createEffect(effect, Vector3(getElementPosition(getLocalPlayer())), 0, 0, 0)

Not working code:

createEffect(effect, Vector3(posX, posY, posZ), 0, 0, 0)

 

Any idea why this don't wanna work? Without errors/warnings in debugscript 3, i got a output so it means that trigger works, but effect don't creates.

KzAkrpb.png

 

Link to comment
  • Scripting Moderators

It's weird situation, i don't really understand why it's happening. I already solved it by using client-side event. But maybe there's other solution.

-- server

function weaponEffects(weapon, endX, endY, endZ, hitElement, startX, startY, startZ) -- triggering custom event using onPlayerWeaponFire...
addEventHandler("onPlayerWeaponFire", getRootElement(), weaponEffects)
  
-- client
function onPlayerClientWeaponFire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) -- creating effect with hitX, hitY, hitZ, and it magically works.
addEventHandler("onClientPlayerWeaponFire", getRootElement(), onPlayerClientWeaponFire)

 

Link to comment
  • Moderators

@majqq

Did you checked if those are actual numbers? (and not strings. In that case you wouldn't see the difference in the outputChatBox.)

 

Also you do not need to use Vector3 in the second example, it can be filled in without. That will save you another function execution.

  • Thanks 1
Link to comment
  • Moderators
1 hour ago, majqq said:

@IIYAMA yup. Did it multiple times. No matter if it's Vector or not. It doesn't work for data sent by trigger.

Hmm indeed strange.

And what if you re-parse it?

function reParseNumber(number)
 return tonumber(tostring(number))
end

 

  • Thanks 1
Link to comment
  • Scripting Moderators
1 hour ago, IIYAMA said:

Hmm indeed strange.

And what if you re-parse it?


function reParseNumber(number)
 return tonumber(tostring(number))
end

 

 

Same results, without creating effect. Anyway it's solved, so i'll leave as it is.

local x, y, z = reParseNumber(posX), reParseNumber(posY), reParseNumber(posZ)
createEffect(effect, x, y, z, 0, 0, 0)

 

  • Like 1
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...