Jump to content

[Error] Help please


Recommended Posts

I mean...after the objects spawn in one time...how i defined them to use themm???

I'm having trouble understanding your English, if you're talking about an object like

local pbags = { 
    {2293.154, 561.47, 7.78}, 
    {2287.2265625, 566.3486328125, 7.78125} 
} 
  
    for _, i in ipairs(pbags) do 
       local baga = createPickup(i[1], i[2], i[3], 3, 1210) 
    end 

You can add another location by adding coordinates with brackets around them, like the example below.

local pbags = { 
    {2293.154, 561.47, 7.78}, 
    {2287.2265625, 566.3486328125, 7.78125} 
    {x,y,z} -- replace x,y,z with your coordinates. 
} 
  
    for _, i in ipairs(pbags) do 
       local baga = createPickup(i[1], i[2], i[3], 3, 1210) 
    end 

Link to comment
  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

Alright ...well now when all objects spawned in one time....when i try to pick up the object...it don't be attached to me... why?

Because 1210 is an ID of an object(suitcase), not a pickup. If you want to attach the suitcase to you, use

attachElements 

I'm using Bone attach

   bagb = createObject(1210, 0, 0, 0) 
            exports.bone_attach:attachElementToBone(bagb,player,12,0,0.1,0.3,0,180,0 

so why don't be attached?

Link to comment
Alright ...well now when all objects spawned in one time....when i try to pick up the object...it don't be attached to me... why?

Because 1210 is an ID of an object(suitcase), not a pickup. If you want to attach the suitcase to you, use

attachElements 

I'm using Bone attach

   bagb = createObject(1210, 0, 0, 0) 
            exports.bone_attach:attachElementToBone(bagb,player,12,0,0.1,0.3,0,180,0 

so why it don't be attached?

Link to comment

ِAlright...i've tried ti attach the pickup....but still not work..see

local pbags = { 
    {2028.2314453125, 648.09765625, 11.366704940796}, 
    {2340.6474609375, 750.9208984375, 11.218271255493}, 
    {1632.525390625, 1035.7626953125, 13.769004821777}, 
    {1494.2626953125, 751.025390625, 29.161626815796}, 
    {1454.25, 751.05859375, 32.736267089844}, 
    {1533.3515625, 751.1181640625, 32.64266204834}, 
    {1427.3037109375, 1462.958984375, 10.8203125} 
     
} 
  
    for _, i in ipairs(pbags) do 
       local baga = createPickup(i[1], i[2], i[3], 3, 1210) 
    end 
     
function onPickupHit(player) 
    if source == baga then 
        if not isPedInVehicle(player) and not isPedDead(player) then 
            exports.bone_attach:attachElementToBone(baga,player,12,0,0.1,0.3,0,180,0) 
            destroyElement(source) 
        end 
    end 
end 
addEventHandler("onPickupHit", root, onPickupHit) 
  
function onBtnClick() 
    local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(baga) 
    if atthedTo == source then 
        local money = math.random(1000, 2000) 
        givePlayerMoney(source, money) 
        destroyElement(baga) 
         
       setTimer(function() x, y, z = unpack(pbags[math.random(#pbags)])     
        baga = createPickup(x, y, z, 3, 1210) 
    end, 50000, 1) 
        triggerClientEvent(source, "WarningText", source, "reward", "You have rewarded and got "..money.. "$ from the dealer!! Good Job Pro!") 
        outputChatBox ("you have Rewarded and got "..money.."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false) 
        triggerClientEvent (source,"winSound", source) 
    else 
        triggerClientEvent(source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!")       
    end 
end 
addEvent("reward", true) 
addEventHandler ("reward", root, onBtnClick) 
  
function onPlayerQuit() 
    local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(baga) 
    if atthedTo == source then 
        destroyElement(baga) 
        local x, y, z = getElementPosition(source) 
        baga = createPickup(x, y, z, 3, 1210) 
    end 
end 
addEventHandler("onPlayerQuit", root, onPlayerQuit) 

Link to comment
ِAlright...i've tried ti attach the pickup....but still not work..see
exports.bone_attach:attachElementToBone(baga,player,12,0,0.1,0.3,0,180,0) 

You made baga a local variable, so it wouldn't work. Change

local baga = createPickup(i[1], i[2], i[3], 3, 1210) 

to

baga = createPickup(i[1], i[2], i[3], 3, 1210) 

Link to comment
ِAlright...i've tried ti attach the pickup....but still not work..see
exports.bone_attach:attachElementToBone(baga,player,12,0,0.1,0.3,0,180,0) 

You made baga a local variable, so it wouldn't work. Change

local baga = createPickup(i[1], i[2], i[3], 3, 1210) 

to

baga = createPickup(i[1], i[2], i[3], 3, 1210) 

Didn't Change anything . :/

Link to comment
Why are you attaching the pickup and then destroying it?

ah...yes...found it i was removing it...whatever the pickup attach is really bad...so i made attached object and attached it..anyway :) Thanks a lot... and actually without your reply i wasn't will check the script again xD!

ah...but still there's a problem....if the player pickup it then if if destroyElement (baga) all pickups will be destroyed :/... and i need only the pickup which the player picked be destroyed..how to do this

Link to comment
Why are you attaching the pickup and then destroying it?

ah...yes...found it i was removing it...whatever the pickup attach is really bad...so i made attached object and attached it..anyway :) Thanks a lot... and actually without your reply i wasn't will check the script again xD!

ah...but still there's a problem....if the player pickup it then if if destroyElement (baga) all pickups will be destroyed :/... and i need only the pickup which the player picked be destroyed..how to do this

can i describe the x, y, z by this table?

local pbags = { 
    1 = {2028.2314453125, 648.09765625, 11.366704940796}, 
    2 = {2340.6474609375, 750.9208984375, 11.218271255493}, 
    3 = {1632.525390625, 1035.7626953125, 13.769004821777}, 
    4 = {1494.2626953125, 751.025390625, 29.161626815796}, 
    5 = {1454.25, 751.05859375, 32.736267089844}, 
    6 = {1533.3515625, 751.1181640625, 32.64266204834}, 
    7 = {1427.3037109375, 1462.958984375, 10.8203125} 
     
} 

Link to comment
Post your new code.
local pbags = { 
    1 = {2028.2314453125, 648.09765625, 11.366704940796}, 
    2 = {2340.6474609375, 750.9208984375, 11.218271255493}, 
    3 = {1632.525390625, 1035.7626953125, 13.769004821777}, 
    4 = {1494.2626953125, 751.025390625, 29.161626815796}, 
    5 = {1454.25, 751.05859375, 32.736267089844}, 
    6 = {1533.3515625, 751.1181640625, 32.64266204834}, 
    7 = {1427.3037109375, 1462.958984375, 10.8203125} 
     
} 
    for _, i in ipairs(pbags) do 
        baga = createPickup(i[1], i[2], i[3], 3, 1210) 
        bagb = createObject(1210, 0, 0, 0) 
    end 
     
function onPickupHit(player) 
        if not isPedInVehicle(player) and not isPedDead(player) then 
            exports.bone_attach:attachElementToBone(bagb,player,12,0,0.1,0.3,0,180,0) 
        end 
    end 
addEventHandler("onPickupHit", root, onPickupHit) 
  
function onBtnClick() 
    local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) 
    if atthedTo == source then 
        local money = math.random(1000, 2000) 
        givePlayerMoney(source, money) 
        destroyElement(bagb) 
  
        triggerClientEvent(source, "WarningText", source, "reward", "You have rewarded and got "..money.. "$ from the dealer!! Good Job Pro!") 
        outputChatBox ("you have Rewarded and got "..money.."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false) 
        triggerClientEvent (source,"winSound", source) 
    else 
        triggerClientEvent(source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!")       
        end 
    end 
addEvent("reward", true) 
addEventHandler ("reward", root, onBtnClick) 
  
function onPlayerQuit() 
    local atthedTo = exports.bone_attach:getElementBoneAttachmentDetails(bagb) 
    if atthedTo == source then 
        destroyElement(bagb) 
        local x, y, z = getElementPosition(source) 
        baga = createPickup(x, y, z, 3, 1210) 
    end 
end 
addEventHandler("onPlayerQuit", root, onPlayerQuit) 

Link to comment
local pbags = 
{ 
    {2028.2314453125, 648.09765625, 11.366704940796}, 
    {2340.6474609375, 750.9208984375, 11.218271255493}, 
    {1632.525390625, 1035.7626953125, 13.769004821777}, 
    {1494.2626953125, 751.025390625, 29.161626815796}, 
    {1454.25, 751.05859375, 32.736267089844}, 
    {1533.3515625, 751.1181640625, 32.64266204834}, 
    {1427.3037109375, 1462.958984375, 10.8203125} 
} 
local bags = { } 
local gotBag = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, i in ipairs ( pbags ) do 
            local baga = createPickup(i[1], i[2], i[3], 3, 1210 ) 
            local bagb = createObject ( 1210, 0, 0, 0 ) 
            addEventHandler ( "onPickupHit", baga, onPickupHit ) 
            bags [ baga ] = bagb 
        end 
    end 
) 
    
function onPickupHit ( player ) 
    if ( not isPedInVehicle ( player ) and not isPedDead ( player ) ) then 
        exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
        gotBag [ player ] = bags [ source ] 
        destroyElement ( source ) 
    end 
end 
  
function onBtnClick ( ) 
    if ( gotBag [ source ] ) then 
        local money = math.random ( 1000, 2000 ) 
        givePlayerMoney ( source, money ) 
        destroyElement ( gotBag [ source ] ) 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have rewarded and got ".. money .. "$ from the dealer!! Good Job Pro!" ) 
        outputChatBox ( "you have Rewarded and got ".. money .."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false ) 
        triggerClientEvent ( source,"winSound", source ) 
    else 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!" ) 
    end 
end 
addEvent ( "reward", true ) 
addEventHandler ( "reward", root, onBtnClick ) 
  
function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        baga = createPickup ( x, y, z, 3, 1210 ) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

Link to comment
local pbags = 
{ 
    {2028.2314453125, 648.09765625, 11.366704940796}, 
    {2340.6474609375, 750.9208984375, 11.218271255493}, 
    {1632.525390625, 1035.7626953125, 13.769004821777}, 
    {1494.2626953125, 751.025390625, 29.161626815796}, 
    {1454.25, 751.05859375, 32.736267089844}, 
    {1533.3515625, 751.1181640625, 32.64266204834}, 
    {1427.3037109375, 1462.958984375, 10.8203125} 
} 
local bags = { } 
local gotBag = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, i in ipairs ( pbags ) do 
            local baga = createPickup(i[1], i[2], i[3], 3, 1210 ) 
            local bagb = createObject ( 1210, 0, 0, 0 ) 
            addEventHandler ( "onPickupHit", baga, onPickupHit ) 
            bags [ baga ] = bagb 
        end 
    end 
) 
    
function onPickupHit ( player ) 
    if ( not isPedInVehicle ( player ) and not isPedDead ( player ) ) then 
        exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
        gotBag [ player ] = bags [ source ] 
        destroyElement ( source ) 
    end 
end 
  
function onBtnClick ( ) 
    if ( gotBag [ source ] ) then 
        local money = math.random ( 1000, 2000 ) 
        givePlayerMoney ( source, money ) 
        destroyElement ( gotBag [ source ] ) 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have rewarded and got ".. money .. "$ from the dealer!! Good Job Pro!" ) 
        outputChatBox ( "you have Rewarded and got ".. money .."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false ) 
        triggerClientEvent ( source,"winSound", source ) 
    else 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!" ) 
    end 
end 
addEvent ( "reward", true ) 
addEventHandler ( "reward", root, onBtnClick ) 
  
function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        baga = createPickup ( x, y, z, 3, 1210 ) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

Please...can you explain what you did? because for me you made Complex things :)

Link to comment
local pbags = 
{ 
    {2028.2314453125, 648.09765625, 11.366704940796}, 
    {2340.6474609375, 750.9208984375, 11.218271255493}, 
    {1632.525390625, 1035.7626953125, 13.769004821777}, 
    {1494.2626953125, 751.025390625, 29.161626815796}, 
    {1454.25, 751.05859375, 32.736267089844}, 
    {1533.3515625, 751.1181640625, 32.64266204834}, 
    {1427.3037109375, 1462.958984375, 10.8203125} 
} 
local bags = { } 
local gotBag = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, i in ipairs ( pbags ) do 
            local baga = createPickup(i[1], i[2], i[3], 3, 1210 ) 
            local bagb = createObject ( 1210, 0, 0, 0 ) 
            addEventHandler ( "onPickupHit", baga, onPickupHit ) 
            bags [ baga ] = bagb 
        end 
    end 
) 
    
function onPickupHit ( player ) 
    if ( not isPedInVehicle ( player ) and not isPedDead ( player ) ) then 
        exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
        gotBag [ player ] = bags [ source ] 
        destroyElement ( source ) 
    end 
end 
  
function onBtnClick ( ) 
    if ( gotBag [ source ] ) then 
        local money = math.random ( 1000, 2000 ) 
        givePlayerMoney ( source, money ) 
        destroyElement ( gotBag [ source ] ) 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have rewarded and got ".. money .. "$ from the dealer!! Good Job Pro!" ) 
        outputChatBox ( "you have Rewarded and got ".. money .."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false ) 
        triggerClientEvent ( source,"winSound", source ) 
    else 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!" ) 
    end 
end 
addEvent ( "reward", true ) 
addEventHandler ( "reward", root, onBtnClick ) 
  
function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        baga = createPickup ( x, y, z, 3, 1210 ) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

Please...can you explain what you did? because for me you made Complex things :)

I have tried to add

        if ( not isPedInVehicle ( player ) and not isPedDead ( player ) and not gotBag [ source ]  ) then 

""and not gotBag [ source ] ... i'm just copied it from the

            destroyElement ( gotBag [ source ] ) 

because it's only thing i understand..because i don't know how i check if the bagb attached to the player after you changed it to more tables :/ .. can you tell me how i describ if bagb attached ? in the script after this edits? :/

Link to comment
Change 'source' to 'player'.

Still able to pick another one ...

    function onPickupHit ( player ) 
        if ( not isPedInVehicle ( player ) and not isPedDead ( player ) and not gotBag [ player ]  ) then 
            exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
            gotBag [ player ] = bags [ source ] 
            destroyElement ( source ) 
        end 
    end 

Link to comment
Change 'source' to 'player'.

Still able to pick another one ...

    function onPickupHit ( player ) 
        if ( not isPedInVehicle ( player ) and not isPedDead ( player ) and not gotBag [ player ]  ) then 
            exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
            gotBag [ player ] = bags [ source ] 
            destroyElement ( source ) 
        end 
    end 

When i'm tried to click on the btn without the bag .. i get my rewards too o.O why?! ?! ?!

and when i click without the bag i get error too:

:37: Bad argument @ 'destroyElement' [Expected element at argument 1] 

Link to comment
local pbags = 
{ 
    {2028.2314453125, 648.09765625, 11.366704940796}, 
    {2340.6474609375, 750.9208984375, 11.218271255493}, 
    {1632.525390625, 1035.7626953125, 13.769004821777}, 
    {1494.2626953125, 751.025390625, 29.161626815796}, 
    {1454.25, 751.05859375, 32.736267089844}, 
    {1533.3515625, 751.1181640625, 32.64266204834}, 
    {1427.3037109375, 1462.958984375, 10.8203125} 
} 
local bags = { } 
local gotBag = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, i in ipairs ( pbags ) do 
            local baga = createPickup(i[1], i[2], i[3], 3, 1210 ) 
            local bagb = createObject ( 1210, 0, 0, 0 ) 
            addEventHandler ( "onPickupHit", baga, onPickupHit ) 
            bags [ baga ] = bagb 
        end 
    end 
) 
    
function onPickupHit ( player ) 
    if ( not isPedInVehicle ( player ) and not isPedDead ( player ) and not gotBag [ player ] ) then 
        exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
        gotBag [ player ] = bags [ source ] 
        destroyElement ( source ) 
    end 
end 
  
function onBtnClick ( ) 
    if ( gotBag [ source ] ) then 
        local money = math.random ( 1000, 2000 ) 
        givePlayerMoney ( source, money ) 
        destroyElement ( gotBag [ source ] ) 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have rewarded and got ".. money .. "$ from the dealer!! Good Job Pro!" ) 
        outputChatBox ( "you have Rewarded and got ".. money .."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false ) 
        triggerClientEvent ( source,"winSound", source ) 
        gotBag [ source ] = nil 
    else 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!" ) 
    end 
end 
addEvent ( "reward", true ) 
addEventHandler ( "reward", root, onBtnClick ) 
  
function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        baga = createPickup ( x, y, z, 3, 1210 ) 
        gotBag [ source ] = nil 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

Link to comment
local pbags = 
{ 
    {2028.2314453125, 648.09765625, 11.366704940796}, 
    {2340.6474609375, 750.9208984375, 11.218271255493}, 
    {1632.525390625, 1035.7626953125, 13.769004821777}, 
    {1494.2626953125, 751.025390625, 29.161626815796}, 
    {1454.25, 751.05859375, 32.736267089844}, 
    {1533.3515625, 751.1181640625, 32.64266204834}, 
    {1427.3037109375, 1462.958984375, 10.8203125} 
} 
local bags = { } 
local gotBag = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, i in ipairs ( pbags ) do 
            local baga = createPickup(i[1], i[2], i[3], 3, 1210 ) 
            local bagb = createObject ( 1210, 0, 0, 0 ) 
            addEventHandler ( "onPickupHit", baga, onPickupHit ) 
            bags [ baga ] = bagb 
        end 
    end 
) 
    
function onPickupHit ( player ) 
    if ( not isPedInVehicle ( player ) and not isPedDead ( player ) and not gotBag [ player ] ) then 
        exports.bone_attach:attachElementToBone ( bags [ source ], player, 12, 0, 0.1, 0.3, 0, 180, 0 ) 
        gotBag [ player ] = bags [ source ] 
        destroyElement ( source ) 
    end 
end 
  
function onBtnClick ( ) 
    if ( gotBag [ source ] ) then 
        local money = math.random ( 1000, 2000 ) 
        givePlayerMoney ( source, money ) 
        destroyElement ( gotBag [ source ] ) 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have rewarded and got ".. money .. "$ from the dealer!! Good Job Pro!" ) 
        outputChatBox ( "you have Rewarded and got ".. money .."$ from the dealer...You are PRO!! Good JOB!", source, 0, 255, 0, false ) 
        triggerClientEvent ( source,"winSound", source ) 
        gotBag [ source ] = nil 
    else 
        triggerClientEvent ( source, "WarningText", source, "reward", "You have to get the briefcase of weapons First!" ) 
    end 
end 
addEvent ( "reward", true ) 
addEventHandler ( "reward", root, onBtnClick ) 
  
function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        baga = createPickup ( x, y, z, 3, 1210 ) 
        gotBag [ source ] = nil 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

Actuallly works fine with some sides...but with onPlayerQuit side.. not works fine...because i'm tried to quit while i'm carrying the bag...then joined again and i found the bag...but when i try to pickup it...not works..

function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        baga = createPickup ( x, y, z, 3, 1210 ) 
        gotBag [ source ] = nil 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

Link to comment
function onPlayerQuit ( ) 
    if ( gotBag [ source ] ) then 
        destroyElement ( gotBag [ source ] ) 
        local x, y, z = getElementPosition ( source ) 
        local baga = createPickup ( x, y, z, 3, 1210 ) 
        local bagb = createObject ( 1210, 0, 0, 0 ) 
        addEventHandler ( "onPickupHit", baga, onPickupHit ) 
        bags [ baga ] = bagb 
        gotBag [ source ] = nil 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 

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