Scripts / Collect Weapons and Ammo with the E key.

Author
Message
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 28th Mar 2014 14:43 Edited at: 31st Mar 2014 09:48
Hi,



Following Super Clarks request for an item pick up script, I spent a couple of minutes making 2 more very simple scripts to collect weapons and ammo using the E key.



Attached in the zip file, free to everyone to use how you wish.



SC

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: 28th Mar 2014 16:45 Edited at: 28th Mar 2014 16:56
Chears Scene Commander Thanks for these.

I'm trying to get the weapons from old FPS to work but no luck

so far



''Scripts Work Great''
PM
Imchasinyou
10
Years of Service
User Offline
Joined: 22nd Mar 2014
Location: OH
Posted: 30th Mar 2014 05:24 Edited at: 30th Mar 2014 05:25
I am a complete idiot when it comes to scripting. Im not sure how to specify a weapon.



I have used an ammo crate for this, the message appears to press E but obviously, with out specifying a weapon to give, nothing happens. Ive added the name of the weapon to the line, AddPlayerWeapon(e); as such, AddPlayerWeapon "Uzi" (e); and Ive tried several different variations. Can some one PLEASE and gently tell me what Im doing wrong.



Also, is there a way to make it a random weapon?
PM
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 31st Mar 2014 09:51
Hi,



These scripts need to be attached to the weapon/ammo script 'Main'. Place a weapon/ammo entity on the map, right click and in the status bar that appears to the left, click the small box in the panel marked Main. This will list all of the available scripts.



AddPlayerWeapon(e) only adds the selected weapon to the players inventory.



SC

i7-4770s 3.10ghz - Geforce GTX 650ti
drewtaylorr
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 18th Jun 2013
Location:
Posted: 21st Apr 2014 17:48
How would I change the display text when collecting them ? When I open in lua edit, and change the text I try to open it in game and get an error?? Help?

Kill or Be Killed
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Apr 2014 20:22 Edited at: 21st Apr 2014 23:28
Imchasinyou wrote: "I am a complete idiot when it comes to scripting. Im not sure how to specify a weapon.



I have used an ammo crate for this, the message appears to press E but obviously, with out specifying a weapon to give, nothing happens. Ive added the name of the weapon to the line, AddPlayerWeapon(e); as such, AddPlayerWeapon "Uzi" (e); and Ive tried several different variations. Can some one PLEASE and gently tell me what Im doing wrong.



Also, is there a way to make it a random weapon? "




you could hide the desired weapon inside the ammo crate (and set the script to run from the weapon rather than the crate)

edit:

ok random weapon code done, firstly if you haven't already make sure you install Avrams code addons - they are needed for this.

https://bitbucket.org/Avram/fpsc-r-toolkit/wiki/Installation

now you need a few scripts for this but they are mostly just to name the entities(the weapons)....

randomweapon.lua (this is the script you place on the crate)





and now the 5 scripts for the weapons

pistolrandom.lua





magnumrandom.lua





uzirandom.lua





shotgunrandom.lua





riflerandom.lua





now place all the weapons into your map and link the scripts to the correct weapon (i.e. pistolrandom.lua onto the pistol, uzirandom.lua onto the uzi etc) then place the crate and link randomweapon.lua to it (and finally hide the weapons from view as desired - in the crate or under the terrain... it doesnt matter)



note that like this there is no limit to the amount of weapons you can collect, if you would like me to edit it to a specific requirement i can do so.



p.s. i hope i have understood your code correctly there Avram... couldn't have done it without you



video of it in action





drewtaylorr wrote: "How would I change the display text when collecting them ? When I open in lua edit, and change the text I try to open it in game and get an error?? Help?"


if u mean to say the colour or font i would say u can't yet, wait for some updated commands and then u should be able to.

if u mean what is actually written just change the text inside the quotation marks only

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11

Login to post a reply

Server time is: 2024-12-22 01:15:53
Your offset time is: 2024-12-22 01:15:53