What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [beta UPDATE] Math Games

[beta UPDATE] Math Games
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [beta release] Math Games
quote:
Originally posted by roflmao456
doesnt really work.... but you have a good idea though :D

when i enter in command it will say COMMAND NOT FOUND
Oops wasn't able to test it I am at work.
code:
/*

made by me, roflmao456 aka john
beta

edited by Matty

*/


var _answer;
var _randomop;
var _random1;
var _random2;
var _on = new Boolean(false);
var _played = new Boolean(false);
var _op = new Array('+', '-', '*', '/');

function OnGetScriptCommands(){
    var ScriptCommands = '<ScriptCommands>';
    ScriptCommands += '<Command>';
    if (_on == false) {
        ScriptCommands += '<Name>mgamestart</Name>';
        ScriptCommands += '<Description>Starts the Math Game</Description>';
    } else {
        ScriptCommands += '<Name>mgamestop</Name>';
        ScriptCommands += '<Description>Stops the Math Game</Description>';
    }
    ScriptCommands += '</Command>';
    ScriptCommands += '</ScriptCommands>';
    return ScriptCommands;
}

function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
    if (_on == false){
        if (sMessage.toLowerCase() == '/mgamestart'){
            _on = true;
            MsgPlus.DisplayToast('Math Game', 'Math Game is now started.');
            _playGame(pChatWnd);
            return '';
        }
    } else {
        if (sMessage.toLowerCase() == '/mgamestop'){
            _on = false;
            MsgPlus.DisplayToast('Math Game','Math Game is now stopped.');
            _played = false;
            return '';
        }
    }
}

function _playGame(pChatWnd){
    Debug.Trace('_playGame function called.'); //start setting random question
    _random1 = Math.round(Math.random()*(99)+1);
    _random2 = Math.round(Math.random()*(99)+1);
    _randomop = Math.round(Math.random()*(_op.length-1));
    _answer = eval(_random1+_op[_randomop]+_random2); // set up the answer
    if (_played != true){
        _on = false;
        pChatWnd.SendMessage('Welcome to Math Game, I am going to ask you math questions.');
        pChatWnd.SendMessage('What is.. \n\n'+_random1+' '+_op[_randomop]+' '+_random2+'?');
        _on = true;
    } else {
        _on = false;
        pChatWnd.SendMessage('new Question!');
        pChatWnd.SendMessage('What is.. \n\n'+_random1+' '+_op[_randomop]+' '+_random2+'?');
        _on = true;
    }
}

function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage){
    if (_on == true){
        if (sOrigin != Messenger.MyName){
            if (sMessage == _answer){
                pChatWnd.SendMessage('That is correct!');
                _played = true;
                _playGame(pChatWnd);
            } else {
                pChatWnd.SendMessage('That is wrong. The correct answer was: '+_answer+'.');
                _played = true;
                _playGame(pChatWnd);
            }
        }
    }
}


that should work, I had _playGame() when it should be _playGame(pChatWnd).
11-28-2006 04:09 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[beta UPDATE] Math Games - by roflmao456 on 11-27-2006 at 11:24 PM
RE: [beta release] Math Games - by matty on 11-27-2006 at 11:47 PM
RE: [beta release] Math Games - by roflmao456 on 11-28-2006 at 12:42 AM
RE: [beta release] Math Games - by dylan! on 11-28-2006 at 12:44 AM
RE: [beta release] Math Games - by matty on 11-28-2006 at 02:38 AM
RE: RE: [beta release] Math Games - by roflmao456 on 11-28-2006 at 04:04 AM
RE: [beta release] Math Games - by matty on 11-28-2006 at 04:09 AM
RE: [beta release] Math Games - by roflmao456 on 11-28-2006 at 04:15 AM
RE: [beta UPDATE] Math Games - by elektra on 11-28-2006 at 04:49 PM
RE: RE: [beta UPDATE] Math Games - by roflmao456 on 11-28-2006 at 08:56 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On