JSONapi example

This is assuming a *nix based OS (tested on an ubuntu server with python 2.7)

ok, lets do a basic concept that I use to use in my own server: do some commands to all players at dawn. First we set up the SCE event to fire our script every time its dawn, passing event argument as well (we only want to do things in to players in the same world)

dawn:
    - command: 'execWait plugins/SimpleCronClone/scripts/dawnEvent.py $1'

now, the code is basically like any other scripting logic (php for example executes by default every time the page is browsed to, in fact it is possible to invoke php via the command line and use it instead of python. although php is really really more meant for http work than general scripting...) we load the JSON api (make sure its on your $path, see its install instructions for info) then do our work.

#!/usr/bin/python

import sys

from JSONapi import *

if __name__ == '__main__':
    params = {'host': 'localhost', 'port':20059, 'username':'admin', 'password':'demo', 'salt':''}
    
    #connect to the server
    api = MinecraftJsonApi(
        host = params['host'], 
        port = params['port'], 
        username = params['username'], 
        password = params['password'], 
        salt = params['salt']
    )
    
    players = api.call('getOnlinePlayerNamesInWorld',sys.argv[1])
    for player in players:
        api.call('givePlayerItem',player,50,1)#one torch to each player
    if len(players) >0:
        #the world is not empty, so we gave some items. announce it!
        api.call('broadcast','dawn event! every one gets a torch in %s'%sys.argv[1])

for more complicated uses I would recommend looking at python tutorials or asking on the other respective developers. This is more an example of complex logic being called for in an event/cron file and using an external api to do that logic for us.