Because that thread was closed (
https://forum.game-guru.com/thread/211716#top ) and I just find it for a few days ago.
I've used all setting from that post, but I can't make that damn switch to recognize if the player already HAVE or NOT that bloody gasmask
Any idea why doesn't work ?
Here is the original script of that switch:
-- script by 3com
-- Since we can not control StartParticleEmitter(e) function yet, something like amount, density, size, of the particles, in this case toxic gas,
-- the I decided place 6 bombs, 5 bombs invisible, a just one visible. ( of course you can just let them all visible, i.e. in an sci-fi lab )
switch_on = 0 -- assure switch is on
id = 0 -- control entity number
id_soldier = 0 -- control soldier number
plrHasMask = 0
function switch_init(e)
end
function switch_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 then
if g_Entity[e]['activated'] == 0 then
Prompt("Press E key to activate the bomb")
if g_KeyPressE == 1 then
g_Entity[e]['activated'] = 1
end
end
if g_Entity[e]['activated'] == 1 then
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
g_Entity[e]['activated'] = 2
ActivateIfUsed(e)
PlaySound(e,0) -- set the sound you want, in entity properties panel>Sound0
switch_on = 1
end
if g_Entity[e]['activated'] == 2 and switch_on == 1 then
--StartParticleEmitter(e) -- uncommented this line if you want the switch throwing gas too.
StartParticleEmitter(6) -- gas bomb activate - Notice 6 is my entity number (visible bomb on the map edit). You'll have to get your own, and change it.
-- the others gas bomb activate too.
for id = 8,11 do -- -- You'll have to get your own, and change it, too.
StartParticleEmitter(id)
end
-- killing soldiers
for id_soldier = 12,14 do -- You'll have to get your own, and change it, too.
SetEntityHealth(id_soldier,0)
if plrHasMask == 0 then -- Place this global variable into your global.lua (plrHasMask = 0)
SetPlayerHealth(0) -- if player has not the gas mask, then he will dead.
end
end
end
else
--StopParticleEmitter(e)
StopParticleEmitter(6) -- deactivate bomb when player away from the switch.
for id = 8,11 do
StopParticleEmitter(id) -- deactivate the others bombs. (the invisible ones)
end
StopSound(e,0)
end
end -- main
function switch_exit(e)
end --exit
Later Edit: Here is the new gas mask script modified with smallg's indications (read below of my post) Thanks Smallg !
The script for gasmask was a little modified by me to show mask from rear glass view:
-- script by 3com adapted to show gas mask glass by Old Larry
-- find the original script at https://forum.game-guru.com/thread/211716
-- Player Collects gas mask
local timerStarted = {}
local time1 = 0
local time2 = g_Time
local imagenumber = 0
local max_images = 3
local delay = 0.01
local input = "g"
local pressed = 0
function gasmask_init(e)
LoadImages("gasmask",0)
SetImagePosition(0,0)
SetImageAlignment(1)
end
function gasmask_main(e)
PlayerDist = GetPlayerDistance(e)
--show_prompt = 1
if PlayerDist < 150 and g_PlayerHealth > 0 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 20.0 then
Prompt ("Press G to use Gas Mask")
end
if g_InKey == "g" then
pressed = 1
plrHasMask = 1
if time1 == 0 then
time1 = g_Time
end
time2 = g_Time
timepassed = (time2 - time1) / 1000
if timepassed >= delay then
SetImagePosition(0,0)
ShowImage(imagenumber)
time1 = 0
if imagenumber < max_images - 1 then
imagenumber = imagenumber + 1
else
imagenumber = 0
end
PromptDuration("Gas Mask in use",3000)
PlaySound(e,0)
Collected(e)
Destroy(e)
ActivateIfUsed(e)
plrHasMask = 1 -- Place this global variable ??? into your global.lua (plrHasMask = 0)
end
end
end
end
Conclusion: WITH or WITHOUT that gas mask, the player is hurt when use that switch....
The view for gasmask can be used free, because is maded by me.
Just multiply x 4 the same attached photo in the ... /scriptbank/images/gasmask/000.png (and 001.png, 002.png, 003.png) .
Well...for a moment please view a little video with the problem:
Smile today, tomorrow could be worse
http://bestradiolarry.ro/fps/
"The best forum, game software, operating system or web platform, it's that software which can give you most of the features and speed, not just amazing graphics."