Mod Dict
This command modifies a value in a dictionary. This command is an advanced command, and if you don't know anything about dictionarys, then I suggest you read up on
this link. Modify dictionary will add whatever value you want to the value already store within the dictionary...
The correct syntax is:
wcs.Command(<userid>).ModDict(<'Key-Name'>,<value to add>)
- Userid - The users Dictionary that you will be accessing
- Key name - The name of the key you want to modify
- Value to add - The value that you want to add to the current value of the key-name. This can be positive or negative...
Example:
def player_spawn(ev):
player = wcs.Command(ev['userid'])
player.UpdateDict('myloop',0)
# Creates a new value, see UpdateDict
def player_ultimate_on(ev):
myloop(ev['userid'])
# Starts myloop, and passes the variable userid
def myloop(userid):
# Here we are going to modify the dict to add 1 each time
player = wcs.Command(userid)
player.ModDict('myloop',1)
# Adds 1 to the current value in the dictionary
gamethread.delayedname(1,'current_loop',myloop,userid)
# Repeat the loop 1 second later, with a name of current_loop
def player_ultimate_off(ev):
gamethread.cancelDelayed('current_loop')
# Cancel the current loop so it stops the looping process
player = wcs.Command(ev['userid'])
loop_counter = player.ReturnDict('myloop')
# Returns the value inside the 'myloop' see ReturnDict
es.tell(ev['userid'],'#green','You held the ultimate key for %s seconds!'%loop_counter)
# tells the user how many loops he did
Comments (0)
You don't have permission to comment on this page.