Jump to content

[HELP]Creating a Pickup System


Recommended Posts

Hello all,There is my problem i want to create a script who when somebody hit the pickup get somo Objects but...

I hit the Pickup and nothing happened :c,Can you help me please? a lot of thanks

--server.lua

local M4Pickup = createPickup(-2812.4370,-849.909,23.22,2,31,300,0) 
  
function GiveDayZItem() 
   setElementData(source, "Coyote Backpack", 1) 
   setElementData(source, "Map", 1) 
   setElementData(source, "GPS", 1) 
   setElementData(source, "Toolbox", 1) 
end 
addEvent( "GiveDayZItem", true ) 
addEventHandler( "onPickupHit", M4Pickup, GiveDayZItem ) 

Basicly When you hit the pickup you will get in your inventory(Defined in the main resource) these things

I apreciate all the help.

sorry for my bad english,Thanks!

--client.lua

  
function GiveDayZ() 
    triggerServerEvent ( "GiveDayZItem", getLocalPlayer() ) 
end 
addEventHandler("onPickupHit", GiveDayZ ) 

Link to comment

onPickupHit is server side.

-- Server Side 
  
local M4Pickup = createPickup(-2812.4370,-849.909,23.22,2,31,300,0) 
  
function GiveDayZItem(player) 
   setElementData(player, "Coyote Backpack", 1) 
   setElementData(player, "Map", 1) 
   setElementData(player, "GPS", 1) 
   setElementData(player, "Toolbox", 1) 
end 
addEventHandler("onPickupHit", M4Pickup, GiveDayZItem) 

Link to comment

Than You Men!

And if i want to the player get a random item the code must be like this?

  
local M4Pickup = createPickup(-2812.4370,-849.909,23.22,2,31,300,0) 
local 1 = "M4" 
local 0 = "GPS" 
local 2 = "Toolbox" 
local 3 = "Map" 
function GiveDayZItem(player) 
   setElementData(player, math.random(0, 3), 1) 
end 
addEventHandler("onPickupHit", M4Pickup, GiveDayZItem) 

Link to comment
  
local M4Pickup = createPickup(-2812.4370,-849.909,23.22,2,31,300,0) 
local item_table={"GPS","M4","Toolbox","Map"} 
  
function GiveDayZItem(player) 
   setElementData(player,item_table[ math.random(1, #item_table)], 1) 
end 
addEventHandler("onPickupHit", M4Pickup, GiveDayZItem) 

Link to comment

It give to me all the weapons no only 1,I want to the scriot guive me 1 random weapon! thanks for the help :D

and how can i make it for give me random items?

local ItemAzar = {  
        "Pasta Can", 
        "Beans Can", 
        "Burger", 
        "Pizza", 
        "Soda Bottle", 
        "Empty Water Bottle", 
        "Empty Soda Cans", 
        "Scruffy Burgers", 
        "Milk", 
        "Raw Meat", 
        "Cooked Meat"  
        } 
local M4Pickup = createPickup(-2812.4370,-849.909,23.22,2,31,300,0) 
  
function GiveDayZItem(player) 
   setElementData(player,ItemAzar[ math.random(1, #ItemAzar)], 1) 
end 
addEventHandler("onPickupHit", M4Pickup, GiveDayZItem) 
  
  

it gives to me the random random things?

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