Hi guys, i'm trying to create a script so that when you get within a certain distance of an object it randomly plays one of four sounds in its slots, with a delay of 5 seconds in between sounds.
Here's what i have come up with so far:
local randomsound = 1
local delay = 5000
local timeout = 1
function RandomSound_init(e)
local timeout = 1
local randomsound = 1
end
function RandomSound_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist =< 500 and GetTimer(e) >= delay then
randomsound = math.random(1,4)
if timeout == 0 then
if randomsound == 1 then
PlaySound(e,1)
timeout =1
end
if randomsound == 2 then
PlaySound(e,2)
timeout =1
end
if randomsound == 3 then
PlaySound(e,3)
timeout =1
end
if randomsound == 4 then
PlaySound(e,4)
timeout =1
end
end
else
if timeout == 1 then
StartTimer(e)
timeout == 0
end
end
end
At the moment i am at work so i cant get into gameguru, but i'd like to have it working before i get home so i can just add it to my project, could somebody please check it for me and if there is anything wrong with it let me know so i can fix it before heading home from work tonight
Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.
Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.
Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.