Axel Posted March 6, 2012 Share Posted March 6, 2012 So i made 2 little scripts: function onEnter ( theVehicle, seat, jacked ) local veh = getVehicleName ( theVehicle ) exports.global:sendLocalMeAction(source, "intra in vehiculul "..veh..".") end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnter ) -- When someone enters the vehicle, a local me action is sent.. and function weaponSwitch ( previousWeaponID, currentWeaponID ) if currentWeaponID == 3 then exports.global:sendLocalMeAction(source, "scoate un baston de politist.") elseif currentWeaponID == 4 then exports.global:sendLocalMeAction(source, "scoate un cutit.") elseif currentWeaponID == 2 then exports.global:sendLocalMeAction(source, "scoate o crosa de golf.") elseif currentWeaponID == 5 then exports.global:sendLocalMeAction(source, "scoate o bata de baseball.") elseif currentWeaponID == 6 then exports.global:sendLocalMeAction(source, "scoate o lopata.") elseif currentWeaponID == 7 then exports.global:sendLocalMeAction(source, "scoate o bata de biliard.") elseif currentWeaponID == 8 then exports.global:sendLocalMeAction(source, "scoate o sabie.") elseif currentWeaponID == 9 then exports.global:sendLocalMeAction(source, "scoate o drujba.") elseif currentWeaponID == 22 then exports.global:sendLocalMeAction(source, "scoate un pistol.") elseif currentWeaponID == 23 then exports.global:sendLocalMeAction(source, "scoate un pistol cu amortizor.") elseif currentWeaponID == 24 then exports.global:sendLocalMeAction(source, "scoate un pistol.") elseif currentWeaponID == 25 then exports.global:sendLocalMeAction(source, "scoate un shotgun.") elseif currentWeaponID == 26 then exports.global:sendLocalMeAction(source, "scoate un shotgun improvizat.") elseif currentWeaponID == 27 then exports.global:sendLocalMeAction(source, "scoate un shotgun de elita.") elseif currentWeaponID == 28 then exports.global:sendLocalMeAction(source, "scoate un Uzi.") elseif currentWeaponID == 29 then exports.global:sendLocalMeAction(source, "scoate un MP5.") elseif currentWeaponID == 30 then exports.global:sendLocalMeAction(source, "scoate un Ak-47.") elseif currentWeaponID == 31 then exports.global:sendLocalMeAction(source, "scoate un M4.") elseif currentWeaponID == 32 then exports.global:sendLocalMeAction(source, "scoate un Tech-9.") elseif currentWeaponID == 34 then exports.global:sendLocalMeAction(source, "scoate un Sniper.") end end addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitch ) -- When someone changes his weapon, a local me action is sent The problem is that when someone enters a vehicle a local action saying that he takes out a Uzi is sent. Does somebody knows how can i cancel the showing of that message? Link to comment
Evil-Cod3r Posted March 6, 2012 Share Posted March 6, 2012 (edited) Use this elseif currentWeaponID == 28 then cancelEvent() Edited March 6, 2012 by Guest Link to comment
Axel Posted March 6, 2012 Author Share Posted March 6, 2012 There is no error in the scripts, it's just the thing that in MTA/GTA shows u some weapons with you can shot from the vehicle when u enter it. In my case Uzi . So what i need help in is that when they enter the car, the message to not appear. Link to comment
Castillo Posted March 6, 2012 Share Posted March 6, 2012 You can try checking if the player is on a vehicle. function weaponSwitch ( previousWeaponID, currentWeaponID ) if isPedInVehicle(source) then return end if (currentWeaponID == 3) then exports.global:sendLocalMeAction(source, "scoate un baston de politist.") elseif (currentWeaponID == 4) then exports.global:sendLocalMeAction(source, "scoate un cutit.") elseif (currentWeaponID == 2) then exports.global:sendLocalMeAction(source, "scoate o crosa de golf.") elseif (currentWeaponID == 5) then exports.global:sendLocalMeAction(source, "scoate o bata de baseball.") elseif (currentWeaponID == 6) then exports.global:sendLocalMeAction(source, "scoate o lopata.") elseif (currentWeaponID == 7) then exports.global:sendLocalMeAction(source, "scoate o bata de biliard.") elseif (currentWeaponID == -- s8) --> then exports.global:sendLocalMeAction(source, "scoate o sabie.") elseif (currentWeaponID == 9) then exports.global:sendLocalMeAction(source, "scoate o drujba.") elseif (currentWeaponID == 22) then exports.global:sendLocalMeAction(source, "scoate un pistol.") elseif (currentWeaponID == 23) then exports.global:sendLocalMeAction(source, "scoate un pistol cu amortizor.") elseif (currentWeaponID == 24) then exports.global:sendLocalMeAction(source, "scoate un pistol.") elseif (currentWeaponID == 25) then exports.global:sendLocalMeAction(source, "scoate un shotgun.") elseif (currentWeaponID == 26) then exports.global:sendLocalMeAction(source, "scoate un shotgun improvizat.") elseif (currentWeaponID == 27) then exports.global:sendLocalMeAction(source, "scoate un shotgun de elita.") elseif (currentWeaponID == 28) then exports.global:sendLocalMeAction(source, "scoate un Uzi.") elseif (currentWeaponID == 29) then exports.global:sendLocalMeAction(source, "scoate un MP5.") elseif (currentWeaponID == 30) then exports.global:sendLocalMeAction(source, "scoate un Ak-47.") elseif (currentWeaponID == 31) then exports.global:sendLocalMeAction(source, "scoate un M4.") elseif (currentWeaponID == 32) then exports.global:sendLocalMeAction(source, "scoate un Tech-9.") elseif (currentWeaponID == 34) then exports.global:sendLocalMeAction(source, "scoate un Sniper.") end end addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitch ) -- When someone changes his weapon, a local me action is sent P.S: Don't listen to Evil, he keep's posting random stuff to increase his post count. Link to comment
Evil-Cod3r Posted March 6, 2012 Share Posted March 6, 2012 No Castillo. iam not increase My post i swear ! iam trying to help others Link to comment
Axel Posted March 6, 2012 Author Share Posted March 6, 2012 That worked just fine:D Thanks Solidsnake14. Now i'm trying to show a me action when the player is targeting a player or a car. function onPlayerTarget ( targetElem ) target = getElementType ( targetElem ) if target and getElementModel ( targetElem ) == 'player' then exports.global:sendLocalMeAction(source, "tinteste spre "..target..".") elseif target and getElementModel ( targetElem ) == 'vehicle' then exports.global:sendLocalMeAction(source, "tinteste spre "..target..".") else return end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget ) -- This shows a warning : 2:Bad argument: getElementType Link to comment
Castillo Posted March 6, 2012 Share Posted March 6, 2012 function onPlayerTarget ( targetElem ) if (targetElem and isElement(targetElem)) then if (getElementType ( targetElem ) == 'player') then exports.global:sendLocalMeAction(source, "tinteste spre ".. getPlayerName(targetElem) ..".") elseif (getElementType ( targetElem ) == 'vehicle' ) then exports.global:sendLocalMeAction(source, "tinteste spre ".. getVehicleName(targetElem) ..".") end end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget ) Do you mean that? Link to comment
Axel Posted March 6, 2012 Author Share Posted March 6, 2012 Yes, that's what i mean. But i noticed it spams the chatbox, is there a way to show it only one time? Link to comment
Castillo Posted March 6, 2012 Share Posted March 6, 2012 I don't know, maybe you can make a check to see if the target is the same as current. Something like this could work: local targeting = {} function onPlayerTarget ( targetElem ) if (targetElem and isElement(targetElem) and targeting[source] ~= targetElem) then if (getElementType ( targetElem ) == 'player') then exports.global:sendLocalMeAction(source, "tinteste spre ".. getPlayerName(targetElem) ..".") elseif (getElementType ( targetElem ) == 'vehicle' ) then exports.global:sendLocalMeAction(source, "tinteste spre ".. getVehicleName(targetElem) ..".") end targeting[source] = targetElem end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget ) 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