Commit 69a5150f authored by Dennis Willers's avatar Dennis Willers
Browse files

Version 1.0

parent 7ede522d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ author = "RoboTec13"
category = "Race"

version = "1.0"
siteid = 120

[script]
imports = ["Icons.as", "Formatting.as"]
imports = ["Icons.as", "Formatting.as", "Permissions.as"]
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ void waitingForResponse() {
}

void requestSocketServer(const Json::Value &in js) {
	print("JSON REQUEST: "+ Json::Write(js));
	// Send raw data (as a string) to the server.
	if (!sock.WriteRaw(Json::Write(js))) {
		// If this fails, the socket might not be open. Something is wrong!
@@ -46,6 +47,7 @@ void requestSocketServer(const Json::Value &in js) {

void handleMessage(const Json::Value &in js)
{
	print("JSON RESPONSE: "+ Json::Write(js));
	if (Json::Write(js) != "null") {
		setVotingInformation(js);
	} 
+3 −1
Original line number Diff line number Diff line
string currentChatMessage = "";

void readLastChatMessage() {
    if (Permissions::InGameChat()) {
        while(true) {
            if (getNetwork() !is null) {
                MwFastBuffer<wstring> chatHistory = getNetwork().ChatHistoryLines;
            if (chatHistory.get_Length() > 0) {
                if (chatHistory.Length > 0) {
                    string chatMessage = chatHistory[0];
                    if (chatMessage != currentChatMessage && !hasVoteTimeout) {
                        currentChatMessage = chatMessage;
@@ -17,6 +18,7 @@ void readLastChatMessage() {
            }
        }
    }
}

bool checkIfMessageIsByCurrentClient() {
    string user = currentChatMessage.SubStr(3,currentChatMessage.IndexOf('$>]')-3);
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ void newSelectedVoteByChat(int newSelectedValue, int vote) {
void selectValue(int newSelectedValue, int vote, bool isPrintVote) {
    if (!hasVoteTimeout && selectedValue != newSelectedValue) {
        selectedValue = newSelectedValue;
        requestSocketServer(jsonBuilderSetVote(vote));
        setVoteInformation(vote);
        if (isPrintVote) printVote(vote);
        startnew(setVoteTimeout);
    }
+20 −9
Original line number Diff line number Diff line
Json::Value jsonBuilderSetVote(int vote) {
// JSON REQUESTS

Json::Value getVotes() {
    auto jsonObj = Json::Object();
    jsonObj["vote"] = vote;
    jsonObj["mapId"] = getMapUid();
    jsonObj["userId"] = getLogin();
    jsonObj["name"] = getNameForUi();
    jsonObj["map"] = getMapUid();
    jsonObj["http"] = "GET";
    jsonObj["url"] = "getVotes?map="+getMapUid();
    return jsonObj;
}

Json::Value getPlayerVote() {
    auto jsonObj = Json::Object();
    jsonObj["map"] = getMapUid();
    jsonObj["http"] = "GET";
    jsonObj["url"] = "getPlayerVote?map="+getMapUid()+"&player="+getLogin();
    return jsonObj;
}

Json::Value jsonBuilderGetMapInfo() {
Json::Value setVote(int vote) {
    auto jsonObj = Json::Object();
    jsonObj["mapId"] = getMapUid();
    jsonObj["userId"] = getLogin();
    jsonObj["name"] = getNameForUi();
    jsonObj["map"] = getMapUid();
    jsonObj["http"] = "POST";
    jsonObj["player"] = getLogin();
    jsonObj["vote"] = vote;
    return jsonObj;
}
Loading