Code
GeSHi (python):a = wcs.Command(userid)
a.SetCoolDown('Skill Name',Time length)
Now the advantage of this, is that you can now set a cooldown time on ANY skill... However, a skill that ISNT a ultimate, you'll have to retrieve whether the cooldown has been activated... For this, you use the command a.GetCoolDown
Code
GeSHi (python):a = wcs.Command(userid)
timelength = a.GetCoolDown('Skill Name')
if not timelength:
es.msg('The skill no longer has a cooldown timer')
This enables you for more possibilities.. now, the correct way to run an ultimate event is as follows..
Code
GeSHi (python):def player_ultimate_on(event_var):
es.msg('We have 3 events')
es.msg('The first event is userid - %s'%event_var['useird'])
# event_var['userid'] dislayes the userid
es.msg('The second event is steamid - %s'%event_var['es_steamid'])
# event_var['es_steamid'] displays the users steamid
es.msg('The third event is username - %s'%event_var['es_username'])
# event_var['es_username'] displays the users name
# Whenever we run an ultimate command, we MUST use the SetCoolDown if we want to set a cooldown...
a = wcs.Command(ev['userid'])
a.SetCoolDown('My Ultimate Name',30)
# Set a cooldown time of 30 for my My Race and My Ultimate Name...
now I'll show you a way to use delayed to your advantage, to get how long a persons held the key down
Code
GeSHi (python):players = {}
# Create a dictionary
def player_ultimate_on(event_var):
user = wcs.Command(ev['userid'])
user.SetCoolDown('Loop Counter',20)
# Sets the cooldown timer to 20 seconds.
players[ev['userid']] = 0
# Sets a key in the dictionary to 0
delay_name = 'delay_%s'%event_var['userid']
# Format the delay name, so each delay is specific to the user running the command... for example, if userid was 3, it'd be delay_3
gamethread.delayedname(1,delay_name,add_one,(delay_name,ev['userid']))
# Delay the code for 1 second, with the name of delay_name, do the function add_one, and pass the variable delay_name and ev['userid']
def add_one(delay_name, userid):
players[userid] += 1
# Adds 1 to the current value of the users counter.. there is also -= *= and /=
gamethread.delayedname(1,delay_name,add_one,(delay_name,userid))
# Repeat the function 1 second later to add another counter
def player_ultimate_off(event_var):
delay_name = 'delay_%s'%event_var['userid']
# Again, we get the unique delay name
gamethread.cancelDelayedD(delay_name)
# Cancel the delay so it don't loop add_one again
loop_counter = players[ev['userid']]
# Gets the counter of length of time the user held down the key
if loop_counter: # If the loop_counter is at least 1
es.msg('You held down the key for %s seconds!'%loop_counter)
As you can see, I now hold how long (or how powerful etc) the loop counter is...Here we could do some math like distance = 20 * loop_counter so that the larger the loop_counter, the larger the distance... anything like that... Hope this helps you create races
.-freddukes







Logged

Canada



fucker.