Sign in to follow this  
Followers 0
BraXi

A guide to clean mess after your DR plugins

7 posts in this topic

So I'm lately "editing" death run for people and I must say 90% of plugins fuck up the game in one or another way causing crashes and runtime errors and undefined behaviour in mod.

I'm not even mentioning how bad quality these plugins are but a few rules should be keept to keep the mod running how it was designed to be.

 

 

1. Allways TERMINATE your plugin before end of the map unless your plugin _really_ needs to do something during the _mod.gsc::EndMap()

level endon( "intermission" ); // so hart to put this in your plugins code? Huh?

2. Destroy scripted HUD elements at the end of the round and map, shotloads of plugins, fucking, prevent, map voting and best players board from running correctly due to HUD limits exceeded.

init( modVersion )
{
	thread cleanup();
	[ your plugin stuff ]
}

cleanup()
{
	level common_scripts\utility::waittill_any( "round_ended", "intermission" );

	notify( "TERMINATE YOUR PLUGIN" );
	your_hud destroy();
	your_entity delete();
}

3. When a function in your plugin does something on a player and has a wait() in it then TERMINATE it when player disconnects.

self endon( "disconnect" );

The same rule applies when ITERATING THROUGH ARRAY OF PLAYERS.

 

THE BAD WAY:

bad()
{
	players = getAllPlayers();
	for( i = 0; i < players.size; i++ )
	{
		p = players[i];
		p giveWeapon( "knife_mp" );
		wait 0.1; // WRONG FUCKING, WRONG, it takes 3 seconds to execute for 30 players and in that 3 seconds people may connect/disconnect causing this code to throw an error
		p switchToWeapon( "knife_mp" );
	}
}

THE GOOD WAY:

good()
{
	players = getAllPlayers();
	for( i = 0; i < players.size; i++ )
	{
		players[i] thread givegun( "knife_mp" );
	}
}

givegun( gun )
{
	self endon( "disconnect" );
	self endon( "death" );

	self giveWeapon( gun );
	wait 0.1;
	self switchToWeapon( gun );
}

4. When coding your plugin, map, or anything, learn to use this simple command to test it and fix errors: \DEVELOPER 1

 

 

0

Share this post


Link to post
Share on other sites

BraXi ya forgot the ugly way… FORMAT YOUR GODDAMN SCRIPTS PROPERLY OR YOU WILL BE TERMINATED!! :angryarnold: ARGH!

0

Share this post


Link to post
Share on other sites

You saved me braxi no wonder my hud was overlapping itself not my fault I swear :troll:

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0