[DEV] ts error: nickname already in use

18. Juni 2018
2
1
1
39
Hey,
First of all thank you very much for the last answer (unfortunately I can not find my last ticket to answer back, I don't know why). Anyway, I have a working version of your system for rage linked with this ticket. (feel free to use it if you want). I have a weird issue: a few seconds after being switched in the ingame channel, teamspeak does an error: nickname already in use. It seems like it tries to rename two times, but I can not figure out why...

Thanks for your help,
Best regards, Xionxionxion (AdAstra RP)

Code:
var tsBrowser = null;
var refresh = 0;
var browserLoad = false;
var canBeRefreshed = true;
var currentUrl = '';

mp.events.add('ConnectTeamspeak', (status) => {
    if (status) {
        tsBrowser = mp.browsers.new('');
        setTimeout(function () {
            refresh = 1;
            mp.game.audio.playSoundFrontend(-1, "Hack_Success", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true);
        }, 500);
    } else {
        refresh = 0;
        if (tsBrowser != null) {
            tsBrowser.destroy();
            tsBrowser = null;
        }
        mp.game.audio.playSoundFrontend(-1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true);
    }
});

function distanceCalc(vector1, vector2) {
    return mp.game.system.vdist2(vector1.x, vector1.y, vector1.z, vector2.x, vector2.y, vector2.z);
}

function subtract(vector1, vector2) {
    vector1.x = vector1.x - vector2.x;
    vector1.y = vector1.y - vector2.y;
    vector1.z = vector1.z - vector2.z;
    return vector1;
}

mp.events.add('render', () => {
    if (tsBrowser != null && canBeRefreshed) {
        if (refresh == 1) {
            canBeRefreshed = false;
            var player = mp.players.local;
            var playerPos = player.position;
            var playerRot = player.getHeading();
            var rotation = Math.PI / 180 * (playerRot * -1);
            var playerNames = new Array();

            var callingPlayerName = player.getVariable("CALLING_PLAYER_NAME");
            if (callingPlayerName && player.getVariable("CALL_IS_STARTED")) {
                if (callingPlayerName != "") {
                    playerNames.push(callingPlayerName + "~10~0~0~3");
                }
            }

            mp.players.forEachInStreamRange(
                (playerStreamed, id) => {
                    var streamedPlayerPos = playerStreamed.position;
                    var distance = distanceCalc(playerPos, streamedPlayerPos);
                    var voiceRange = playerStreamed.getVariable("VOICE_RANGE");
                    var volumeModifier = 0;
                    var range = 25;
                    if (voiceRange == "Fort") {
                        range = 50;
                    }
                    else if (voiceRange == "Faible") {
                        range = 5;
                    }
                    if (distance > 5) {
                        volumeModifier = (distance * -5 / 10);
                    }
                    if (volumeModifier > 0) {
                        volumeModifier = 0;
                    }

                    if (distance < range) {
                        var subPos = subtract(streamedPlayerPos, playerPos);
                        var x = subPos.x * Math.cos(rotation) - subPos.y * Math.sin(rotation);
                        var y = subPos.x * Math.sin(rotation) + subPos.y * Math.cos(rotation);
                        x = x * 10 / range;
                        y = y * 10 / range;
                        var isDeath = playerStreamed.isDead();
                        if (isDeath == null || !isDeath) {
                            playerNames.push(playerStreamed.name + "~" + (Math.round(x * 1000) / 1000) + "~" + (Math.round(y * 1000) / 1000) + "~0~" + (Math.round(volumeModifier * 1000) / 1000));
                        }
                    }
                }
            );
            var newUrl = "http://localhost:15555/players/" + player.name + "/" + playerNames.join(";") + "/";
            if (currentUrl != newUrl) {
                tsBrowser.url = newUrl;
                currentUrl = newUrl;
            }
            setTimeout(function () {
                canBeRefreshed = true;
            }, 500);
        }
    }
});
 
  • Gefällt mir
Reaktionen: ByTropical

SeToY

Projektleiter
25. März 2016
4.447
15.627
1.117
Oberhausen, Deutschland
www.problemadmin.de
Hi,

thank you for providing the code for RageMP projects. Much appreciated.

I've converted your last ticket into a thread (pretty much like this one), as we have a dedicated category for that.

Regarding your issue: Is there some server-sided code you could provide? From the looks of it everything seems to be fine with your code.
 
19. September 2017
4
0
20
36
cmdflow.de
Kurzer Hinweis meinerseits:

Code:
function distanceCalc(vector1, vector2) {
    return mp.game.system.vdist2(vector1.x, vector1.y, vector1.z, vector2.x, vector2.y, vector2.z);
}

liefert keine Meter zurück. Im Beispiel hört ihr euch ab einer Rage von 50 nicht. Das sind aber nicht 50 Meter. Range 50 bei vdist2 sind in Meter ca 5-7.
Keine Ahnung was genau vdist2 zurückgibt, aber es sind jedenfalls keine Meter sonder ein vielfaches.
Falls jemand von euch verzweifelt wieso man sich immer nur innerhalb 5-7 Meter hört => erhöht die Range.
Bei ner Rage von 250 gehe ich mit dem Ingame Charakter 18 Schritte bis ich die Strecke zurückgelegt habe.

Hoffe das hilft dem einen oder anderen.

Gruß Flow