DarkByte Posted January 14, 2017 Share Posted January 14, 2017 (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 January 14, 2017 by DarkByte Link to comment
myonlake Posted January 14, 2017 Share Posted January 14, 2017 (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 January 14, 2017 by myonlake Link to comment
DarkByte Posted January 14, 2017 Author Share Posted January 14, 2017 The original is with vehicle, but i've edited it to get the weapon creator...... Link to comment
myonlake Posted January 14, 2017 Share Posted January 14, 2017 Well, the script doesn't make any sense. What do you want to do exactly? Projectile is created You create a new colshape sphere at where it's spawned and save the colshape to g_Rockets with the creator... twice (source = creator) The projectile hits the colshape (which it already is in, I don't even know how it even triggers the event, lol) You get the current active weapon of g_Me (which I recall is getLocalPlayer();) You check if that weapon returns something (it always returns a number value, lol) You check if the colshape exists in g_Rockets You check if the hitElement matches the weapon ... id... .. uh, what? Then you check if the projectile creator doesn't match the weapon id..... why? Then you kill a timer, and you create another timer. And you do absolutely nothing with the getProjectileCreator. I don't understand your code... at all. Link to comment
Simple0x47 Posted January 15, 2017 Share Posted January 15, 2017 You should use this event to make it easier. OnClientPlayerWeaponFire Check if it's the localPlayer the ones that shoots and check if the weapon ID is the rocket launcher and done. Link to comment
Moderators IIYAMA Posted January 16, 2017 Moderators Share Posted January 16, 2017 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 Link to comment
DarkByte Posted January 16, 2017 Author Share Posted January 16, 2017 @IIYAMAthanks bud 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