Jump to content

Help Please


Recommended Posts

When i pickup this bag..it's don't be attached in the player back...Help please..

I made Attach Element

local pbags = { 
    {2293.154296875, 561.470703125, 7.78125}, 
  
} 
  
  
local marker = createMarker (2291.1999511719,537,0.80000001192093,"cylinder", 1.5, 255, 0, 0) 
  
  
function createBags ( thePlayer ) 
  
local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
local bag = createPickup ( x, y, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 
function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
        end 
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
        setElementData ( thePlayer, "bag", true ) 
        setElementCollisionsEnabled ( bag, false ) 
        attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 
  
addEventHandler ("onPickupHit", getRootElement(), onPickupHit) 

and also how to make in the table about 10 places and make them all spawn? Not only one.

Thanks

Link to comment
You're not calling the marker, if you want to hit it. This is probably how you should try:
  
if source == Marker[1] then 
  

Assuming you had this before as marker:

Marker[1] = createMarker(x, y, z, "corona", 0, 0, 0, 0) 

What Marker o.O? i didn't do function for marker yet..It's onPickupHit!!!..And i made attachelements but not be showed in the player back..Check the script please...........

        attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 

Link to comment

What Marker o.O? i didn't do function for marker yet..It's onPickupHit!!!..And i made attachelements but not be showed in the player back..Check the script please...........

And whats the marker creation then for? i probably misunderstood, if you want to get it on pickup hit..

function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
        end 
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
        setElementData ( thePlayer, "bag", true ) 
        setElementCollisionsEnabled ( bag, false ) 
        attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 
  
addEventHandler ("onPickupHit", getRootElement(), onPickupHit) 

i'm not sure, but try using elses instead of returns.

Link to comment

What Marker o.O? i didn't do function for marker yet..It's onPickupHit!!!..And i made attachelements but not be showed in the player back..Check the script please...........

And whats the marker creation then for? i probably misunderstood, if you want to get it on pickup hit..

function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
        end 
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
        setElementData ( thePlayer, "bag", true ) 
        setElementCollisionsEnabled ( bag, false ) 
        attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 
  
addEventHandler ("onPickupHit", getRootElement(), onPickupHit) 

i'm not sure, but try using elses instead of returns.

What??? Man..Can you igrone the marker? just igrone it!! i didn't script full script yet..but the Element bag don't be attached in the player Back..Can you tell me why? or try to give me example..or else..

But Please Igrone the marker

Link to comment

What??? Man..Can you igrone the marker? just igrone it!! i didn't script full script yet..but the Element bag don't be attached in the player Back..Can you tell me why? or try to give me example..or else..

But Please Igrone the marker

Read the last line of my post, try changing the returns with

else 

they might be bugging as the second return could be trying to return to the first one.

function onPickupHit ( thePlayer )

if ( source ~= bag ) then

return

end

if ( isPedInVehicle ( thePlayer ) ) then

return

end

Link to comment

What??? Man..Can you igrone the marker? just igrone it!! i didn't script full script yet..but the Element bag don't be attached in the player Back..Can you tell me why? or try to give me example..or else..

But Please Igrone the marker

Read the last line of my post, try changing the returns with

else 

they might be bugging as the second return could be trying to return to the first one.

function onPickupHit ( thePlayer )

if ( source ~= bag ) then

return

end

if ( isPedInVehicle ( thePlayer ) ) then

return

end

Please give me an example of what you want to say....

it's gonna be like

if ( source ~= bag ) then

return

else

if ( isPedInVehicle ( thePlayer ) ) then

return

or what?

Link to comment

What??? Man..Can you igrone the marker? just igrone it!! i didn't script full script yet..but the Element bag don't be attached in the player Back..Can you tell me why? or try to give me example..or else..

But Please Igrone the marker

Read the last line of my post, try changing the returns with

else 

they might be bugging as the second return could be trying to return to the first one.

function onPickupHit ( thePlayer )

if ( source ~= bag ) then

return

end

if ( isPedInVehicle ( thePlayer ) ) then

return

end

Please give me an example of what you want to say....

it's gonna be like

if ( source ~= bag ) then

return

else

if ( isPedInVehicle ( thePlayer ) ) then

return

or what?

Whatever! the script now ...

local pbags = { 
    {2293.154296875, 561.470703125, 7.78125}, 
  
} 
  
  
local marker = createMarker (2291.1999511719,537,0.80000001192093,"cylinder", 1.5, 255, 0, 0) 
  
  
function createBags ( thePlayer ) 
  
local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
local bag = createPickup ( x, y, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 
function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
    else 
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    else 
        destroyElement ( bag ) 
        setElementData ( thePlayer, "bag", true ) 
        setElementCollisionsEnabled ( bag, false ) 
        attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
        end 
    end 
end 
  
addEventHandler ("onPickupHit", getRootElement(), onPickupHit) 
  

and Still not shows the Bag in the player back..

Link to comment

Then i'm not sure... but why you have a math.random with the pbag? Try creating a manual pickup and then going to it. Then try making it math, go by steps. Like:

function createBags ( thePlayer ) 
  
local x, y, z = local x,y,z = getElementPosition( getLocalPlayer() ) 
local bag = createPickup ( x, y+10, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 

Start it, and then go to look it right infront of you to see if it works. (and btw, the bag wich is local, how are you calling it in?)

Link to comment
Then i'm not sure... but why you have a math.random with the pbag? Try creating a manual pickup and then going to it. Then try making it math, go by steps. Like:
function createBags ( thePlayer ) 
  
local x, y, z = local x,y,z = getElementPosition( getLocalPlayer() ) 
local bag = createPickup ( x, y+10, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 

Start it, and then go to look it right infront of you to see if it works. (and btw, the bag wich is local, how are you calling it in?)

Ok look,

First: Why the element don't be showed in the player back when he hit the pickup?

Second: This one you posted gives me ERROR in CMD

:12: unexpected symbol near 'local' 

Thanks

Link to comment
Then i'm not sure... but why you have a math.random with the pbag? Try creating a manual pickup and then going to it. Then try making it math, go by steps. Like:
function createBags ( thePlayer ) 
  
local x, y, z = local x,y,z = getElementPosition( getLocalPlayer() ) 
local bag = createPickup ( x, y+10, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 

Start it, and then go to look it right infront of you to see if it works. (and btw, the bag wich is local, how are you calling it in?)

Ok look,

First: Why the element don't be showed in the player back when he hit the pickup?

Second: This one you posted gives me ERROR in CMD

:12: unexpected symbol near 'local' 

Thanks

oops, i accidentaly placed local twice.

function createBags ( thePlayer ) 
  
local x,y,z = getElementPosition( getLocalPlayer() ) 
local bag = createPickup ( x, y+10, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 

Link to comment
Then i'm not sure... but why you have a math.random with the pbag? Try creating a manual pickup and then going to it. Then try making it math, go by steps. Like:
function createBags ( thePlayer ) 
  
local x, y, z = local x,y,z = getElementPosition( getLocalPlayer() ) 
local bag = createPickup ( x, y+10, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 

Start it, and then go to look it right infront of you to see if it works. (and btw, the bag wich is local, how are you calling it in?)

Ok look,

First: Why the element don't be showed in the player back when he hit the pickup?

Second: This one you posted gives me ERROR in CMD

:12: unexpected symbol near 'local' 

Thanks

oops, i accidentaly placed local twice.

function createBags ( thePlayer ) 
  
local x,y,z = getElementPosition( getLocalPlayer() ) 
local bag = createPickup ( x, y+10, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 

It's not changing anything..i want the attachelements work..but it's not attach the bag in the player back...can you fix it?

Link to comment
When i pickup this bag..it's don't be attached in the player back...Help please..

I made Attach Element

local pbags = { 
    {2293.154296875, 561.470703125, 7.78125}, 
  
} 
  
  
local marker = createMarker (2291.1999511719,537,0.80000001192093,"cylinder", 1.5, 255, 0, 0) 
  
  
function createBags ( thePlayer ) 
  
local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
local bag = createPickup ( x, y, z, 3, 1550 ) 
end 
addEventHandler ("onResourceStart", getRootElement(), createBags) 
function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
        end 
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
        setElementData ( thePlayer, "bag", true ) 
        setElementCollisionsEnabled ( bag, false ) 
        attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 
  
addEventHandler ("onPickupHit", getRootElement(), onPickupHit) 

and also how to make in the table about 10 places and make them all spawn? Not only one.

Thanks

Answer Please,I want to attach the element in the player, but not work..check the script.

Thanks

Link to comment

You can't attach a pickup, is not supported by attachElements function, you'll have to create an object, then attach it.

local pbags = 
    { 
        { 2293.154296875, 561.470703125, 7.78125 }, 
    } 
  
local marker = createMarker ( 2291.1999511719, 537, 0.80000001192093, "cylinder", 1.5, 255, 0, 0 ) 
  
function createBags ( thePlayer ) 
    local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
    local bag = createPickup ( x, y, z, 3, 1550 ) 
    addEventHandler ( "onPickupHit", bag, onPickupHit ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), createBags ) 
  
function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
    end 
  
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
    local bag = createObject ( 1550, 0, 0, 0 ) 
    setElementData ( thePlayer, "bag", true ) 
    setElementCollisionsEnabled ( bag, false ) 
    attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 

Link to comment
You can't attach a pickup, is not supported by attachElements function, you'll have to create an object, then attach it.
local pbags = 
    { 
        { 2293.154296875, 561.470703125, 7.78125 }, 
    } 
  
local marker = createMarker ( 2291.1999511719, 537, 0.80000001192093, "cylinder", 1.5, 255, 0, 0 ) 
  
function createBags ( thePlayer ) 
    local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
    local bag = createPickup ( x, y, z, 3, 1550 ) 
    addEventHandler ( "onPickupHit", bag, onPickupHit ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), createBags ) 
  
function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
    end 
  
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
    local bag = createObject ( 1550, 0, 0, 0 ) 
    setElementData ( thePlayer, "bag", true ) 
    setElementCollisionsEnabled ( bag, false ) 
    attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 

but i want to attach it when the player pickup the bag..not when the resource start :/

Link to comment
You can't attach a pickup, is not supported by attachElements function, you'll have to create an object, then attach it.
local pbags = 
    { 
        { 2293.154296875, 561.470703125, 7.78125 }, 
    } 
  
local marker = createMarker ( 2291.1999511719, 537, 0.80000001192093, "cylinder", 1.5, 255, 0, 0 ) 
  
function createBags ( thePlayer ) 
    local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
    local bag = createPickup ( x, y, z, 3, 1550 ) 
    addEventHandler ( "onPickupHit", bag, onPickupHit ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), createBags ) 
  
function onPickupHit ( thePlayer ) 
    if ( source ~= bag ) then 
        return 
    end 
  
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
    local bag = createObject ( 1550, 0, 0, 0 ) 
    setElementData ( thePlayer, "bag", true ) 
    setElementCollisionsEnabled ( bag, false ) 
    attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
end 

Dosen't Work..I didn't see the Object attached when i picked the Pickup up..

Link to comment

Ah, yes, found the problem, use this, it works.

local pbags = 
    { 
        { 2293.154296875, 561.470703125, 7.78125 }, 
    } 
  
local marker = createMarker ( 2291.1999511719, 537, 0.80000001192093, "cylinder", 1.5, 255, 0, 0 ) 
  
function createBags ( thePlayer ) 
    local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) 
    local bag = createPickup ( x, y, z, 3, 1550 ) 
    addEventHandler ( "onPickupHit", bag, onPickupHit ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), createBags ) 
  
function onPickupHit ( thePlayer ) 
    if ( isPedInVehicle ( thePlayer ) ) then 
        return 
    end 
  
    local bag = createObject ( 1550, 0, 0, 0 ) 
    setElementData ( thePlayer, "bag", true ) 
    setElementCollisionsEnabled ( bag, false ) 
    attachElements ( bag, thePlayer, 0, -0.3, 0.3 ) 
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...