Create a class

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Create a class

Post by Moustache » October 24th, 2011, 5:20 pm

In my mod I want to give people the option to create a custom class ingame without leaving the server or waiting till the game ends. I want to do this with a script.

I found this in the globallogic:

Code: Select all

player setclientdvar( "g_scriptMainMenu", game["menu_eog_main"] );
So I tested this in an other file:

Code: Select all

self openMenu( game["menu_eog_main"] );
menu.jpg
It opens that menu which contains Create a class.

When I change something in a custom class (with menu_eog_main) I get this two messages on the bottom left:
Unknown cmd updategamerprofile
Successfully wrote stats data
When I edit a class in that menu (for example custom class 1, change primary weapon from m16a4 to ak47) and then take a look in the normal choose class menu I see that the weapon has changed (ak47). But when I select it I get the old weapon (m16a4). But when the map rotates or I reconnect I do get the new weapon.

I have been trying to fix this for a few days now but I can't get it to work properly. Does anyone know how to fix it so I don't have to reconnect or wait on the map rotate?

I have tried to fix it with getstat and setstat.
self setstat( 201, 20 ); // set 201,customclass1,Primary Weapon, to ak47
But then I also have to reconnect first or wait for a map change to get it working.
You do not have the required permissions to view the files attached to this post.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Create a class

Post by Drofder2004 » October 25th, 2011, 4:36 am

HAve never tried it but I assume the stat file is read at the beginning of the map and therefore cannot interpret the change until after the map has reloaded.

I think the custom classes are controlled by dvar (cant remember, never tested), and if they are, then you could just edit the DVAR manually.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Create a class

Post by Moustache » October 25th, 2011, 7:07 pm

Drofder2004 wrote:HAve never tried it but I assume the stat file is read at the beginning of the map and therefore cannot interpret the change until after the map has reloaded.
But how is it possible then that the menu choose the new weapon but I still get the old weapon?
Drofder2004 wrote:I think the custom classes are controlled by dvar (cant remember, never tested), and if they are, then you could just edit the DVAR manually.
Below here is a part of changeclass.menu, I think it is the part where you are talking about but I don't know what do do with it. Can you help me out?

