What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Help] I need help with a little game i'm making

[Help] I need help with a little game i'm making
Author: Message:
laurenz
Junior Member
**


Posts: 23
Joined: Sep 2005
O.P. [Help] I need help with a little game i'm making
Hi guys.
I want to test my scripting skills by making a rather simple game for my contacts to play. (if you wonder what game, it's this one)
It's not really a game, as the player is never able to win at all. But it's just to keep them busy for a while.

But there is one large problem i'm facing:
When 2 or more persons are playing the game at the same time, they will share the same values! So one person could be taking 3 stones, and at the same time someone else takes 2 stones, but they both get the same result since the person that used the command as last will overwrite the values of the other player's game.

So does anyone have a solution for not overwriting eachother's values?

This is the code:
code:
function OnEvent_Initialize(MessengerStart)
{
}

function OnEvent_Uninitialize(MessengerExit)
{
}

var send // text that get's sended
var stenen // amount of stones left
var spelregels // true if waiting for answer if the person wants to know the rules or not
var start // true when the game has actually started
var contact // E-mail of the contact i'm talking to

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    for (var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext())
    {
        contact = e.item().Email;
    }
     
     if(MessageKind == 1 && Origin != Messenger.MyName && Message.substr(0,5) == "!spel") // start the intro when !spel gets said (spel means game in dutch)
     {
         send = "Heej "+ contact + "!\nDus jij wilt het spelletje steentje rapen tegen mij spelen? Nou, kom maar op dan!\nWil je eerst de spelregels horen? ja/nee"; // ask if player wants to hear the rules
         ChatWnd.SendMessage(send);    // send message
         spelregels = true // there has been asked if the player wants to see rules or not
     }
     
    else if(MessageKind == 1 && Origin != Messenger.MyName && spelregels == true) // check if the script is waiting for a answer on the rule question above
    {
        if(Message.substr(0,2) == "ja") // player wants to hear the rules
        {
            send = "De regels zijn erg simpel.\nEr zijn 23 stenen en in beurten pakken we ieder 1 tot 3 stenen van de stapel. Degene die de laatste steen moet pakken heeft verloren!\nLaten we dan maar eens beginnen."; // the rules
            ChatWnd.SendMessage(send); // send message
            spelregels = false; // answer recieved, don't wait for it anymore
            start = true; // start the actual game!
        }
       
        else if(Message.substr(0,3) == "nee") // player doesn't want to hear the rules
        {
            send = "Oké, laten we dan maar beginnen!"; // "Ok, Let's start then!"
            ChatWnd.SendMessage(send); // send message
            spelregels = false; // answer recieved, don't wait for it anymore
            start = true; // start the actual game!
        }
       
        else if(Message.substr(0,5) != "sorry" || Message.substr(0,3) != "dus") // the answer is neither yes nor no so ask the question again.
        {
            send = "Sorry, dit is een onverwacht antwoord\nWilt u de spelregels horen of niet? Typ simpelweg !ja of !nee."; // ask again
            ChatWnd.SendMessage(send); // send message
        }   
    }
   
    else if(MessageKind == 1 && Origin != Messenger.MyName && start == true){
// The game comes here.. No idea how though.
    }
}

I know I could have done a lot of things different and probably better. But I'm not that good in scripting so I only use stuff I know. You may comment about better ways of how to do this though.
But mainly I now want to know how to get all the values unique for every user that plays.

Any ideas about how to script the game is also appreciated!
06-22-2007 12:17 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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