Results 1 to 5 of 5

Thread: [CoD 1.1] Does modifying game["menu_team"] applies only to self?

  1. #1
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts

    [CoD 1.1] Does modifying game["menu_team"] applies only to self?

    Hello

    Do you know if modifying game["menu_team"] applies only to self?

    I tried self game["menu_team"] = ... but that gives me a bad syntax error

    I'm not sure how I could check if it does or not ...

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    I don't get what you're trying to do. If you're trying to edit which menu file gets shown to players, just do it through script. If you're trying to modify it globally, then why are you using self? Also, who (or what) is self in the context that you're describing?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    raphael (22nd March 2023)

  4. #3
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by IzNoGoD View Post
    If you're trying to edit which menu file gets shown to players, just do it through script.
    Do you mean it's possible to set a specific team menu to a specific player through gsc ? (I mean not globally/not for everyone)

    Quote Originally Posted by IzNoGoD View Post
    Also, who (or what) is self in the context that you're describing?
    In this context, self is a player

    Here is the code I'm trying to make working :

    Code:
    //1. Put this file in the "codam" folder of the "main" server folder.
    //2. Add the below line to "modlist.gsc":
    //[[register]]("Promod", codam\promod::main);
    
    main(phase, register)
    {
    	switch(phase)
    	{
    		case "init": _init(register); break;
    	}
    }
    _init(register)
    {
    	if(isDefined(level.promod))
    		return;
    	level.promod = true;
    
    	[[register]]("PlayerConnect", ::playerConnect, "thread");
    	[[register]]("PlayerDisconnect", ::deleteVar, "thread");
    	[[register]]("gt_spawnSpectator", ::spawnSpectator, "thread");
    	[[register]]("gt_startRound", ::startRound, "thread");
    
    	if (getCvar("previousmap") == "") //SERVER JUST STARTED
    	{
    		setCvar("previousmap", getCvar("mapname"));
    	}
    	else
    	{
    		if (getCvar("previousmap") != getCvar("mapname")) //MAP CHANGED
    		{
    			level.mapchanged = true;
    			setCvar("previousmap", getCvar("mapname"));
    		}
    	}
    }
    
    playerConnect(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, b0, b1, b2, b2, b4, b5, b6, b7, b8, b9)
    {
    	//RESTORE alreadyconnected vars
    	vidrestart = getCvar("tmp_pm_alreadyconnected");
        if (vidrestart != "") 
    	{
    		vidrestart = codam\_mm_mmm::strTok(vidrestart, ";");
            for (i = 0; i < vidrestart.size; i++) 
    		{
                num = self getEntityNumber();
                user = codam\_mm_mmm::strTok(vidrestart[i], "|");
    
                if (user[1] == num)
    			{
    				self.pers["alreadyconnected"] = user[0];
                    break;
                }
            }
        }
    
    	//CHECK IF ALREADY JOINED AND IS A FULLBRIGHT MAP (so no unnecessary vid_restart for r_overBrightBits)
    	if (isDefined(self.pers["alreadyconnected"]))
    	{
    		if (isDefined(level.mapchanged))
    		{
    			mapname = getCvar("mapname");
    			if (mapname == "mp_carentan" || mapname == "mp_depot")
        		{
    				self setClientCvar("r_fullbright", 1);
    
    				prefix = "1sk_team_vidrestart_";
    				game["menu_team"] = prefix + game["allies"] + game["axis"];
    				precacheMenu(prefix + "americangerman");
    				precacheMenu(prefix + "britishgerman");
    				precacheMenu(prefix + "russiangerman");
    
    				self.pers["removevidrestartmenuneeded"] = true;
    			}
    			else
    			{
    				//SET NORMAL MENU
    
    				prefix = "1sk_team_";
    
    				game["menu_team"] = prefix + game["allies"] + game["axis"];
    				precacheMenu(prefix + "americangerman");
    				precacheMenu(prefix + "britishgerman");
    				precacheMenu(prefix + "russiangerman");
    			}
    		}
    		else
    		{
    			//SET NORMAL MENU
    
    			prefix = "1sk_team_";
    
    			game["menu_team"] = prefix + game["allies"] + game["axis"];
    			precacheMenu(prefix + "americangerman");
    			precacheMenu(prefix + "britishgerman");
    			precacheMenu(prefix + "russiangerman");
    		}
    	}
    	//CHECK IF FIRST JOIN: validate r_overBrightBits (that will also do vid_restart in case is a r_fullbright map)
    	else
    	{
    		self setClientCvar("r_overBrightBits", 0);
    		self setClientCvar("r_swapInterval", 0);
    
    		mapname = getCvar("mapname");
    		if (mapname == "mp_carentan" || mapname == "mp_depot")
        	{
    			self setClientCvar("r_fullbright", 1);
    		}
    
    		prefix = "1sk_team_vidrestart_";
    		game["menu_team"] = prefix + game["allies"] + game["axis"];
    		precacheMenu(prefix + "americangerman");
    		precacheMenu(prefix + "britishgerman");
    		precacheMenu(prefix + "russiangerman");
    
    		self.pers["removevidrestartmenuneeded"] = true;
    
    		//SET VAR alreadyconnected
    		self.pers["alreadyconnected"] = true;
    		clientnum = self getEntityNumber();
    		removeVar(clientnum);
        	rSTR = "";
        	if (getCvar("tmp_pm_alreadyconnected") != "")
    		{
    			rSTR += getCvar("tmp_pm_alreadyconnected");
    		}
        	rSTR += true;
        	rSTR += "|" + clientnum;
        	rSTR += ";";
        	setCvar("tmp_pm_alreadyconnected", rSTR);
    	}
    }
    
    deleteVar(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9)
    {
        num = self getEntityNumber();
        removeVar(num);
    }
    removeVar(num)
    {
        vidrestart = getCvar("tmp_pm_alreadyconnected");
        if (vidrestart != "") 
    	{
            vidrestart = codam\_mm_mmm::strTok(vidrestart, ";");
            validuser = false;
            rSTR = "";
            for(i = 0; i < vidrestart.size; i++) 
    		{
                user = codam\_mm_mmm::strTok(vidrestart[i], "|");
                if(user[1] == num) 
    			{
                    validuser = true;
                    continue;
                }
                rSTR += vidrestart[i];
                rSTR += ";";
            }
            if (validuser)
    		{
    			setCvar("tmp_pm_alreadyconnected", rSTR);
    		} 
        }
    }
    
    spawnSpectator(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9)
    {
    	setPlayerCvars(self);
    
    	//REMOVE VIDRESTART MENU IF SET
    	if (isDefined(self.pers["removevidrestartmenuneeded"]))
    	{
    		wait 1;
    
    		prefix = "1sk_team_";
    
    		game["menu_team"] = prefix + game["allies"] + game["axis"];
    		precacheMenu(prefix + "americangerman");
    		precacheMenu(prefix + "britishgerman");
    		precacheMenu(prefix + "russiangerman");
    
    		self setClientCvar("g_scriptMainMenu", game["menu_team"]);
    		self openMenu(game["menu_team"]);
    
    		self.pers["removevidrestartmenuneeded"] = undefined;
    	}
    }
    
    startRound(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9)
    {
    	if (getCvar("g_gametype") == "sd")
    	{
    		wait 1;
    
    		players = getEntArray("player", "classname");
    		
    		if (players.size > 0)
    		{
    			for(i = 0; i < players.size; i++)
    			{
    				setPlayerCvars(players[i]);
    			}
    		}
    	}
    }
    
    setPlayerCvars(player)
    {
    	if (!isDefined(player.pers["mm_fov"]))
    	{
    		player setClientCvar("cg_fov", 93);
        }
    	player setClientCvar("fx_draw", 0);
    	player setClientCvar("r_fog", 0);
    	player setClientCvar("r_entFullbright", 1);
    }

    I just ran my public server with that, when a player joined, clicking on a team just showed again the team menu (in my case)

  5. #4
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    I accidentally deleted the part where I explained what I'm trying to do

    I'm trying to make some players execute the vid_restart command, at some specific moments

    For that I set a custom team menu that exec a cfg file when being opened (I don't know another way to do it)

    Edit:

    On my testing server, I just reproduced what happened on the public one

    When a player is joining and downloading files, the player who clicks a team just get the team menu again

    When the player finished downloading and is in, now clicking a team propose to pick a weapon
    Last edited by raphael; 9th March 2023 at 19:23.

  6. #5
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    I think I found a solution here :
    - https://killtube.org/showthread.php?...er-Redirection
    - https://killtube.org/showthread.php?...y-boobs-quot-)


    It looks to be a better way/the way for what I try to achieve

    I will tell if I succeed

    edit: my issue is fixed using this "ExecClientCommand" trick
    I don't need to modify the team menu anymore
    Last edited by raphael; 9th March 2023 at 23:17.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •