denny199 Posted February 12, 2012 Share Posted February 12, 2012 hi there I was wondering that some servers have liek this: a hunter fight; Danny hitted Joop with his hunter like that but how? i maded like this: but when i shoot it comes test: and a error in debugscript: ser bad argument 17: getelementtype but i wanna make if a player hits a another player with his rocket that it comes in the chatbox that he hitted him please help me -- i know from wiki but i dnunno were to start function onPlayerTarget ( targetElem ) if getElementType ( targetElem ) == "vehicle" and getElementModel ( targetElem ) == 425 then outputChatBox ( "test" ) end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget ) Link to comment
Evil-Cod3r Posted February 12, 2012 Share Posted February 12, 2012 (edited) Code Updated ! 2 local him = getPlayerName(killer) local me = getPlayerName(source) local what = getElementType() local mta = getElementModel() function kill ( ammo, killer, killerweapon, bodypart) if (what == "vehicle" and mta == 425) then outputChatBox ( "him .. Has Killed .. me with .. what .. mta" ) end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) Edited February 12, 2012 by Guest Link to comment
Kenix Posted February 12, 2012 Share Posted February 12, 2012 denny199,Can you explain better please? Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 ofc, If you have got a hunter fight Like this: I shoot you and you got killed by me then i will that in the chatbox comes: ( "Danny has killed Kennix with his hunter" ) Link to comment
Evil-Cod3r Posted February 12, 2012 Share Posted February 12, 2012 see my code updated ! Link to comment
Kenix Posted February 12, 2012 Share Posted February 12, 2012 function kill ( ammo, killer, killerweapon, bodypart ) local vehicle = getPedOccupiedVehicle( killer ) if isElement( vehicle ) and getElementModel( vehicle ) == 425 then outputChatBox ( getPlayerName( killer )..' has killed '..getPlayerName( source )..' with his hunter.' ) end end addEventHandler ( "onPlayerWasted", root, kill ) Evil-Cod3r,Your code is wrong. local him = getPlayerName(killer) -- variable killer is nil local me = getPlayerName(source) -- variable source is nil ( source used in event you can read [url=https://wiki.multitheftauto.com/wiki/Predefined_variables_list]https://wiki.multitheftauto.com/wiki/Pre ... ables_list[/url] ) local what = getElementType() -- not use arguments so return false local mta = getElementModel() -- same function kill ( ammo, killer, killerweapon, bodypart) if (what == "vehicle" and mta == 425) then outputChatBox ( "him .. Has Killed .. me with .. what .. mta" ) end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) Link to comment
Evil-Cod3r Posted February 12, 2012 Share Posted February 12, 2012 oh sorrey thanks for the lesson Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 it says bad argument @ getpecoccupiedvehicle used this code function kill ( ammo, killer, killerweapon, bodypart ) local vehicle = getPedOccupiedVehicle( killer ) if isElement( vehicle ) and getElementModel( vehicle ) == 425 then outputChatBox ( getPlayerName( killer )..' has killed '..getPlayerName( source )..' with his hunter.' ) end end addEventHandler ( "onPlayerWasted", root, kill ) Link to comment
Kenix Posted February 12, 2012 Share Posted February 12, 2012 (edited) function kill ( ammo, killer, killerweapon, bodypart ) if killer and killer ~= source then if isPedInVehicle( killer ) and killerweapon == 19 or killerweapon == 51 then local vehicle = getPedOccupiedVehicle( killer ) if isElement( vehicle ) and getElementModel( vehicle ) == 425 then outputChatBox ( getPlayerName( killer )..' has killed '..getPlayerName( source )..' with his hunter.' ) end end end end addEventHandler ( "onPlayerWasted", root, kill ) Updated. You need for race gm? Edited February 12, 2012 by Guest Link to comment
Castillo Posted February 12, 2012 Share Posted February 12, 2012 There's no really way to know who shoot you, because you get killed caused by your vehicle explosion, not by the rocket fired. I don't know if "onClientVehicleCollision" detects the rocket, and if you're able to track the projectile creator. Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 well, kenix code didn't work it does nothing now i saw the updated, thanks for that but it's now serverside Link to comment
Kenix Posted February 12, 2012 Share Posted February 12, 2012 (edited) well, kenix code didn't work it does nothing now i saw the updated, thanks for that but it's now serverside My code is wrong I actually was realized. We can't get who create projectile. I think better request parameter attacker for event onVehicleExplode in bug tracker. Edited February 12, 2012 by Guest Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 could u give me a example? Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 Could you help me to update the code caus i get it a little bit conffused in my head Link to comment
Castillo Posted February 12, 2012 Share Posted February 12, 2012 function projectileCreation() local target = getProjectileTarget(source) if (target and getElementType(target) == "vehicle" and getVehicleController(target)) then local player = getVehicleController(target) outputChatBox(getPlayerName(player)) end end addEventHandler("onClientProjectileCreation", getRootElement(), projectileCreation) Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 not working. client and server not working Link to comment
Castillo Posted February 12, 2012 Share Posted February 12, 2012 That's like a example, if the rocket has a target and the target is a vehicle and the vehicle has a driver, then output it's name to the client. Link to comment
Kenix Posted February 12, 2012 Share Posted February 12, 2012 (edited) Client addEventHandler( "onClientProjectileCreation", root, function( creator ) local target = getProjectileTarget( source ) if isElement( target ) and getElementType( target ) == 'vehicle' and isElement( creator ) and getElementType( creator ) == 'vehicle' then local attacker = getVehicleController( creator ) local player = getVehicleController( target ) if isElement( attacker ) and isElement( player ) then triggerServerEvent( 'onVehicleExploded',player,attacker ) end end end ) Server addEvent( 'onVehicleExploded',true ) addEventHandler( 'onVehicleExploded',root, function( attacker ) outputChatBox ( getPlayerName( attacker )..' has killed '..getPlayerName( source )..' with his hunter.',root,255,0,0 ) end ) Updated again. Edited February 12, 2012 by Guest Link to comment
Kenix Posted February 12, 2012 Share Posted February 12, 2012 Try again. And check each row with outputChatBox/outputDebugString. Maybe projectile creator is player ( not vehicle ). Link to comment
denny199 Posted February 12, 2012 Author Share Posted February 12, 2012 will look tommorow thanks realy thanks both 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