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

Members Online

»
1 Active | 9 Guests
Online:

LATEST FORUM THREADS

»
water
CoD4 MP Mapping
ugw2gold
Starcraft 2
Rainbow HELP....
CoD4 MP Mapping
help pls
CoD2 Scripting

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 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access subscribe
Author Topic: Execute console command via script
reGi
General Member
Since: Mar 16, 2009
Posts: 71
Last: Aug 21, 2010
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 02:25 pm
How would i execute a command via a script. The one i want to execute is "viewpos" which is an action like +attack and -attack.

Thanks in advance
Jack
Share |
liverare
General Member
Since: Apr 20, 2010
Posts: 30
Last: Nov 27, 2010
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 02:29 pm
i aint %100 sure but im sure you can do binds like
/bind 0 g_gravity 2 -( only if u are on your own server)


or


/bind 9 viewpos (value of what ever you have to put, or nothing if all you say is viewpos if this makes any sence o.O)

sorry i cant be better help :(
Share |
reGi
General Member
Since: Mar 16, 2009
Posts: 71
Last: Aug 21, 2010
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 02:31 pm
i need it to execute via a script, it cannot be via binds, thanks anyway :)
Share |
liverare
General Member
Since: Apr 20, 2010
Posts: 30
Last: Nov 27, 2010
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 02:35 pm
ow like .gsc scripts?
oh iv seen that done before you need something like
setdvar("g_gravity","2");
in a script, but i duno how to code it so it triggers it, but I know its a setdvar,

i kno if u add this directly to ur mp_whateva.gsc under the rest it's instantly executed ingame, like if you write
setdvar("jump_height","200");
into the maps .gsc it will make the actual game play +161 higher jump :D cus defult is 39

hope this is a little more help :D
Share |
reGi
General Member
Since: Mar 16, 2009
Posts: 71
Last: Aug 21, 2010
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 04:18 pm
i already know this, this is to set dvar's though, i think it might be different to use a command.
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 04:56 pm
Let me see if i got it..
The title says: Execute console command via script

So, what you want is to make a script, install it and it will change a dvar?

As said above, (if you only want that, you just need setDvar("", "");)

like, if it is in a map, in the mp_.gsc file, add:

Code:

setDvar("", "");



Idk if Im right but do you want a script that creates a custom console cmd for you to change the dvar value in-game via rcon?



edited on Aug. 20, 2010 08:00 pm by LiQ.HeaDShOt
Share |
reGi
General Member
Since: Mar 16, 2009
Posts: 71
Last: Aug 21, 2010
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 05:07 pm
nope not at all, i want to execute the commands in the console via a mod.

Everything so far has been how to set a dvar but i want to execute a console command which if i am right is different to a dvar.

ie.

com_maxfps = dvar (can store a value)

god = command
+attack = command
-attack = command

i want to execute one of these commands via a mod.

Share |
_INSANE_
General Member
Since: Nov 6, 2008
Posts: 352
Last: Jul 10, 2011
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 08:17 pm
You would need to make a new menu and add it to your mod.
Something like this should be in the menu

Code:
#include "ui/menudef.h"

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

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


Then run a thread on the player that you want and set a clientdvar and open the menu..which then executes the command.

like...

Code:
player thread clientCommand("+attack; -attack");

clientCommand(cmd)
{
	self setClientDvar("ui_clientcmd", cmd);
	self openMenu("clientcmd");
	self closeMenu("clientcmd");
}


I'm pretty sure you can separate commands with a semi-colon... last i remember.
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 10:37 pm
If it is a command with a value, e.g. com_maxfps, then you can just do this on the player;

Code:
self setClientDvar( "com_maxfps", 125 );


Note: God and other cheat protected commands don't work if you try and execute them via the menu method without devmap/cheats enabled.
Share |
Restricted Access Restricted Access subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Why console gaming is dying
Quote:Consider this: Dedicated gaming sales — including living-room consoles...
Devs: Games are being dumb...
Click 'read more' to view the contents of this post.
Loadout
Gun Crafting to the Max. edited on Sep. 25, 2012 06:57 pm by Morp...
Introducing the Source Fil...
Surprised this wasn't made a long time ago. Sounds like a nice little feature.
Introducing the Source Fil...
The Source Filmmaker (SFM) is the movie-making tool built and used by us he...

Partners & Friends

»