agario-client.js
function(name) {
        if(this.debug >= 3)
            this.log('spawn() called, name=' + name);

        if(!this.ws || this.ws.readyState !== WebSocket.OPEN) {
            if(this.debug >= 1)
                this.log('[warning] spawn() was called when connection was not established, packet will be dropped');
            return false;
        }

        var buf = new Buffer(1 + 2*name.length);
        buf.writeUInt8(0, 0);
        for (var i=0;i<name.length;i++) {
            buf.writeUInt16LE(name.charCodeAt(i), 1 + i*2);
        }
        this.send(buf);

        //fix for unstable spawn on official servers
        if(!this.spawn_attempt && this.spawn_interval) {
            if(this.debug >= 4)
                this.log('Starting spawn() interval');

            var that = this;
            this.spawn_attempt = 1;
            this.spawn_interval_id = setInterval(function() {
                if(that.debug >= 4)
                    that.log('spawn() interval tick, attempt ' + that.spawn_attempt + '/' + that.spawn_attempts);

                if(that.spawn_attempt >= that.spawn_attempts) {
                    if(that.debug >= 1)
                        that.log('[warning] spawn() interval gave up! Disconnecting from server!');
                    that.spawn_attempt = 0;
                    clearInterval(that.spawn_interval_id);
                    that.spawn_interval_id = 0;
                    that.disconnect();
                    return;
                }
                that.spawn_attempt++;
                that.spawn(name);
            }, that.spawn_interval);
        }

        return true;
    }
function(name) {
        if(this.debug >= 3)
            this.log('spawn() called, name=' + name);

        if(!this.ws || this.ws.readyState !== WebSocket.OPEN) {
            if(this.debug >= 1)
                this.log('[warning] spawn() was called when connection was not established, packet will be dropped');
            return false;
        }

        var buf = new Buffer(1 + 2*name.length);
        buf.writeUInt8(0, 0);
        for (var i=0;i<name.length;i++) {
            buf.writeUInt16LE(name.charCodeAt(i), 1 + i*2);
        }
        this.send(buf);

        //fix for unstable spawn on official servers
        if(!this.spawn_attempt && this.spawn_interval) {
            if(this.debug >= 4)
                this.log('Starting spawn() interval');

            var that = this;
            this.spawn_attempt = 1;
            this.spawn_interval_id = setInterval(function() {
                if(that.debug >= 4)
                    that.log('spawn() interval tick, attempt ' + that.spawn_attempt + '/' + that.spawn_attempts);

                if(that.spawn_attempt >= that.spawn_attempts) {
                    if(that.debug >= 1)
                        that.log('[warning] spawn() interval gave up! Disconnecting from server!');
                    that.spawn_attempt = 0;
                    clearInterval(that.spawn_interval_id);
                    that.spawn_interval_id = 0;
                    that.disconnect();
                    return;
                }
                that.spawn_attempt++;
                that.spawn(name);
            }, that.spawn_interval);
        }

        return true;
    }
function ( name ) { if ( this . debug >= 3 ) this . log ( 'spawn() called, name=' + name ) ; if ( ! this . ws || this . ws . readyState !== WebSocket . OPEN ) { if ( this . debug >= 1 ) this . log ( '[warning] spawn() was called when connection was not established, packet will be dropped' ) ; return false ; } var buf = new Buffer ( 1 + 2 * name . length ) ; buf . writeUInt8 ( 0 , 0 ) ; for ( var i = 0 ; i < name . length ; i ++ ) { buf . writeUInt16LE ( name . charCodeAt ( i ) , 1 + i * 2 ) ; } this . send ( buf ) ; //fix for unstable spawn on official servers
 if ( ! this . spawn_attempt && this . spawn_interval ) { if ( this . debug >= 4 ) this . log ( 'Starting spawn() interval' ) ; var that = this ; this . spawn_attempt = 1 ; this . spawn_interval_id = setInterval ( function ( ) { if ( that . debug >= 4 ) that . log ( 'spawn() interval tick, attempt ' + that . spawn_attempt + '/' + that . spawn_attempts ) ; if ( that . spawn_attempt >= that . spawn_attempts ) { if ( that . debug >= 1 ) that . log ( '[warning] spawn() interval gave up! Disconnecting from server!' ) ; that . spawn_attempt = 0 ; clearInterval ( that . spawn_interval_id ) ; that . spawn_interval_id = 0 ; that . disconnect ( ) ; return ; } that . spawn_attempt ++ ; that . spawn ( name ) ; } , that . spawn_interval ) ; } return true ; }
functions that you can call to control your balls spawn ball
functions that you can call to control your balls spawn ball