WelCome Posted March 10, 2018 Share Posted March 10, 2018 function take(thePlayer) if isElementWithinColShape(thePlayer,col) then local ammo = getPickupAmmo(pickup) local bron = getPickupWeapon(pickup) giveWeapon(thePlayer,bron,ammo) outputChatBox("test") destroyElement(col) destroyElement(pickup) end end function weapon_drop (thePlayer) local bron = getPlayerWeapon(thePlayer) local ammo = getPedTotalAmmo(thePlayer) local slot = getPedWeaponSlot(thePlayer) local x,y,z = getElementPosition(thePlayer) local pickup_bron = getPedWeapon(thePlayer) local p = getPedWeapon(thePlayer) if slot > 1 then if ammo > 1 then pickup = createPickup(x,y,z,2,p,0,ammo) col = createColSphere(x,y,z,1.0) addEventHandler("onPickupHit",pickup,take) takeWeapon(thePlayer,p,ammo) end end end addCommandHandler("bind_q",function(thePlayer) bindKey(thePlayer,"U","down",weapon_drop,thePlayer) bindKey(thePlayer,"I","down",take,thePlayer) end) I want to drop weapon,this code work but if is 2 pickup and if u hit 1 pickup, 2 will not work Pls help me Link to comment
SycroX Posted March 11, 2018 Share Posted March 11, 2018 On 3/11/2018 at 00:23, WelCome said: function take(thePlayer) if isElementWithinColShape(thePlayer,col) then local ammo = getPickupAmmo(pickup) local bron = getPickupWeapon(pickup) giveWeapon(thePlayer,bron,ammo) outputChatBox("test") destroyElement(col) destroyElement(pickup) end end function weapon_drop (thePlayer) local bron = getPlayerWeapon(thePlayer) local ammo = getPedTotalAmmo(thePlayer) local slot = getPedWeaponSlot(thePlayer) local x,y,z = getElementPosition(thePlayer) local pickup_bron = getPedWeapon(thePlayer) local p = getPedWeapon(thePlayer) if slot > 1 then if ammo > 1 then pickup = createPickup(x,y,z,2,p,0,ammo) col = createColSphere(x,y,z,1.0) addEventHandler("onPickupHit",pickup,take) takeWeapon(thePlayer,p,ammo) end end end addCommandHandler("bind_q",function(thePlayer) bindKey(thePlayer,"U","down",weapon_drop,thePlayer) bindKey(thePlayer,"I","down",take,thePlayer) end) I want to drop weapon,this code work but if is 2 pickup and if u hit 1 pickup, 2 will not work Pls help me use tables Link to comment
WelCome Posted March 11, 2018 Author Share Posted March 11, 2018 Why this code didn't work tablee = {} col_table = {} local function take(thePlayer) if isElementWithinColShape(thePlayer,col) then local ammo = getPickupAmmo(pickup) local bron = getPickupWeapon(pickup) giveWeapon(thePlayer,bron,ammo) outputChatBox("test") table.remove(col_table) table.remove(tablee) end end local function weapon_drop (thePlayer) local bron = getPlayerWeapon(thePlayer) local ammo = getPedTotalAmmo(thePlayer) local slot = getPedWeaponSlot(thePlayer) local x,y,z = getElementPosition(thePlayer) local pickup_bron = getPedWeapon(thePlayer) local p = getPedWeapon(thePlayer) if slot >= 0 then if ammo >= 0 then pickup = createPickup(x,y,z,2,p,0,ammo) col = createColSphere(x,y,z,1.0) table.insert(col_table,col) takeWeapon(thePlayer,p,ammo) table.insert(tablee,pickup) addEventHandler("onPickupHit",pickup,take) end end end addCommandHandler("bind_q",function(thePlayer) bindKey(thePlayer,"U","down",weapon_drop,thePlayer) bindKey(thePlayer,"I","down",take,thePlayer) end) Link to comment
DNL291 Posted March 11, 2018 Share Posted March 11, 2018 (edited) Could you describe better how your script should work? I have no idea how it supposed to work by looking at the code. Edited March 11, 2018 by DNL291 Link to comment
WelCome Posted March 11, 2018 Author Share Posted March 11, 2018 (edited) I want drop weapon and pick weapon but if u drop two weapon first weapon will didnt cant pick Edited March 11, 2018 by WelCome 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