kewizzle Posted March 20, 2014 Posted March 20, 2014 hi guys i need help keeping a weapon that has no ammo so players dont have to rebuy the weapon
Castillo Posted March 20, 2014 Posted March 20, 2014 I guess that you can check everytime when they use the weapon to see if the ammo is 1, then if it is, disable the fire control, and also do the same for when they switch weapons. Events: onClientPlayerWeaponFire onClientPlayerWeaponSwitch Functions: getPedTotalAmmo toggleControl
kewizzle Posted March 20, 2014 Author Posted March 20, 2014 ill see what i can do with the stuff youve given me and ill post a reply of what i did if i have issues
kewizzle Posted March 20, 2014 Author Posted March 20, 2014 couldnt figure it out all i learned is how to make explosive weapons
kewizzle Posted March 20, 2014 Author Posted March 20, 2014 tbh i was lost when i put them together and i deleted it so im going to go into notepad++ and retry and then ill post
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 Heres what i tried addEventHandler( "onWeaponFire", root, function () getPedTotalAmmo(source) if PedAmmo = 0 then getWeaponInSlot(1) or getWeaponInSlot(2) or getWeaponInSlot(3) or getWeaponInSlot(4) or getWeaponInSlot(5) or getWeaponInSlot(6) or getWeaponInSlot(7) or getWeaponInSlot(8) or getWeaponInSlot(9) or getWeaponInSlot(10) or getWeaponInSlot(11) or getWeaponInSlot(12) then giveWeapon(source, weapon, 0) end
Castillo Posted March 21, 2014 Posted March 21, 2014 No offense, but that doesn't make any sense, and I mean no sense at all.
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 im trying to make it get the total ammo and then if the ammo is = to 0 then it would set weapon that was there back in the slot with 0 ammo
Castillo Posted March 21, 2014 Posted March 21, 2014 There's no need to give the weapon back, since you can stop the player from using it again. By the way, "onWeaponFire" will be available in MTA 1.4, it's not available in current versions.
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 oh shit so i can make the weapon unusable if it has 1 ammo...
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 i cant figure it out im looking on the wiki for stuff to do with weapons and i cant find a way to make the weapon unusable
Castillo Posted March 21, 2014 Posted March 21, 2014 local invalidWeapons = -- Define a table with the weapons that won't be checked. { [ 0 ] = true, [ 1 ] = true, [ 2 ] = true, [ 3 ] = true, [ 4 ] = true, [ 5 ] = true, [ 6 ] = true, [ 7 ] = true, [ 8 ] = true, [ 9 ] = true, [ 10 ] = true, [ 11 ] = true, [ 12 ] = true, [ 14 ] = true, [ 15 ] = true, [ 16 ] = true, [ 17 ] = true, [ 18 ] = true, [ 39 ] = true, [ 44 ] = true, [ 45 ] = true, [ 46 ] = true, [ 40 ] = true } addEventHandler ( "onClientPlayerWeaponFire", localPlayer, -- Add the event handler. function ( weapon ) if ( not invalidWeapons [ weapon ] ) then -- If the weapon the player used is not in the invalidWeapons table.. if ( getPedTotalAmmo ( localPlayer ) == 1 ) then -- Check if the weapon ammo is equal to 1, then.. toggleControl ( "fire", false ) -- Disable the fire control, so the player can no longer fire. end -- End the ammo check end -- End the invalid weapon check end -- End the function ) addEventHandler ( "onClientPlayerWeaponSwitch", localPlayer, -- Add the event handler. function ( ) toggleControl ( "fire", true ) -- Enable the fire control. local weapon = getPedWeapon ( localPlayer ) -- Get the player current weapon. if ( not invalidWeapons [ weapon ] ) then -- If the weapon the player is not in the invalidWeapons table.. if ( getPedTotalAmmo ( localPlayer ) == 1 ) then -- Check if the weapon ammo is equal to 1, then.. toggleControl ( "fire", false ) -- Disable the fire control, so the player can no longer fire. end -- End the ammo check end -- End the invalid weapon check end -- End the function ) 1
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 OMG thanks so much now im going to read through it and see how it works
Castillo Posted March 21, 2014 Posted March 21, 2014 See if it works when you switch weapons, because it didn't work out on my local server, but I think it's because of one of my scripts messing around.
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 Yes when i give the weapon back with ammo wont shoot till i switch weapons and switch back but thats okay whos gonna stay on the same weapon while having zombies chase them lol theyll probably switch weapons on the way to get ammo anyway but thanks works perfect and i understand the script now i read through it and the side notes.
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