dzek (varez) Posted April 1, 2010 Share Posted April 1, 2010 hi, how can i get the position where projectile hit the ground/player/whatever? Link to comment
Dark Dragon Posted April 2, 2010 Share Posted April 2, 2010 did you try onClientPlayerWeaponFire? For explosive projectiles you can use onClientExplosion Link to comment
dzek (varez) Posted April 2, 2010 Author Share Posted April 2, 2010 did you try onClientPlayerWeaponFire? This does not trigger for projectiles based For explosive projectiles you can use onClientExplosion this is molotov projectile. after hitting ground it dont create the molotov explosion, so this will fail too. i need to create explosion "manually" after projectile hit the ground Link to comment
karlis Posted April 2, 2010 Share Posted April 2, 2010 doesnt proectile destroys when it hit ground?and getElementPosition dont works? Link to comment
dzek (varez) Posted April 2, 2010 Author Share Posted April 2, 2010 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? Link to comment
karlis Posted April 2, 2010 Share Posted April 2, 2010 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
Gamesnert Posted April 2, 2010 Share Posted April 2, 2010 good.. but i dont see "onProjectileDestroy" event or anything like that.. onElementDestroy / onClientElementDestroy Link to comment
dzek (varez) Posted April 2, 2010 Author Share Posted April 2, 2010 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
dzek (varez) Posted April 2, 2010 Author Share Posted April 2, 2010 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
karlis Posted April 2, 2010 Share Posted April 2, 2010 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
dzek (varez) Posted April 2, 2010 Author Share Posted April 2, 2010 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 you removed your idea bout attaching another element (you told bout vehicles ) 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
karlis Posted April 3, 2010 Share Posted April 3, 2010 problem is that only blips,markers,vehicles,peds and objects attaches. and i didnt change mind, but sugsted it for testing, then according results later you can see the way to suceed Link to comment
dzek (varez) Posted April 3, 2010 Author Share Posted April 3, 2010 hmm.. so im still waiting for ideas i think.. Link to comment
Gamesnert Posted April 3, 2010 Share Posted April 3, 2010 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? Wait, nevermind Link to comment
dzek (varez) Posted April 3, 2010 Author Share Posted April 3, 2010 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? what?? Link to comment
Gamesnert Posted April 3, 2010 Share Posted April 3, 2010 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. 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
dzek (varez) Posted April 3, 2010 Author Share Posted April 3, 2010 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. Hmm, my friend's new GPU (but overclocked ) 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
Gamesnert Posted April 3, 2010 Share Posted April 3, 2010 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
dzek (varez) Posted April 3, 2010 Author Share Posted April 3, 2010 i dont need a sync here, just want to create a projectile, that will explode just for one player, nobody else should see it. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now