xSyndicate58 try these two scripts...
attach this control script to an always active dynamic entity..use ONLY ONE of this script in the level
script name is jc_player_freeze_music.lua
-- jc_player_freeze_music.lua
--
-- This is the music and player freeze control script
-- ONLY ONE used on level
-- attach script to an always active dynamic entity
-- these will be the explodable entities added to use with this script
local myent = {}
local mycnt = 0
-- the music trak to play
local mustrak = 2
local mon = 0
-- the explodable entitys state
local estate = {}
local ce = 0
-- delay used to freeeze player and music (change to your required value)
local tmdelay = 10000
-- Used by the destroy_too_near script to check if this control script is active
jc_player_freeze_music_set = 0
function jc_player_freeze_music_init(e)
end
function jc_player_freeze_music_main(e)
-- tell destroy_too_near script we are active
jc_player_freeze_music_set = 1
-- at startup start the music trak
-- if you have set the music to play already just rem out these lines
if mon == 0 then
music_play_cue(mustrak, 500)
music_set_volume(100,100)
mon = 1
end
-- if we have explodable entities added then do the for loop
if mycnt > 0 then
for ce = 1, mycnt do
-- if explodable entity has set trip (exploded)
if estate[ce] == "trip" then
-- we now freeze player and stop the music and reset the timer
FreezePlayer()
music_stop(10)
StartTimer(e)
-- set the state to tripped so we will control the next state logic
estate[ce] = "tripped"
elseif estate[ce] == "tripped" then
-- if we are tripped then check the time delay
if GetTimer(e) < tmdelay then
-- play sound while we wait
PlaySoundIfSilent(e,1)
else
-- time delay is up so unfreeze player stop the sound start the music
UnFreezePlayer()
StopSound(e,1)
music_play_instant(mustrak,10)
music_set_volume(100,100)
-- set the state to fin so we don't do this logic anymore
estate[ce] = "fin"
end
end
end
end
end
-- explodable entity adds its entity number to our list
function jc_player_freeze_music_add_me(ex)
if ex > 0 then
mycnt = mycnt + 1
myent[mycnt] = ex
estate[mycnt] = "setup"
end
return mycnt
end
-- explodable entity sets the trip state when it explodes
function jc_player_freeze_music_set_state(ec, st)
if ec > 0 and ec <= mycnt then
estate[mycnt] = st
end
end
and attach this one to your explode entity... add as many as you need
script name is destroy_too_near.lua
-- destroy_too_near.lua
--
-- Add this script to explodable entitys as many as you want
-- this is the external control script that will do most of the work
require "scriptbank\\myScripts\\jc_player_freeze_music"
-- will hold this expoldable entitys position in the above control scripts list of entitys
local ecnt = {}
-- player near distance check value
local neardist = 400 -- 220
function destroy_too_near_init(e)
-- make sure our ecnt[e] is set at zero at start
ecnt[e] = 0
end
function destroy_too_near_main(e)
-- check if we can see the external control script
if jc_player_freeze_music_set ~= nil then
if jc_player_freeze_music_set == 0 then
return
end
else
PromptLocal(e, "musicFreezeControl not setup")
end
-- we can see the external control script
-- so we can carry on
-- if our ecnt[e] has not been added yet then add our (e) to the control scripts list
if ecnt[e] == 0 then
ecnt[e] = jc_player_freeze_music_add_me(e)
elseif ecnt[e] > 0 then
-- we have been added to the control script
-- so check if player is near
if GetPlayerDistance(e) < neardist then
-- too near so explode
SetEntityHealth(e,0)
-- tell the control script we have exploded
-- using ecnt[e] our position in the control scrpts list
jc_player_freeze_music_set_state(ecnt[e], "trip")
end
end
end
[ /code ]
good luck..
I don't know why the script is not showing in the script box..?