zombienation Posted March 18, 2012 Share Posted March 18, 2012 hello, i am searching for blocking the function "fire" with guns i want to have it so players can use weaponslot 1 with meelee weapons, i do this to block it in the area function entergym3(hitPlayer) if getElementType(hitPlayer) == "player" then if (getPedWeaponSlot(hitPlayer) ~= 8 ) and (isPedOnGround(hitPlayer)) and (getPedOccupiedVehicle(hitPlayer) == false) then setElementInterior ( hitPlayer, 0 ) setElementPosition ( hitPlayer, 2553, -1288, 1015 ) toggleControl ( hitPlayer, "fire", true ) toggleControl ( hitPlayer, "aim_weapon", true ) toggleControl ( hitPlayer, "next_weapon", false ) toggleControl ( hitPlayer, "previous_weapon", false ) end end end addEventHandler ( "onMarkerHit", gymentrance, entergym3 ) i tried to add this but that didn't worked setPedWeaponSlot ( hitPlayer, 2 ) for those who are interested i'm working with this resource, file lvboxing_server.lua https://community.multitheftauto.com/index.php?p= ... ils&id=458 thx Link to comment
Castillo Posted March 18, 2012 Share Posted March 18, 2012 You want to block "fire" control or force the player to only use slot 1? Link to comment
zombienation Posted March 18, 2012 Author Share Posted March 18, 2012 yes, but i actually ment slot 2, i was wrong when i made the topic, slot 1 is knuckels and 2 is meelee right? the enter fym function is when players enter the place where it happens, but there is an other marker, to go to the location to hold the fight, its after that second marker i'd like to do this, its ok if players, watching the find cant use any weapons, but inside the "arena" i'd like to put the weaponslot on, i got it to work one time, it gave me the meelee slot, but i wasn't able to "fire", for that i tought its maybe handy to add the full lua http://pastebin.com/LJ7wBCE1 Edit: oh btw dont mind this pls function enterboxingring(hitPlayer) if source == boxingmarker and getElementType(hitPlayer) == "player" then setPedWeaponSlot ( hitPlayer, 1 ) if boxingplayers == 0 then i was trying to do it there while i was replying here, but it didn't worked, when it was on 2 Link to comment
Castillo Posted March 18, 2012 Share Posted March 18, 2012 Use the event onPlayerWeaponSwitch to check if the slot isn't 2, set it back to 2 with setPedWeaponSlot. Link to comment
zombienation Posted March 18, 2012 Author Share Posted March 18, 2012 by that u mean onPlayerWeaponSwitch ( hitPlayer, 2 ) or function enterboxingring(hitPlayer) onPlayerWeaponSwitch == 2 then toggleControl ( source, "fire", true ) --enable it end end i just realised that "slot 2" was actually weapon id 2, but still when its on slot 1 or 2 in script, inside the fight place they spawn with fist, what maybe could give extra options for this, there are two meelee weapon pickups in the battle arena, maybe there is something alse then setslot or weaponswitch that works with activating the weapon by a pickup? somehow, idk.. Edit: when i added onPlayerWeaponSwitch ( hitPlayer, 1 ) to enter the first marker, the ped spawned with the meelee in his hand, when i went in the second marker, it were fists again, when i added the line on the blue/red player sides for the fight, they still spawned with there fists, they were able to pickup the pickup, but it didn't turned on slot two, and scrolling in weapons is on false to block the other weapons.. Link to comment
Castillo Posted March 19, 2012 Share Posted March 19, 2012 Is a event handler not a function. This event is triggered whenever a player's equipped weapon slot changes. This means giveWeapon and takeWeapon will trigger this function if the equipped slot is forced to change. Link to comment
zombienation Posted March 19, 2012 Author Share Posted March 19, 2012 well i'm kinda stuck lol Link to comment
Al3grab Posted March 19, 2012 Share Posted March 19, 2012 addEventHandler("onPlayerWeaponSwitch",root, function() --- here comes your code end ) 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