Jaysds1 Posted May 12, 2012 Posted May 12, 2012 (edited) you could use: onClientPlayerWeaponFire after getting what the client/player shot at, use addEventHandler("onClientPlayerWeaponFire",localPlayer,function() if(getElementType(hitElement)=="vehicle)"then --YOUR CODE end end) Edited May 12, 2012 by Guest My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Booo Posted May 12, 2012 Posted May 12, 2012 How to get a player who shoots at the car. Client side !! function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if getElementType(hitElement)=="Vehicle" then outputChatBox (..getPlayerName(getLocalPlayer()).."np shot car",getRootElement(), 0, 255, 0 ) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) تذكر عند تصفحك للأنترنت قوله تعالى: (( وهو معكم أين ما كنتم والله بما تعملون بصير )) ا
Michael# Posted May 12, 2012 Posted May 12, 2012 (edited) Your code is wrong Booo. addEventHandler ( 'onClientPlayerWeaponFire', root, function ( _, _, _, _, _, _, uHit ) if ( getElementType ( uHit ) == 'vehicle' ) then outputChatBox ( getPlayerName ( source ) .. ' shooted on ' .. getPlayerName ( getPedOccupiedVehicle ( uHit ) ), 255, 255, 255, false ) end end ) Edited May 12, 2012 by Guest
Castillo Posted May 12, 2012 Posted May 12, 2012 @Michael#: You're wrong as well, outputChatBox client side doesn't has a visibleTo argument. -- client side: addEventHandler ( "onClientPlayerWeaponFire", root, function ( _, _, _, _, _, _, uHit ) if ( uHit and getElementType ( uHit ) == "vehicle" ) then triggerServerEvent ( "sendMessage", localPlayer, uHit ) end end ) -- server side: addEvent ( "sendMessage", true ) addEventHandler ( "sendMessage", root, function ( vehicle ) if ( vehicle ) then outputChatBox ( getPlayerName ( source ) .." shooted on ".. getVehicleName ( vehicle ), root, 255, 255, 255, false ) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted May 12, 2012 Posted May 12, 2012 Also, you we're using getPlayerName on a vehicle element. And you also use getPedOccupiedVehicle, but you already have a vehicle element which is "uHit". San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Michael# Posted May 13, 2012 Posted May 13, 2012 Fuu I confused getPedOccupiedVehicle with getVehicleController.
arezu Posted May 13, 2012 Posted May 13, 2012 If you are using solidsnakes code, remember to use getLocalPlayer() (like you Jaysds1 did in his reply) instead of root, because otherwise it will trigger for every player that has the shooter in its streaming range.
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