Jump to content

projectile hit position


Recommended Posts

doesnt proectile destroys when it hit ground?and getElementPosition dont works?

good.. but i dont see "onProjectileDestroy" event or anything like that..

or should i getElementPosition everyframe, until my element exist?

you could do that, but for performance reasons calculate aprox time when ti should land and get pos only then

Link to comment
you could do that, but for performance reasons calculate aprox time when ti should land and get pos only then

omg, HOW?

sometimes ped is standing in front of SOMETHING, making the projectile hit in same time as created,

sometimes ped just throw molotov in open space

sometimes ped throwing molotov from the roof

sometimes ped even throw molotov from big mountain..

too much cases and random things

i thought is there any event that will help me get the time projectile destroy

edit:

I'll try that Gamesnert :)

Link to comment

sweet.. well, almost

function molotovHit()
local px, py, pz = getElementPosition(source)
outputChatBox(getElementType(source))
outputChatBox(px.."."..py.."."..pz)
--createExplosion(lx, ly, lz, 1, getRootElement())
end
 
local projectile = createProjectile (ped, 18, lx, ly, zz+0.7, 1.0, getLocalPlayer(), rx, ry, rz, dx, dy)
addEventHandler("onClientElementDestroy", projectile, molotovHit)

chatbox:

projectile

0.0.0

Link to comment

is there alternative ways to get pos?marix, or how was it called?(dont blame me please, im noob in matrixes)

abut that calculation, varez, theres processLineOfSight

edit:varez, try checking xyz every frame, bcoz may destroy is triggered to late

Link to comment
edit:varez, try checking xyz every frame, bcoz may destroy is triggered to late

hehe, 1st you told me that this will be CPU consuming (indeed),

now you are changing your mind :P

you removed your idea bout attaching another element (you told bout vehicles :P) to it..

well, i think thats not a bad idea, i'll try to attach a very small object and on projectile remove ill check the object position, then remove the object.. hope this will work fine..

im waiting for another ideas anyway :)

Link to comment
edit:varez, try checking xyz every frame, bcoz may destroy is triggered to late

hehe, 1st you told me that this will be CPU consuming (indeed),

This shouldn't be that CPU consuming, otherwise you have to be doing it wrong. Keep in mind that SA does over 9000x more calculations to draw images onto the screen and calculate physics. Yet, that doesn't lag all too much. It's perhaps not ideal, but CPU consuming? I doubt it.

An alternative way could be using onClientExplosion. Don't ask me how, but it should be possible. (in some way)

P.S. Did I just detect a double-double-post? :o Wait, nevermind

Link to comment
This shouldn't be that CPU consuming, otherwise you have to be doing it wrong. Keep in mind that SA does over 9000x more calculations to draw images onto the screen and calculate physics. Yet, that doesn't lag all too much. It's perhaps not ideal, but CPU consuming? I doubt it.

maybe.. but custom scripting could lag game easly even if game have milion things more to do :)

An alternative way could be using onClientExplosion. Don't ask me how, but it should be possible. (in some way)

i'll give it a try, but i shouldnt think molotov projectile hit makes a explosion (as i dont see any)

P.S. Did I just detect a double-double-post? :o

what??

Link to comment
maybe.. but custom scripting could lag game easly even if game have milion things more to do :)

There's a certain truth in here. Lua is a lot slower than C++, because Lua is extremely dynamic and C++ basically isn't. Dynamic means the PC needs to do a lot more calculations to actually do the same thing, but it's much easier for a person to script in. However, don't exaggerate the amount of more calculations need to be done. If onClientRender would really be that CPU consuming, the map editor would fry your PC in seconds, and Valhalla would simply turn your PC in a nuclear bomb. :P

i'll give it a try, but i shouldnt think molotov projectile hit makes a explosion (as i dont see any)

What do you mean, you "can't see any explosion"? Molotov projectiles should create an explosion.

what??

I didn't say anything D:

Link to comment
If onClientRender would really be that CPU consuming, the map editor would fry your PC in seconds, and Valhalla would simply turn your PC in a nuclear bomb. :P

Hmm, my friend's new GPU (but overclocked :P) was burned not on the newest game on max detail, but in MTA Map Editor ;)

i'll give it a try, but i shouldnt think molotov projectile hit makes a explosion (as i dont see any)

What do you mean, you "can't see any explosion"? Molotov projectiles should create an explosion.

ok, i think i figured it out..

when you set as creator ped that was created server side, the explosion dont show up..

thats why i was trying to create explosion "manually"..

if i set creator to local player everything is ok!

and if you create ped clientside, and set him as creator, everything is ok too

edit:

okay, what can be creator of projectile if not local player (as i dont want to sync the projectile)?

getRootElement() fails

Link to comment

It makes sense you don't get an explosion if you're not the creator. Projectiles only get synced with you specified as creator, and creating an explosion from a non-synced projectile would create desync.

Just use onClientRender to get the last position, and create an explosion from a molotov over there. See if that works.

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...