Jump to content

Error


WelCome

Recommended Posts

Posted
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 :/
 

 

 

Posted
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

Chillin' with some demons, satans and vamps

Posted

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)

 

Posted (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 by DNL291

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)

I want drop weapon and pick weapon but if u drop two weapon first weapon will didnt
cant pick

Edited by WelCome

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