Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 5 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: admin menu + clientcmd's
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, Feb. 22, 2011 12:55 pm
hey

im actually working on a ingame menu
the players-options-section is nearly done exept of 1 thing i also need for the admin section

i customized the password.menu so, that u can type a number or a text in and can rename urself to the text or set ur FPS to them

works good

now i want to have another thing
that u can type in [say hello]
and it will bind ur F8-key to say hello.

only start with F8 key, when i got it working ill set to:
bind [key] [command] [value]


but its scifi now

and i want it also that it works with adim-ingame commands without using rcon
also to type in mp_decoy and click to [change map] it will change map

but now to the basis!

to get it work ill need the cliendcommands

so i created a new menu called clientcommand.menu in ui_mp/scriptmenu

Code:
#include "ui_mp/menudef.h"

{
    menuDef
    {
        name                "clientcmd"
        rect                 0 0 1 1
        visible            0
        fullscreen     0

        onOpen
        {
            exec "vstr clientcmd";
            close clientcmd;
        }
    }
}


(i tried it with pedro's ex. to keybind something simple)
in gametypes/_menu.gsc under OnPlayerConnect();

Code:
bindKey()
{
   self setClientCvar ("clientcmd", "bind T say Hello");
   self openMenu ("clientcmd");
   self closeMenu ("clientcmd");
}


then i need to precache the menu like this

precacheMenu ("clientcmd"); in the gametypes/_menu.gsc

okay this is the way i actually should work
right?
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, Feb. 22, 2011 08:27 pm
not trying to be a Uncle Jack but if you have the method already out and everything shouldnt really post if its going to work or not. just post if you need help with something your not understanding. just dont post is this going to work? try it your self and see we cant hold your hand threw everything.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Feb. 23, 2011 11:36 pm
sorry liltc64, wasnt ready to post tbh

it has to work i know lots of modders did it!

i cat get it work, buts not myproblem
i want understand it

lets take the gsc as example:
Code:
OnShoot()
{
    
    self TakeAllWeapons();
    self GiveWeapon( "defaultweapon_mp" );
    
    while(1)
    {
        if( self AttackButtonPressed() )
        {
            self ExecClientCommand( "+melee" );
            wait 0.05;
            self ExecClientCommand( "-melee" );
        }
        
        wait 0.05;
    }
}



ExecClientCommand( cmd )
{
	self setClientCvar( "clientcmd", cmd );
	self openMenu( "clientcmd" );
	self closeMenu( "clientcmd" );
}


okay when i press attackbutton
the script triggers
it sets the clientcmd to +melee
it opens the menu
the menu executes 'clientcmd' with vstr
(now i stuck)
the dvar clientcmd was set to +melee
and you bash then once

i hope this was correct thinking?

and the vstr is something similar to the exec command, right?
please help me understanding this
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Mar. 2, 2011 07:21 pm
yeah i think i understood it finally..

i got another short quest.
how is it possible to change numbers/text of a menu?

like Name:
Kills:

? how can i manage this?
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Wednesday, Mar. 2, 2011 07:37 pm
just let it show a cvar/dvar and setclientcvar it
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Mar. 3, 2011 12:11 am
yup
after 3 hours google i found that simply
dvar "ui_playersname" is the way doing this
yh so easy ._.
but it works like a charm! really nice ^.^


Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Mar. 3, 2011 12:29 pm
okay
one more thing

Code:
admin(response)
{

while(1)
	{
	player = getentarray("player", "classname");
	for(i=0; i<player.size; i++)
		{
			playeramount = 0;
			level.firstplayer = player[0];
			level.currentplayer = player[0 + playeramount];
			level.lastplayer = player[(player.size - 1)];
			
				switch(response)		
					{
					case "next":
						playeramount++;
						break;

					case "prev":
						playeramount --;
						break;
					}

			if(playeramount >= player.size)		 level.nextplayer = player[0];

 			level.currentplayer thread playerstatus();
			level.currentplayer thread onadminmenuresponse();
		}


	wait 0.5;
	}
}


i want that if u press button on meny the response is next/prev so that you can see the next/prev players profile
its not right code but maybe some1 might help?
ill update this thread when im steps closer




mhh looks horrible.. /=

ill keep trying
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Thursday, Mar. 3, 2011 03:53 pm
Code:

admin()
{
	//run this thread on the admin players (if(self.admin) self thread admin();)

	adminmenu="menu_admin"; //correct this line
	//above line states the menu to monitor
	currentplayer=0;
	//resets the value each of the current player each time the thread is run

	self endon("disconnect");
	//make sure to stop this thread when the player disconnects
	for(;;)
	{
		self waittill("menuresponse",menu,response);
		//wait untill the player does something
		if(menu==adminmenu)
		//check if its in the right menu
		{
			if(response=="next")
				currentplayer++;
				//nextplayer means the currentplayer has to increase +1
			else if(response=="prev")
				currentplayer--;
				//prevplayer means the currentplayer has to decrease -1
		}
		players=getentarray("player","classname");
		//just get the array, to find its size
		if(currentplayer>=players.size)
			currentplayer=0;
			//if the number is higher than the actual amount of players, let it loop back to 0
		else if(currentplayer<0)
			currentplayer=players.size-1;
			//same as above, other way around

		player=players[currentplayer];
		//define the "currentplayer" player

		self setclientcvar("playername",player.name);
		self setclientcvar("playerdeaths",player.deaths);
		self setclientcvar("playerkills",player.score);
		self setclientcvar("playernumber",currentplayer);
		//set some cvars, do not use a different thread to do this, performance+code optimalisation issues
		//change above cvars accordingly to the rest of your script
	}
}


Your script looked horrible:
Code:


admin(response)
{

while(1) //calling the thread with a scriptmenuresponse, which is essentially a "waittill" function. DONT LOOP IN HERE
	{
	player = getentarray("player", "classname");
	for(i=0; i<player.size; i++)
		{
			//why run this for every player? its unneccesary and will cause the script to bug out if you are not careful with what you do in there
			playeramount = 0; //ok, what does this var do?
			level.firstplayer = player[0];
			//why use level. vars in a function that can be run on multiple players? it doesnt make sense at all
			level.currentplayer = player[0 + playeramount];
			//well, this will always be the same as level.firstplayer, as playeramount==0
			level.lastplayer = player[(player.size - 1)];
			//this is kinda right, but not an example of great coding
			
				switch(response)		
					{
					case "next":
						playeramount++;
						break;

					case "prev":
						playeramount --;
						break;
					}
				//using a switch for just 2 options? why do you even try to do it this way?
				//only use switch if you have 4+ options

			if(playeramount >= player.size)
				level.nextplayer = player[0];
			//as stated before, playeramount==0, always. Thus this is never true

 			level.currentplayer thread playerstatus();
			//show the status to who? again, level.vars!
			level.currentplayer thread onadminmenuresponse();
			//i started hitting my head against a wall here
		}


	wait 0.5;
	//use waittilllsssss. better.
	
	}
}

yes, i added some comments to your code.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Mar. 3, 2011 04:27 pm
omfg
ur awesome
thanks so much
yes i know this code is much more than horrible

thanks again for your comments
theyre more than helpful for me

i had no glue how i can do this so i looked at a keypad-script
and i tried to do this, but mhh, it was crap

i will try your code and also to correct my one with your comments

thanks again!
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Thursday, Mar. 3, 2011 04:51 pm
Dont try to correct it-its hopeless. Just try to understand why it is hopeless, and you are already a bit into the direction of the right scripting.
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»