SkiZo Posted January 4, 2017 Posted January 4, 2017 Hello , I Created A script ! it's work but the problem that ! the minigun not allowed in all the server how can i make it not allowed only in "Challenges area" Challenges area ! Deathmatch Make you make event vs other player ! Use any gun but not minigun !! this is the script --- --- function antiminigun ( previousWeaponID, currentWeaponID ) --when a player switches his weapon if currentWeaponID == 38 then local name = getClientName ( source ) local weapon = getWeaponNameFromID ( currentWeaponID ) outputChatBox ( "You Can not use This Weapon in this Area", source, 255, 100, 0,true ) PN = getPlayerFromNick (name) toggleControl (source, "fire", false) else toggleControl (source, "fire", true) end end addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), antiminigun ) -- -- this is the area local skintable = { [10] = true, [11] = true, [12] = true, [13] = true, [14] = true, [15] = true, [17] = true, [16] = true, [18] = true, [19] = true, [20] = true, [21] = true, [22] = true, [24] = true} --Zombie Skinszone1 = createColCuboid ( 112.9927444458, 1337.1772460938, 10, 170, 150, 255 ) safeZoneRadar = createRadarArea ( 112.9927444458, 1337.1772460938, 170, 150, 0, 0, 0, 0 ) setElementData (safeZoneRadar, "zombieProof", true) function outZone(hitPlayer,thePlayer) function inZone(hitPlayer,thePlayer) local skin = getElementModel (hitPlayer) if not skintable[getElementModel(hitPlayer)] then --if not zombie toggleControl (hitPlayer, "fire", true) toggleControl (hitPlayer, "next_weapon", true) toggleControl (hitPlayer, "previous_weapon", true) toggleControl (hitPlayer, "prelaus_weapon", true) toggleControl (hitPlayer, "aim_weapon", true) toggleControl (hitPlayer, "vehicle_fire", false) else --if zombie killPed (hitPlayer) --kill zombie end end addEventHandler( "onColShapeHit", zone1, inZone ) local skin = getElementModel (hitPlayer) toggleControl (hitPlayer, "fire", true) toggleControl (hitPlayer, "next_weapon", true) toggleControl (hitPlayer, "previous_weapon", true) toggleControl (hitPlayer, "prelaus_weapon", true) toggleControl (hitPlayer, "aim_weapon", true) toggleControl (hitPlayer, "vehicle_fire", true) if skintable[getElementModel(hitPlayer)] then killPed (hitPlayer) --kill zombie end end addEventHandler( "onColShapeLeave", zone1, outZone )
iPrestege Posted January 4, 2017 Posted January 4, 2017 (edited) You can simply use isElementWithinColShape with onPlayerWeaponSwitch to toggleControl. @S.W.A.T Edited January 4, 2017 by iPrestege typo
iPrestege Posted January 4, 2017 Posted January 4, 2017 addEventHandler ( 'onPlayerWeaponSwitch',root, function ( _,aMyWeapon ) if isElementWithinColShape( source,zone1 ) and aMyWeapon == 38 then toggleControl( source,'fire',false ); else toggleControl( source,'fire',true ); end end ); remove the antiminigun function and use this ^^ @S.W.A.T
SkiZo Posted January 4, 2017 Author Posted January 4, 2017 (edited) [2017-01-04 19:41:48] WARNING: ChallengeArea\safetyzone.lua:39: Bad argument @ 'isElementWithinColShape' [Expected colshape at argument 2, got nil] [DUP x4] Thank You Very Much It's Work Thank You Thank you !! @iPrestege Edited January 4, 2017 by S.W.A.T Nothing littel mistake :v
iPrestege Posted January 4, 2017 Posted January 4, 2017 You're welcome not a problem just i thought your colshape variable is 'zone1' because it's in the event anyways glad to hear that enjoy.
SkiZo Posted January 4, 2017 Author Posted January 4, 2017 Yeah Was Named Only 'zone' but i change it to 'zone1' and every thing is good thanks again !! if i wonna to add other gun like Sniper i use aMyWeapon == 38 or aMyWeapon ==34 then ??? And If I Wonna to add That output chat and be visible to that player who use MiniGun shoold i add outputChatBox ( "You Can not use This Weapon in this Event", source, 255, 100, 0,true ) or outputChatBox ( "You Can not use This Weapon in this Event", hitPlayer, 255, 100, 0,true ) ???? @iPrestege
iPrestege Posted January 4, 2017 Posted January 4, 2017 Yes use or aMyWeapon == weaponID and about the message just change hitPlayer with source because it's the player in the event.
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