Scripts / Pick up and move special items in game

Author
Message
Flameinc
9
Years of Service
User Offline
Joined: 1st Aug 2014
Location:
Posted: 19th Aug 2014 07:23
I have been trying to code a script that can let the player pick up special items in the game and then drop the item anywhere else on the map.

For example, you come to a barrel that says Prompt("You have an Explosive Barrel, Press E to place the Barrel") or Prompt("You need to find an explosive barrel and place it here")

any possible solutions???

here is an example of code that I tried:

PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 300 then
if g_Entity[e]['activated'] == 0 then
if g_Entity[e]['haskey'] == -1 then
g_Entity[e]['activated'] = 1
else
if g_Entity[e]['haskey'] == 1 then
Prompt("You have an Explosive Barrel, Press E to place the Barrel")
if g_KeyPressE == 1 then
Spawn(e)
else
Prompt("You need to find an explosive barrel and place it here")
end
end


-'haskey' is a barrel that you picked up

Flameinc
tomjscott
User Banned
Posted: 21st Aug 2014 16:55
You can do this a number of ways. One way is if you have the specific location where the barrel MUST be placed then you would do something similar to what you are trying to do here where you have an unspawned barrel at that location and then spawn it when the player presses the activation key. Another way to do this is to have a barrel somewhere on the map that when you press the pickup object key that it is then moved off the map somewhere while the player has it in his possession. At anyplace on the map when the player presses a key to then drop the barrel, you use the SetPosition functions to place it there. If you are more ambitious, you can also have the barrel moved up in the air in front of the player and to move around as the player moves as if he's carrying it. All these things are possible.

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0071

Login to post a reply

Server time is: 2024-05-03 08:12:26
Your offset time is: 2024-05-03 08:12:26