Code: Select all

		/* =================================== default classes ================================= */

		// PC widescreen fix
		#ifdef PC
			#undef  CHOICE_X_START
			#define CHOICE_X_START	-320
			
			#undef	CHOICE_HORIZONTAL_ALIGN
			#define CHOICE_HORIZONTAL_ALIGN HORIZONTAL_ALIGN_CENTER
		#endif
		
		CHOICE_SECTION_TITLE( 1, "@MPUI_DEFAULT_CLASSES" )		
		
		CHOICE_BUTTON_FOCUS( 2, "@CLASS_CLASS1", scriptMenuResponse "assault_mp,0"; close self, execnow "set ui_class_offset 200; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0", ; )
		CHOICE_BUTTON_FOCUS( 3, "@CLASS_CLASS2", scriptMenuResponse "specops_mp,0"; close self, execnow "set ui_class_offset 210; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0", ; )
		CHOICE_BUTTON_FOCUS( 4, "@CLASS_CLASS3", scriptMenuResponse "heavygunner_mp,0"; close self, execnow "set ui_class_offset 220; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0", ; )		
	
		CHOICE_BUTTON_FOCUS_VIS_ADV( 5, "@CLASS_CLASS4", scriptMenuResponse "demolitions_mp,0"; close self;, execnow "set ui_class_offset 230; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0", ;, when( stat( 257 ) >= 1 ), stat( 257 ) >= 1 )
		CHOICE_DBUTTON_VIS( 5, "@CLASS_CLASS4", when( stat( 257 ) < 1 ) )
		CHOICE_NEWICON_VIS( 5, "specialty_new", when( stat(257) > 1 ) )
		
		//CHOICE_BUTTON_FOCUS( 5, "@CLASS_CLASS4", scriptMenuResponse "demolitions_mp,0"; close self, execnow "set ui_class_offset 230; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0", ; )
		
		CHOICE_BUTTON_FOCUS_VIS_ADV( 6, "@CLASS_CLASS5", scriptMenuResponse "sniper_mp,0"; close self;, execnow "set ui_class_offset 240; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0";, ;, when( stat( 258 ) >= 1 ), stat( 258 ) >= 1 )
		CHOICE_DBUTTON_VIS( 6, "@CLASS_CLASS5", when( ( stat( 258 ) < 1 ) ) )
		CHOICE_NEWICON_VIS( 6, "specialty_new", when( stat(258) > 1 ) )
		
		//CHOICE_BUTTON_FOCUS( 6, "@CLASS_CLASS5", scriptMenuResponse "sniper_mp,0"; close self, execnow "set ui_class_offset 240; set ui_multi_s "HIGH_BOUND"; set ui_multi_dt 0", ; )	
		
		#define DATA_TABLE_PRIMARY				int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+1), 5 ))
		#define DATA_TABLE_PRIMARY_ATTACHMENT	int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+2), 5 ))
		#define DATA_TABLE_SECONDARY			int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+3), 5 ))
		#define DATA_TABLE_SECONDARY_ATTACHMENT	int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+4), 5 ))
		#define DATA_TABLE_SPECIALTY_EQUIPMENT	int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+5), 5 ))
		#define DATA_TABLE_SPECIALTY_WEAPON		int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+6), 5 ))
		#define DATA_TABLE_SPECIALTY_ABILITY	int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+7), 5 ))
		#define DATA_TABLE_SPECIAL_GRENADE		int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+8), 5 ))
		#define DATA_TABLE_CAMO					int(tablelookup( "mp/classTable.csv", 1, (dvarInt("ui_class_offset")+9), 5 ))

		/* ==================================== custom classes ============================================= */
				
		CHOICE_SECTION_TITLE_VIS( 8, "@MPUI_CUSTOM_CLASSES", when( stat(260) > 0 ); )	

		CHOICE_BUTTON_FOCUS_VIS( 9, dvarString( customclass1 ), scriptMenuResponse "custom1,0"; close self, setdvar ui_custom_class_highlighted "0"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( stat(260) > 0 ); )
		CHOICE_BUTTON_FOCUS_VIS( 10, dvarString( customclass2 ), scriptMenuResponse "custom2,0"; close self, setdvar ui_custom_class_highlighted "10"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( stat(210) > 0 ); )
		//CHOICE_DBUTTON_VIS( 10, dvarString( customclass2 ), when( stat( 210 ) == 0 && stat(260) > 0 ); )
		CHOICE_BUTTON_FOCUS_VIS( 11, dvarString( customclass3 ), scriptMenuResponse "custom3,0"; close self, setdvar ui_custom_class_highlighted "20"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( stat(220) > 0 ); )
		//CHOICE_DBUTTON_VIS( 11, dvarString( customclass3 ), when( stat( 220 ) == 0 && stat(260) > 0 ); )
		CHOICE_BUTTON_FOCUS_VIS( 12, dvarString( customclass4 ), scriptMenuResponse "custom4,0"; close self;, setdvar ui_custom_class_highlighted "30"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( stat(230) > 0 ); )
		//CHOICE_DBUTTON_VIS( 12, dvarString( customclass4 ), when( stat( 230 ) == 0 && stat(260) > 0 ); )
		CHOICE_BUTTON_FOCUS_VIS( 13, dvarString( customclass5 ), scriptMenuResponse "custom5,0"; close self;, setdvar ui_custom_class_highlighted "40"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( stat(240) > 0 ); )
		//CHOICE_DBUTTON_VIS( 13, dvarString( customclass5 ), when( stat( 240 ) == 0 && stat(260) > 0 ); )
		
		//CHOICE_BUTTON_FOCUS_VIS_ADV( 12, dvarString( customclass4 ), scriptMenuResponse "custom4,0"; close self;, hide loadout_info; show "custom4_loadout"; setdvar ui_custom_class_highlighted "30"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( stat( 257 ) >= 1 ), stat( 257 ) >= 1 )
		//CHOICE_DBUTTON_VIS( 12, dvarString( customclass4 ), when( ( stat( 257 ) < 1 ) ) )
		//CHOICE_NEWICON_VIS( 12, "specialty_new", when( stat(257) > 1 ) )
		
		//CHOICE_BUTTON_FOCUS_VIS_ADV( 13, dvarString( customclass5 ), scriptMenuResponse "custom5,0"; close self;, hide loadout_info; show "custom5_loadout"; setdvar ui_custom_class_highlighted "40"; exec "set ui_multi_s 0; set ui_multi_dt "HIGH_BOUND;, ;, when( ( stat( 258 ) >= 1 ) ), ( stat( 258 ) >= 1 ) )
		//CHOICE_DBUTTON_VIS( 13, dvarString( customclass5 ), when( ( stat( 258 ) < 1 ) ) )
		//CHOICE_NEWICON_VIS( 13, "specialty_new", when( stat(258) > 1 ) )			

		#define STATS_PRIMARY					stat( dvarInt( ui_custom_class_highlighted ) + 201 )
		#define STATS_RIMARY_ATTACHMENT			stat( dvarInt( ui_custom_class_highlighted ) + 202 )
		#define STATS_SECONDARY					stat( dvarInt( ui_custom_class_highlighted ) + 203 )
		#define STATS_SECONDARY_ATTACHMENT		stat( dvarInt( ui_custom_class_highlighted ) + 204 )
		#define STATS_SPECIALTY_EQUIPMENT		stat( dvarInt( ui_custom_class_highlighted ) + 205 )
		#define STATS_SPECIALTY_WEAPON			stat( dvarInt( ui_custom_class_highlighted ) + 206 )
		#define STATS_SPECIALTY_ABILITY			stat( dvarInt( ui_custom_class_highlighted ) + 207 )
		#define STATS_SPECIAL_GRENADE			stat( dvarInt( ui_custom_class_highlighted ) + 208 )
		#define STATS_CAMO						stat( dvarInt( ui_custom_class_highlighted ) + 209 )

		#include "ui/safearea.menu"
		
		/* ================================================================================= */
		/* ================================ LOADOUT DISPLAY ================================ */
		/* ================================================================================= */

		#define STAT_CAC_PRIMARY				int(min( STATS_PRIMARY+dvarInt(ui_multi_s), DATA_TABLE_PRIMARY+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_PRIMARY_ATTACHMENT		int(min( STATS_RIMARY_ATTACHMENT+dvarInt(ui_multi_s), DATA_TABLE_PRIMARY_ATTACHMENT+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_SECONDARY				int(min( STATS_SECONDARY+dvarInt(ui_multi_s), DATA_TABLE_SECONDARY+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_SECONDARY_ATTACHMENT	int(min( STATS_SECONDARY_ATTACHMENT+dvarInt(ui_multi_s), DATA_TABLE_SECONDARY_ATTACHMENT+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_SPECIALTY_EQUIPMENT	int(min( STATS_SPECIALTY_EQUIPMENT+dvarInt(ui_multi_s), DATA_TABLE_SPECIALTY_EQUIPMENT+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_SPECIALTY_WEAPON		int(min( STATS_SPECIALTY_WEAPON+dvarInt(ui_multi_s), DATA_TABLE_SPECIALTY_WEAPON+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_SPECIALTY_ABILITY		int(min( STATS_SPECIALTY_ABILITY+dvarInt(ui_multi_s), DATA_TABLE_SPECIALTY_ABILITY+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_SPECIAL_GRENADE		int(min( STATS_SPECIAL_GRENADE+dvarInt(ui_multi_s), DATA_TABLE_SPECIAL_GRENADE+dvarInt(ui_multi_dt) ))
		#define STAT_CAC_CAMO					int(min( STATS_CAMO+dvarInt(ui_multi_s), DATA_TABLE_CAMO+dvarInt(ui_multi_dt) ))
		

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Create a class

