Scripts / Need a working pickup key script

Author
Message
Slaur3n
GameGuru TGC Backer
15
Years of Service
User Offline
Joined: 16th Sep 2008
Location: Norway
Posted: 13th Jun 2014 17:00
Hey
ive used this script before, but now it dosent work:

-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Item by pressing "E"

function collectkey_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 the key");
end

-- Player pickup some item through pressing "E"
if PlayerDist < 80 and g_KeyPressE == 1 then
PlaySound(e,0);
AddPlayerKey(e);
Destroy(e);
end



--End of function
end
almightyhood
10
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 13th Jun 2014 17:06 Edited at: 13th Jun 2014 17:08
i think you need this added too the top now. just above the function_main(e)







function scriptname_init(e)

end

thats what i had to add to alot of my scripts im using anyways m8 hope it works/helps

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
Slaur3n
GameGuru TGC Backer
15
Years of Service
User Offline
Joined: 16th Sep 2008
Location: Norway
Posted: 13th Jun 2014 17:21
thanks! but i found out that i used this script. This work perfectly!

-- 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 Key");
end

-- Player pickup some item through pressing "E"
if PlayerDist < 80 and g_KeyPressE == 1 then
PlaySound(e,0);
Collected(e);
Destroy(e);
end



--End of function
end
almightyhood
10
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 13th Jun 2014 17:33
ok cool, but i think without the bit of code for the init at top you can only run x amount of scripts, at least i couldn't run more than 17 examples without a crash everytime anyways.

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM

Login to post a reply

Server time is: 2024-09-08 03:58:53
Your offset time is: 2024-09-08 03:58:53