greentumbleweed Posted April 10, 2021 Posted April 10, 2021 I'm want to make the function run with a loop for 3 possible weapons and only give/ take away 1 weapon at a time. but it removes primary weapon from back when i equip secondary or vise versa also only equips secondary when equiping any weapon. function rearmPlayerWeapon(weaponName,slot,slot1,slot2,slot3) takeAllWeapons(source) setElementData(source,"currentweapon_"..slot,weaponName) weapon = getElementData(source,"currentweapon_1") if weapon then for id,item in pairs(weaponTable)do if weapon == item[1] and getElementData(source,item[1])>= 1 and getElementData(source,item[2])>= 1 and item[5] == 1 then ammoData,weapID = getWeaponAmmoType(weapon) removeWeaponBack() giveWeapon(source,weapID,getElementData(source,ammoData),slot1) end end end weapon2 = getElementData(source,"currentweapon_2") if weapon2 then for id,item in pairs(weaponTable)do if weapon2 == item[1] and getElementData(source,item[1])>= 1 and ((getElementData(source,item[2]) and getElementData(source,item[2])>= 1) or item[2] == "others") and item[5] == 2 then ammoData2,weapID2 = getWeaponAmmoType(weapon2) removeWeaponBackSec() giveWeapon(source,weapID2,getElementData(source,ammoData2),slot2) end end end weapon3 = getElementData(source,"currentweapon_3") if weapon3 then for id,item in pairs(weaponTable)do if weapon3 == item[1] and getElementData(source,item[1])>= 1 and item[5] == 3 then ammoData3,weapID3 = getWeaponAmmoType(weapon3) removeWeaponBackSpe() giveWeapon(source,weapID3,getElementData(source,ammoData3),slot3) end end end triggerClientEvent(source,"refreshInventoryManual",source) end addEvent("onPlayerRearmWeapon",true) addEventHandler("onPlayerRearmWeapon",getRootElement(),rearmPlayerWeapon)
Moderators Lord Henry Posted April 10, 2021 Moderators Posted April 10, 2021 You need to write in Portuguese if you want to post on the Portuguese Section. Topic moved to international section. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
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