Post by Drofder2004 » October 25th, 2011, 11:38 pm

Nope, what you need is inside _class.gsc

cac_getData()

Code: Select all

cac_getdata()
{
        if ( isDefined( self.cac_initialized ) )
                return;
 
/*...etc*/
cac_getdata is the function that create the classes, this is run everytime the player spawns. However the code above simply stops the thread from continuing. You could potentially delete it, but I do not know what strain it would cause to do so (or if it is possible at all).

I would try deleting it first to see if it does actually work and then from there if it does work, use a method of stopping the loop unless the player changes their custom class [so the loop only happens when a change is made]
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Create a class

Post by Moustache » October 26th, 2011, 6:27 pm

Drofder2004 wrote:Nope, what you need is inside _class.gsc

cac_getData()

Code: Select all

cac_getdata()
{
        if ( isDefined( self.cac_initialized ) )
                return;
 
/*...etc*/
cac_getdata is the function that create the classes, this is run everytime the player spawns. However the code above simply stops the thread from continuing. You could potentially delete it, but I do not know what strain it would cause to do so (or if it is possible at all).

I would try deleting it first to see if it does actually work and then from there if it does work, use a method of stopping the loop unless the player changes their custom class [so the loop only happens when a change is made]
I appreciate your help :)

Sorry that is something I forgot to tell. I already checked the script and edited the _class.gsc:

Code: Select all

cac_getdata()
{
//	if ( isDefined( self.cac_initialized ) )
//		return;
self iPrintLnBold( "^1spawning player" ); // test
self iPrintLnBold( "primary weapon ccustom class 1 = " + self getstat( 201 ) );
self iPrintLnBold( "primary weapon ccustom class 1 = " + self getstat( 201 ) );
This line always prints the old weapon. But I just think it strange that the menu shows the new weapon and I spawn with the old and the 201 stat is still the old weapon.

Also I have tried to "discconect" myself and then "connect":
self thread Callback_PlayerConnect();
self thread Callback_PlayerDisconnect();

But nothing has worked so far :?

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Create a class

Post by Moustache » October 27th, 2011, 9:27 am

megazor wrote:
Also I have tried to "discconect" myself and then "connect":
self thread Callback_PlayerConnect();
self thread Callback_PlayerDisconnect();
All experienced modders (nearly Doctors of Scripting) will be lolling at it.
Yea I know but I just tried things that crossed my mind. I didn't give it a big chance of success.

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Create a class

Post by Moustache » October 28th, 2011, 8:12 am

megazor wrote:what u need is simply pay drofder 5 euro - and he will do this script job for you!
So you are saying it actually is posible?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Create a class

Post by Drofder2004 » October 28th, 2011, 9:58 pm

megazor wrote:what u need is simply pay drofder 5 euro - and he will do this script job for you!
Or you or IzNoGod could just do it for free...

Either way, atm I am stuck as to what to do, but to be honest, I have not looked beyond what I have already given you.
Maybe when a I get an hour or two free I will look further.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Create a class

Post by Moustache » October 29th, 2011, 1:59 pm

Drofder2004 wrote:
megazor wrote:what u need is simply pay drofder 5 euro - and he will do this script job for you!
Or you or IzNoGod could just do it for free...

Either way, atm I am stuck as to what to do, but to be honest, I have not looked beyond what I have already given you.
Maybe when a I get an hour or two free I will look further.
Thanks :)

I am also going to take a look at it myself today and try to find something.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Create a class

Post by Drofder2004 » October 29th, 2011, 8:05 pm

megazor wrote:if u give him 10 euro, he will find 10 free hours today.
Be useful or don't.
If you are not here to help, stay out the thread this is not the general section. Once may be funny, twice at a stretch but threee times and you become boring.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Create a class

Post by Moustache » October 31st, 2011, 8:42 pm

I tried to check all the stats but I couldn't find one that changed after editing the custom class. I also checked all the menus but failed to found the source of it.

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests