Jump to content

Error


WelCome

Recommended Posts

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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...