[Support] Can you set DVAR so players have VIP when map changes?
-
init() { level.vipXuids = []; // You can predefine XUIDs in your script like this level.vipXuids[0] = "predefined_xuid_here"; level.vipXuids[1] = "another_one"; level.vipXuids[2] = "etc, etc."; level thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill("connected", player); if(isInArray(level.vipXuids, player getXUID())) { // If the player XUID is in the predefined array, give them VIP status and set their VIP dvar player.status = "VIP++"; // Give them VIP status for the script self setPlayerVipDvar(true); // Set their VIP status DVAR } else if(player getPlayerDvar()) { // If the player does not have their XUID in the predefined array but has their VIP dvar set player.status = "VIP++"; // Give them VIP status for the script self setPlayerVipDvar(true); // Set their VIP status DVAR } /* You could combine the two conditions using an || operator, but this should be a little easier to understand for beginners. */ player thread onPlayerSpawned(); } } onPlayerSpawned() { self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("spawned_player"); if(self.status == "VIP++") { // If player has VIP status // Do VIP things } } } setPlayerVipDvar(value) { setPlayerDvar(self, "vip_status", value); } getPlayerVipDvar() { return getPlayerDvar(self, "vip_status"); } setPlayerDvar(player, dvar, value) { dvar = player getXUID() + "_" + dvar; setDvar(dvar, value); } getPlayerDvar(player, dvar) { dvar = player getXUID() + "_" + dvar; return getDvar(dvar); }
Here's how I'd accomplish what you're trying to do. It's untested but you can take a look to try and understand the general process as I left comments. I'm willing to help you on Discord or something since you at least attempted to write your own script and showed what you tried.
-
TheHiddenHour this looks really good! is this something that works without server restart? (like you could do this ingame and when the next map rotates, it applies)
-
mikzy It should work between map restarts. The only thing that can reset the dvars on console at least is through doing it manually or resetting the entire server.
You also might want to make your own
isInArray()
function, I can't remember if it actually exists or is accessible .arrayContains(array, value) { foreach(item in array) { if(item == value) { return true; } } return false; }
-
Thanks alot my friend, excited to try this. Appreciate the amount of effort put into your response mate
-
ImVeryTwisted did this ever work? sorry for bumping. need this really bad and need results.
TheHiddenHour did you mean a RESET like completely resetting the server files or RESTART? -
mikzy Restart
-
mikzy I don't think the post above was as clear as it could be, so im gonna show you how i got this to work on my server.
First we need some utilities in order for this to work. Import this code anywhere into yours.
setPlayerDvar(player, dvar, value) { thedvar = player getXUID() + "_" + dvar; setDvar(thedvar, value); } getPlayerDvar(player, dvar) { thedvar = player getXUID() + "_" + dvar; return getDvar(thedvar); }
Once that is done, you can add dvars to functions like so.
func_givevip(player) { if(player != self && player.status != "VIP") { player.status = "VIP"; setPlayerDvar(player, "VIP", true); //sticky dvar function!! } }
Then all you'd need to do is add an if check in your onPlayerConnect to give players with the dvar enabled vip.
onPlayerConnect() { for(;;) { level waittill("connecting", player); player thread onPlayerSpawned(); if(getPlayerDvar(player, "VIP") == "") {} else if(getPlayerDvar(player, "VIP") == true) player.status = "VIP"; } }
I found that it had to be done this way because getPlayerDvar does not reliably get the variable when checking for numbers, or true/false.
So using "" as false, and "true" as true it is able to work properly -
Cahz and this is a DVAR VIP system meaning it stores it as a DVAR until server restarts and works through map rotations?
-
-
This post is deleted!