My code is working 100%, but it makes lag once I switch weapon..
take a look
function Switch(button,press)
wep = getPedWeaponSlot(localPlayer)
a= {}
for z=0,12 do
a[z] = exports.settingPanel:getSetting(tostring(z))
end
if not a then return end
for z= 0,12 do
if button == a[0] then
if(press) then
setPedWeaponSlot(localPlayer, 0)
end
end
if a[0] == a[z+1] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[0] then
if (press) then
if wep == 0 then
setPedWeaponSlot(localPlayer, z+1)
else
setPedWeaponSlot(localPlayer,0)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[2] then
if(press) then
setPedWeaponSlot(localPlayer, 2)
end
end
if a[2] == a[z+3] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[2] then
if (press) then
if wep == 2 then
setPedWeaponSlot(localPlayer, z+3)
else
setPedWeaponSlot(localPlayer,2)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[3] then
if(press) then
setPedWeaponSlot(localPlayer, 3)
end
end
if a[3] == a[z+4] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[3] then
if (press) then
if wep == 3 then
setPedWeaponSlot(localPlayer, z+4)
else
setPedWeaponSlot(localPlayer,3)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[4] then
if(press) then
setPedWeaponSlot(localPlayer, 4)
end
end
if a[4] == a[z+5] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[4] then
if (press) then
if wep == 4 then
setPedWeaponSlot(localPlayer, z+5)
else
setPedWeaponSlot(localPlayer,4)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[5] then
if(press) then
setPedWeaponSlot(localPlayer, 5)
end
end
if a[5] == a[z+6] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[5] then
if (press) then
if wep == 5 then
setPedWeaponSlot(localPlayer, z+6)
else
setPedWeaponSlot(localPlayer,5)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[6] then
if(press) then
setPedWeaponSlot(localPlayer, 6)
end
end
if a[6] == a[z+7] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[6] then
if (press) then
if wep == 6 then
setPedWeaponSlot(localPlayer, z+7)
else
setPedWeaponSlot(localPlayer,6)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[7] then
if(press) then
setPedWeaponSlot(localPlayer, 7)
end
end
if a[7] == a[z+8] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[7] then
if (press) then
if wep ==7 then
setPedWeaponSlot(localPlayer, z+8)
else
setPedWeaponSlot(localPlayer,7)
end
end
end
end)
end
end
for z= 0,12 do
if button == a[8] then
if(press) then
setPedWeaponSlot(localPlayer, 8)
end
end
if a[8] == a[z+9] then
addEventHandler("onClientKey", root, function (button, press)
if button == a[8] then
if (press) then
if wep ==8 then
setPedWeaponSlot(localPlayer, z+9)
else
setPedWeaponSlot(localPlayer,8)
end
end
end
end)
end
end
end
addEventHandler("onClientKey", root, Switch)