Player Status

72 views
Skip to first unread message

Mark Holliday

unread,
Nov 5, 2014, 9:29:17 AM11/5/14
to ajax...@googlegroups.com
Phpbb3 version. I've added a player status for ajaxChat which works as it should by adding the following lines of code ...

loggedin.html
                        <label for="Status">Status:</label>
                        <select id="status" onchange="document.getElementById('looking').selectedIndex=0; ajaxChat.playerStatus(this.options[this.selectedIndex].value, 0);">
                                <option>&nbsp;</option>
                                <option>Here</option>
                                <option>Busy</option>
                                <option>Away</option>
                                <option>BRB</option>
                                <option>Need a Pard !</option>
                        </select>
                        &nbsp;&nbsp;<label for="lookingFor" style="background-color:#CFE7E2; color:black;">&nbsp;Looking For:&nbsp;</label>
                        <select id="looking" onchange="document.getElementById('status').selectedIndex=0; ajaxChat.playerStatus(this.options[this.selectedIndex].value, 1);">
                                <option>&nbsp;</option>
                                <option>WGTLS 3</option>
                                <option>WGTLS 9</option>
                                <option>Match 9</option>
                                <option>Guilds Open (Alternate)</option>
                                <option>Guilds Open (Bestball)</option>
                                <option>Top Dog</option>
                                <option>WGTLS Tour</option>
                                <option>KO Tourney</option>
                                <option>League Tables</option>
                                <option>WGTLS Open</option>
                                <option>PGA (9 Holes)</option>
                                <option>PGA (18 Holes)</option>
                                <option>WGTLS Blitz</option>
                        </select

Ajaxchat.php
        function playerstatus($status, $colour) {
                if($this->isUserOnline($userid)) {
                        $this->setUserStatus($status);
                        $this->setUserStatusColour($colour);
                        $this->updateOnlineList();
                        $this->addInfoMessage($status, 'userStatus');
                        $this->addInfoMessage($colour, 'userStatusColour');
                        // Change status message
                        $text = '/playerstatus '.$this->getUserName().' '.rawurlencode($this->getUserStatus()).' '.$this->getUserStatusColour();
                        $this->insertChatBotMessage(
                                $this->getChannel(),
                                $text,
                                null,
                                1
                        );
                }
                // Re-initialize the view:
                $this->initView();
        }

chat.js
        playerStatus: function(usernewStatus, colour) {
                if(ajaxChat.inArray(ajaxChat.playerStatuses, usernewStatus)) {
                        clearTimeout(ajaxChat.timer);
                        var message = 'playerstatus=' + ajaxChat.encodeText(usernewStatus) + '&colour=' + colour;
                        ajaxChat.makeRequest(ajaxChat.ajaxURL,'POST',message);
                }
        },

which as I said earlier does exacty what I need to.

What I wanted to do was call this from an external PHP script to update the players status when a certain event happened.

I tried using the "Display online users" script ...


so it references the functions in Ajaxchat.php but when I call it using "$chatInterface->playerstatus($status, $colour) " nothing happens.

I'm no expert so may very well have missed something here.




Chris D

unread,
Nov 11, 2014, 11:36:26 PM11/11/14
to
Hmm aside from what you added above is there any additional code to add such as a /case switch? I'm running vbulletin which is slightly diff however from everything you've posted it looks to only be via internal. Any additional information is greatly appreciated as this would be a great mod for others as well if you were to post the full version ( if this already isn't ) 

Just getting an "unknown command: /playerstatus"




Mark Holliday

unread,
Nov 12, 2014, 3:56:45 PM11/12/14
to ajax...@googlegroups.com
No there are bits I've not added above because they didn't seem relevant. I only posted those above to show how it worked. What I think is happening is the session is being lost when calling my playerstatus code from an external script eg not in the ajaChat loggedin.html

Currently the players can change their own status manually so it isn't the end of the world but would of liked it to be automated.


On Wednesday, 12 November 2014 04:36:26 UTC, Chris D wrote:

Chris D

unread,
Nov 12, 2014, 10:33:06 PM11/12/14
to ajax...@googlegroups.com
Would you be willing to share your mod with everyone? This would be very useful especially for those of us running fansites for gaming communities. I'm constantly trying to find new things to add to mine. Appreciate anything you can share, and hopefully someone can help you out, either Frug, Syn or a few other guru's here.
Reply all
Reply to author
Forward
0 new messages