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)
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects random weapon
local random = 0
function randomweapon_main(e)
local this = aEntity:new(e, "randomweapon")
if this:distance(aPlayer) < 100 and pressed == 0 then
Prompt("Press E To Collect A Random Weapon")
if g_KeyPressE == 1 then
pressed = 1
random = math.random(1,5)
PlaySound0(e);
if random == 1 then
local pistol = aEntity.by_name("pistolrandom")
AddPlayerWeapon(pistol.e);
end
if random == 2 then
local magnum = aEntity.by_name("magnumrandom")
AddPlayerWeapon(magnum.e);
end
if random == 3 then
local uzi = aEntity.by_name("uzirandom")
AddPlayerWeapon(uzi.e);
end
if random == 4 then
local shotgun = aEntity.by_name("shotgunrandom")
AddPlayerWeapon(shotgun.e);
end
if random == 5 then
local rifle = aEntity.by_name("riflerandom")
AddPlayerWeapon(rifle.e);
end
--Destroy(e);
end
end
if g_KeyPressE == 0 then
pressed = 0
end
end
and now the 5 scripts for the weapons
pistolrandom.lua
function pistolrandom_main(e)
local this = aEntity:new(e, "pistolrandom")
end
magnumrandom.lua
function magnumrandom_main(e)
local this = aEntity:new(e, "magnumrandom")
end
uzirandom.lua
function uzirandom_main(e)
local this = aEntity:new(e, "uzirandom")
end
shotgunrandom.lua
function shotgunrandom_main(e)
local this = aEntity:new(e, "shotgunrandom")
end
riflerandom.lua
function riflerandom_main(e)
local this = aEntity:new(e, "riflerandom")
end
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