User:RoadKillPuppy: Difference between revisions

From WolfWiki
Jump to navigation Jump to search
No edit summary
added playsound_env command to the playsound.lua script
Line 14: Line 14:
-- RoadKillPuppy's PlaySound / etpro lua module
-- RoadKillPuppy's PlaySound / etpro lua module
-- ex. 'rcon rconpass playsound -1 sound/etpro/hit.wav'
-- ex. 'rcon rconpass playsound -1 sound/etpro/hit.wav'
--    'rcon rconpass playsound_env 10 sound/etpro/hit.wav'
--
--
-- copypasted 99% of the code from ReyalP's wolfwiki page
-- copypasted 99% of the code from ReyalP's wolfwiki page
Line 22: Line 23:
-- 0.3 rkp: workaround for etpro beta racecondition
-- 0.3 rkp: workaround for etpro beta racecondition
-- 0.4 rkp: cleaned-up version for etpro 3.2.3
-- 0.4 rkp: cleaned-up version for etpro 3.2.3
-- 0.5 rkp: added playsound_env command


-- global varlist
-- global varlist
PlaySoundVersion = "0.4"
PlaySoundVersion = "0.5"


-- called when game inits
-- called when game inits
Line 34: Line 36:
-- some help
-- some help
function PlaySoundHelp()
function PlaySoundHelp()
        et.G_Print("playsound -1 plays a sound that everybody on the server can hear\n");
         et.G_Print("usage: playsound -1 path_to_sound.wav\n");
         et.G_Print("usage: playsound -1 path_to_sound.wav\n");
end
function PlaySoundEnvHelp()
        et.G_Print("playsound_env plays a sound that you can hear in the proximity of the player with slot -playerslot-\n");
        et.G_Print("usage: playsound_env playerslot path_to_sound.wav\n");
end
end


Line 40: Line 48:
function et_ConsoleCommand()
function et_ConsoleCommand()
         if et.trap_Argv(0) == "playsound" then
         if et.trap_Argv(0) == "playsound" then
                 if et.trap_Argc() == 1 then
                 if et.trap_Argc() ~= 3 then
                         PlaySoundHelp()
                         PlaySoundHelp()
                 else
                 else
Line 47: Line 55:
                 return 1
                 return 1
         end
         end
        if et.trap_Argv(0) == "playsound_env" then
                if et.trap_Argc() ~= 3 then
                        PlaySoundEnvHelp()
                else
                        soundindex = et.G_SoundIndex( et.trap_Argv(2) )
                        et.G_Sound( et.trap_Argv(1) , soundindex )
                end
                return 1
        end
         return 0
         return 0
end
end

Revision as of 01:12, 3 December 2005

Contact

http://bani.anime.net/banimod/forums/images/avatars/2655845734090fc0ecc1e0.jpg

Oh and btw: excuse me for my wiki-noobness...

etpro-lua - playsound.lua

The following script enables the playsound command when using etpro. By feeding the server with the correct sound-files (pk3-based that is), it's possible for etadmin_mod to spam spree_sounds.

-- RoadKillPuppy's PlaySound / etpro lua module
-- ex. 'rcon rconpass playsound -1 sound/etpro/hit.wav'
--     'rcon rconpass playsound_env 10 sound/etpro/hit.wav'
--
-- copypasted 99% of the code from ReyalP's wolfwiki page
-- thx r0f`deej for testing...  May your sprees be remembered!
--
-- 0.1 rkp
-- 0.2 rkp: dirty implementation of -1 parameter used by etadminmod
-- 0.3 rkp: workaround for etpro beta racecondition
-- 0.4 rkp: cleaned-up version for etpro 3.2.3
-- 0.5 rkp: added playsound_env command

-- global varlist
PlaySoundVersion = "0.5"

-- called when game inits
function et_InitGame( levelTime, randomSeed, restart )
        et.RegisterModname( "rkp_playsound-" .. PlaySoundVersion .. " " .. et.FindSelf() )
        et.G_Print( "RoadKillPuppy's PlaySound version " ..  PlaySoundVersion .. " activated...\n" )
end

-- some help
function PlaySoundHelp()
        et.G_Print("playsound -1 plays a sound that everybody on the server can hear\n");
        et.G_Print("usage: playsound -1 path_to_sound.wav\n");
end

function PlaySoundEnvHelp()
        et.G_Print("playsound_env plays a sound that you can hear in the proximity of the player with slot -playerslot-\n");
        et.G_Print("usage: playsound_env playerslot path_to_sound.wav\n");
end

-- react on new console command
function et_ConsoleCommand()
        if et.trap_Argv(0) == "playsound" then
                if et.trap_Argc() ~= 3 then
                        PlaySoundHelp()
                else
                        et.G_globalSound(et.trap_Argv(2));
                end
                return 1
        end

        if et.trap_Argv(0) == "playsound_env" then
                if et.trap_Argc() ~= 3 then
                        PlaySoundEnvHelp()
                else
                        soundindex = et.G_SoundIndex( et.trap_Argv(2) )
                        et.G_Sound( et.trap_Argv(1) , soundindex )
                end
                return 1
        end

        return 0
end

etadmin_sounds.pk3 pk3 with et_adminmod wav files (thx mark)

For a quick howto:

- ET Pro >= 3.2.3

- add -->set lua_modules "playsound.lua"<-- to server.cfg

- copy the lua script and sound pk3 into your etpro dir

- test with 'rcon rconpass playsound -1 sound/etpro/hit.wav' and 'rcon rconpass playsound -1 sound/misc/killingspree.wav'