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 MTA:SA Scripting Is Fun!
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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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 MTA:SA Scripting Is Fun!
kewizzle Posted March 20, 2014 Author Posted March 20, 2014 couldnt figure it out all i learned is how to make explosive weapons MTA:SA Scripting Is Fun!
Castillo Posted March 20, 2014 Posted March 20, 2014 Post what you've tried. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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 MTA:SA Scripting Is Fun!
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 MTA:SA Scripting Is Fun!
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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 my bad i started a week ago help MTA:SA Scripting Is Fun!
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 MTA:SA Scripting Is Fun!
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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
kewizzle Posted March 21, 2014 Author Posted March 21, 2014 oh shit so i can make the weapon unusable if it has 1 ammo... MTA:SA Scripting Is Fun!
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 MTA:SA Scripting Is Fun!
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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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 MTA:SA Scripting Is Fun!
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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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. MTA:SA Scripting Is Fun!
Castillo Posted March 21, 2014 Posted March 21, 2014 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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