Scripts / Pick Up Item Script By Pressing E ( Problem

Author
Message
Super Clark
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 4th Apr 2011
Location: UK
Posted: 25th Mar 2014 07:04
Help required please, I have tried different variations on this and

they just crash reloded once you press E to collect. Not sure if script

is correct. I'm a novice to this stuff any help would be great.





Version 1

-- LUA Script - precede every function and global member with lowercase name of script + '_main'

-- Player Collects Item by pressing "E"



function item_main(e)



**************************************************************





Version 2



-- LUA Script - precede every function and global member with lowercase name of script + '_main'

-- Player Collects Item by pressing "E"



function pickupitem_main(e)

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));





-- Showing Text

if PlayerDist < 80 then

Prompt("Press E to pickup Item");

end



-- Player pickup some item through pressing "E"

if PlayerDist < 80 and g_KeyPressE == 1 then

PlaySound0(e);

AddPlayerItem(e);

Destroy(e);

end







--End of function

end







I wondering does anything need adding to the global script to allow the

'Item' variation ie, ammo - health - weapon, so does Item need adding to

this part of the global script?
PM
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 25th Mar 2014 17:38
Hi,



Edited this, and it now seems to work. I hope this is what you wanted.





i7-4770s 3.10ghz - Geforce GTX 650ti
Super Clark
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 4th Apr 2011
Location: UK
Posted: 25th Mar 2014 18:46
Just waht I wanted, Thank You Scene Commander
PM

Login to post a reply

Server time is: 2024-05-06 07:11:03
Your offset time is: 2024-05-06 07:11:03