Jump to content

Rocket col shape


DarkByte

Recommended Posts

Posted (edited)

Hello.

I've found this script to detect the weapon (hs rocket/ rocket). If the rocket hits col shape it will output the creator but it doesn't work :/ 
 

addEventHandler("onClientColShapeHit",root,
function(element)
	local weapon = getPedWeapon(g_Me);

	if weapon and g_Rockets[source] and g_Rockets[source][2] and (element == weapon) and (g_Rockets[source][2] ~= weapon) then
		if isTimer(resetTimer) then
			killTimer(resetTimer);
		end
		MyKiller = getProjectileCreator(g_Rockets[source][2]);
		setTimer(resetKiller,20000,1);
      outputChatBox(getPlayerName(MyKiller));
	end
end)

addEventHandler("onClientProjectileCreation",root,
function(creator)
	local x,y,z = getElementPosition(source);
	local detector = createColSphere(x,y,z,6);
	g_Rockets[detector] = {source,creator};
end)

 

Edited by DarkByte

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted (edited)

I'm quite sure that's not your script because 1. it doesn't output anything, 2. it's not the full script, 3. g_Me, g_Rockets and those semicolons are a signature of a scripter I know. This is an old script.

Please provide more information (and a link to the resource).

Edited by myonlake

If I helped you, please click the like button on the right ;) Thanks!

Posted

The original is with vehicle, but i've edited it to get the weapon creator......

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

Well, the script doesn't make any sense. What do you want to do exactly?

  1. Projectile is created
    1. You create a new colshape sphere at where it's spawned and save the colshape to g_Rockets with the creator... twice (source = creator)
  2. The projectile hits the colshape (which it already is in, I don't even know how it even triggers the event, lol)
  3. You get the current active weapon of g_Me (which I recall is getLocalPlayer();)
  4. You check if that weapon returns something (it always returns a number value, lol)
  5. You check if the colshape exists in g_Rockets
  6. You check if the hitElement matches the weapon ... id... .. uh, what?
  7. Then you check if the projectile creator doesn't match the weapon id..... why?
  8. Then you kill a timer, and you create another timer.
  9. And you do absolutely nothing with the getProjectileCreator.

I don't understand your code... at all.

If I helped you, please click the like button on the right ;) Thanks!

  • Moderators
Posted
onClientProjectileCreation

https://wiki.multitheftauto.com/wiki/OnClientElementDestroy (the rocket) (you will know the type of rocket)

Or use:

https://wiki.multitheftauto.com/wiki/OnClientExplosion (you can't retrieve the rocket type with this method, but it is simpler than the one with onClientProjectileCreation)

Here you will know the creator!

 

Want to know who you killed? >

local detector = createColSphere(x,y,z,6);

https://wiki.multitheftauto.com/wiki/GetElementsWithinColShape

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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