CobbTheWarriorsRPG Posted August 9, 2013 Share Posted August 9, 2013 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
TAPL Posted August 9, 2013 Share Posted August 9, 2013 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
CobbTheWarriorsRPG Posted August 9, 2013 Author Share Posted August 9, 2013 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
bandi94 Posted August 9, 2013 Share Posted August 9, 2013 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
CobbTheWarriorsRPG Posted August 9, 2013 Author Share Posted August 9, 2013 It give to me all the weapons no only 1,I want to the scriot guive me 1 random weapon! thanks for the help 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now