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

Members Online

»
0 Active | 10 Guests
Online:

LATEST FORUM THREADS

»
water
CoD4 MP Mapping
Script errors
CoD4 MP Mapping

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, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access subscribe
Author Topic: Command
z0d
General Member
Since: Apr 29, 2012
Posts: 33
Last: May 8, 2013
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Jul. 3, 2012 09:36 am
Hello,

I want to create command which works same way as quickchat ones work. So there aren't any for loops and it works only if you're logged with rcon. Any ideas?

Regards,
z0d
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, Jul. 3, 2012 10:44 am
a little confused on what you mean. could you elaborate more on that? maybe just give a quick example what you mean?
Share |
z0d
General Member
Since: Apr 29, 2012
Posts: 33
Last: May 8, 2013
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Jul. 3, 2012 11:11 am
well, I want to send some server informations to website (like player's weapon, score, deaths etc.etc.). to do so, i must create cvar which shows me weapon/score/deaths value. that way, i must create a for loop which changes cvar's value every second but i dont want to use for loop. so i thought i could avoid server loop if i make some quickchat 'command' which calls my function that updates cvar... since only rcon users will be able to get response of that value (cvar value), it doesn't really matter if other users (those who are not logged with rcon) will be able to call quickchat function since nothing will happen (they wont even notice) but to make it look better, id like to make some rcon command f.e. /rcon updateserverinfo and that way it will call function which updates cvars. so basically, command which works same way as quickchat commands work (no for loops or anything).
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, Jul. 3, 2012 11:18 am
so for your website to read these stats you would need your website to be able to read a file from your servers FTP. thats the only way i see it correct? in that case you have alot of work ahead of you to make this command. its easy to make the cvar but when you do that you need to gather everyone in the server and list them on a file and have there stats next to there name indvidualy. then not only that you need your website to go into this file and organize the stats and display it on your website. and yes its possible but thats alotttttt of work that im sorry i dont have time to help you with. but hopefully someone on this site can.
Share |
z0d
General Member
Since: Apr 29, 2012
Posts: 33
Last: May 8, 2013
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Jul. 3, 2012 11:31 am
nop, not really. might work that way but i connected to server using udp protocol. so it works way how 'console' works when u make homemade LAN/internet server.

well, here's sample i just made:

Code:
playerinfo()
{
		players = getentarray("player", "classname");
		
		for(i = 0; i < players.size; i++)
		{
			player = players[i];
	
			player_name = player.name;
			player_position = player.origin;
			player_angle = player.angle;
			player_health = player.health;
			player_score = player.score;
			player_deaths = player.deaths;
      
			infoplayer = player_position + "/"...;
                        
                        setcvar("serverinfo123", infoplayer);

			wait 0.1;
                 }
}


so as i explained before, thats what i want my command (rcon) to do. so just go through this function every time i call it.

edited on Jul. 3, 2012 11:32 am by z0d
Share |
kelik
General Member
Since: Jan 2, 2011
Posts: 13
Last: Dec 8, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Wednesday, Jul. 4, 2012 02:32 am
I might be wrong, since I'm not well-experienced, but I think you will still need a loop which would check if there's some update need to be done. As far as I know, you can't create and use rcon commands like /rcon updatestatus, I think you need to sign a value, like /rcon updatestatus 1. And because of that, you will need a loop that checks if 'updatestatus' var was changed. Can someone correct me if I'm wrong?
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: Wednesday, Jul. 4, 2012 03:43 am
your exactly right just make sure in your code you change it back to 0 after you assign it to 1, so it dosnt keep updating when you dont want it to.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 480
Last: Apr 15, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Jul. 4, 2012 07:14 am
why do you want not to use a loop?

you can do it without as you said with the quickchat-system

have a search here in the forums + dowload sections there was a guy iirc named nebulak who created a kind of ingame quickchat rcon tool

it locks you in as admin and maybe if you use it this way, lets say V + 5 + 1 > and send a response to your _menus.gsc
there you can check the menu and if it is your admin quickmenu and your are an admin, you can update your player-info

this would require a clientside-mod (> download)
you can avoid that by lets say manually binding a button with:
"bind M menuresponse adminmenu saveplayerinfo"
and check in your _menus.gsc if the menu is "-1" and the response > and now send your information via your script

this is a workaround with no clientside script and no extra loop

you still might check if the player is an admin with for example
Code:
if( player getGuid() == level.adminGuids[i] ) player.is_admin = true;


this is something what i wrote and use (similar) in my mod:

Code:
init()
{
	level thread updatePlayerInformationLooped();
}

updatePlayerInformationLooped()
{
	// catch all players
	players = getEntArray( "player" , "classname" );

	// while game[state] != "intermission"
	for( nextToUpdate = 0 ; !isDefined( game["state"] ) || game["state"] != "intermission" ; nextToUpdate++ )
	{
		// a short waittime: would take here 6.4 seconds to catch all possible players
		wait( 0.1 );

		// if we updated all players, reset variables and get all players again
		if( nextToUpdate >= players.size )
		{
			players = getEntArray( "player" , "classname" );
			nextToUpdate = 0;
		}

		// if the current player is defined & a player, save his stats
		if( isDefined( players[nextToUpdate] ) && isPlayer( players[nextToUpdate] ) )
		{
			// maybe check here if this player is allowed save his info
			// if( !players[nextToUpdate] isAdmin() )
			// 	continue;

			players[nextToUpdate] sendPlayerInfo();
		}
	}
	
	// if the game[state] is in intermission (scoreboard) then save again all stats
	level thread updatePlayerInformationSingle();
}

updatePlayerInformationSingle()
{
	players = getEntArray( "player" , "classname" );

	for( i = 0 ; i < players.size ; i++ )
	{
		wait( 0.1 );

		if( isDefined( players[i] ) && isPlayer( players[i] ) )
		{
			// maybe check here if this player is allowed save his info
			// if( !players[i] isAdmin() )
			// 	continue;

			players[i] sendPlayerInfo();
		}
	}
}

sendPlayerInfo()
{
	// seperate your inputs with this delimiter if parsing required on your website
	delim = "|";
	// define info as empty string
	info = "";

	// reset CVAR
	setCvar( "playerinfo" , info );

	// add all possible stats here
	data = [];
	data[data.size] = self.name;
	data[data.size] = self.origin;
	data[data.size] = self getGuid();
	data[data.size] = self getEntityNumber();
	data[data.size] = self.angles;
	data[data.size] = self getCurrentWeapon();
	data[data.size] = self.score;
	data[data.size] = self.deaths;
	
	// merge all information
	for( i = 0 ; i < data.size ; i++ )
	{
		if( isDefined( data[i] ) )
		{
			if( i == data.size - 1 )
				info += data[i];
			else
				info += ( data[i] + delim );
		}
	}

	// and send it this way to the server (remember the char limit is around 1000)
	setCvar( "playerinfo" , info );
}
Share |
z0d
General Member
Since: Apr 29, 2012
Posts: 33
Last: May 8, 2013
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Jul. 4, 2012 07:40 am
im not really a for loop lover so... :P ill check it out, thanks :)
Share |
Restricted Access Restricted Access subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 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

»