Page 1 of 1

es_map_start not trihgerred in custom addon

PostPosted: Mon Sep 03, 2012 9:20 am
by Neka
Hello!
Here the code
# ../scripts/custom/gg_knife_bonus/gg_knife_bonus.py

# ==================================================
# IMPORTS
# ==================================================
# Python Imports
import os
import random

# Eventscripts Imports
import es

# GunGame Imports
from gungame51.core.players.shortcuts import Player
from gungame51.core.addons.shortcuts import AddonInfo

# ==================================================
# ADDON REGISTRATION/INFORMATION
# ==================================================
info = AddonInfo()
info.name = 'gg_res'
info.title = 'GG Round End Sound'
info.author = 'Neka'
info.version = '1.0'

# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    global randomResList

    randomResList = os.listdir('%s/cstrike/sound/gungame/gg_res/random' % (os.getcwd()))
    personalResList = os.listdir('%s/cstrike/sound/gungame/gg_res/personal' % (os.getcwd()))

def unload():
    pass


# ==================================================
# GAME EVENTS
# ==================================================
def es_map_start(event_var):
    print "KKhkjhkfjdshklHLKLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL"

#def es_map_start(event_var):
    #setDownload()
#    print "ES_MAP_START WORKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

def gg_win(event_var):
    ggPlayer = Player(event_var['userid'])
    player_weapon = ggPlayer.weapon

    if player_weapon == "knife":
        ggPlayer.give('smokegrenade', True, False)



# =================================================
# CUSTOM FUNCTION
# =================================================
def setDownload():
    for i in range(0, len(randomResList)):
        if randomResList[i].endswith('wav') or randomResList[i].endswith('mp3'):
            es.stringtable('downloadables', 'sound/gungame/gg_res/random/%s' %(randomResList[i]))


What's wrong with this event?

PostPosted: Mon Sep 03, 2012 3:21 pm
by satoon101
I don't know if "print" works as intended, but I am not sure. es_map_start should definitely be working fine in custom addons. Maybe use, in place of print:
def es_map_start(event_var):
    es.msg('THIS IS A TEST FOR ES_MAP_START')
Satoon

PostPosted: Tue Sep 04, 2012 3:21 am
by Neka
Still doesn't work
I need to place setDownload() function into es_map_start callback. It successful called from load(), but not from es_map_start.

PostPosted: Tue Sep 04, 2012 3:46 am
by Neka
Ok, it works, thanks.