Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. [Support] Can you set DVAR so players have VIP when map changes?

[Support] Can you set DVAR so players have VIP when map changes?

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
11 Posts 4 Posters 512 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ImVeryTwistedundefined Offline
    ImVeryTwistedundefined Offline
    ImVeryTwisted
    wrote on last edited by Mr. Android
    #1

    Are the dvars reset after each game? I've had a go at this but doesn't seem to work

    in my init:

    level.vipPlusPlusList = [];
    	i = 1;
    	while( i < 17 )
    	{
    		level.vipPlusPlusList[i - 1] = getdvar( "VIP++" + i );
    		i++;
    	}
    

    in my onplayerconnect:

    myXuid = player getXuid();
    
    
    	foreach(vip in level.vipPlusPlusList)
    	{
    		if (myXuid == vip )
    			player.status = "VIP++";
    	}
    

    a shortened version of my function to add a player to list:

    namedvarstick = player getXuid();
    
       	setdvar( "VIP++" + getdvar( "dvarVIPNumber" ), namedvarstick );
       	setdvar( "dvarVIPNumber", "" + ( getdvarint( "dvarVIPNumber" ) + 1 ) );
    
    1 Reply Last reply
    0
    • TheHiddenHourundefined Offline
      TheHiddenHourundefined Offline
      TheHiddenHour Contributor
      wrote on last edited by
      #2
      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.

      1 Reply Last reply
      0
      • mikzyundefined Offline
        mikzyundefined Offline
        mikzy Banned
        wrote on last edited by
        #3

        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)

        TheHiddenHourundefined 1 Reply Last reply
        0
        • TheHiddenHourundefined Offline
          TheHiddenHourundefined Offline
          TheHiddenHour Contributor
          replied to mikzy on last edited by
          #4

          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;
          }
          
          1 Reply Last reply
          0
          • ImVeryTwistedundefined Offline
            ImVeryTwistedundefined Offline
            ImVeryTwisted
            wrote on last edited by
            #5

            Thanks alot my friend, excited to try this. Appreciate the amount of effort put into your response mate

            1 Reply Last reply
            0
            • mikzyundefined Offline
              mikzyundefined Offline
              mikzy Banned
              wrote on last edited by
              #6

              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?

              TheHiddenHourundefined Cahzundefined 2 Replies Last reply
              0
              • TheHiddenHourundefined Offline
                TheHiddenHourundefined Offline
                TheHiddenHour Contributor
                replied to mikzy on last edited by
                #7

                mikzy Restart

                1 Reply Last reply
                0
                • Cahzundefined Offline
                  Cahzundefined Offline
                  Cahz VIP
                  replied to mikzy on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • mikzyundefined Offline
                    mikzyundefined Offline
                    mikzy Banned
                    wrote on last edited by
                    #9

                    Cahz and this is a DVAR VIP system meaning it stores it as a DVAR until server restarts and works through map rotations?

                    Cahzundefined 1 Reply Last reply
                    0
                    • Cahzundefined Offline
                      Cahzundefined Offline
                      Cahz VIP
                      replied to mikzy on last edited by
                      #10

                      mikzy that is absolutely correct. I didn't think it would work, but it does

                      1 Reply Last reply
                      0
                      • mikzyundefined Offline
                        mikzyundefined Offline
                        mikzy Banned
                        wrote on last edited by
                        #11
                        This post is deleted!
                        1 Reply Last reply
                        0

                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Donate