Post tutorial RSS A guide to make your DR plugins clean

Will give you an idea of how to make DR plugin bug & script error free Tutorial was made by BraXi on my website, thought be best to post here.

Posted by on - Basic Server Side Coding

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

Tutorial made by BraXi

Comments
Lossy Author
Lossy

appears my code tags messed up, will fix it later :|

Reply Good karma+2 votes
dannyboy2k15
dannyboy2k15

how do i open admin it dont let me im in the game and i go to open it and it dont open

Reply Good karma Bad karma+1 vote
Lossy Author
Lossy

You'll have to explain a bit more since i have no idea what you mean.

Reply Good karma+1 vote
Guest
Guest

This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.