Hello, and today we will develop a plugin that modifies the inner game aspects for gameplay, also known as a gamemode.
With our gamemode, we will make one where you spawn as Pyro, and you get only one weapon.
Requirements:
-Sourcemod
-TF2
-TF2Items
-TF2Items GiveWeapon (plugin and .inc)
Now lets get started!
Includes (can be modified):
Code:
#include <sourcemod>
#include <tf2items>
#include <tf2_stocks>
#include <tf2items_giveweapon>
You need these for your plugin to compile correctly.
Now, to make our plugin.
Code:
new TF2ItemSlot = 8;
This tells us to find all the slots. We need this so that we can strip all the items.
Code:
public Plugin:myinfo =
{
name = "[TF2] Pyro Battle",
author = "Me",
description = "A gamemode where pyros fight eachother.",
version = "1.0",
url = ""
};
Plugin info, nothing new here.
Next you would need to hook the events, for this, I chose player_spawn and post_inventory_application.
Code:
public OnPluginStart()
{
HookEvent( "post_inventory_application", OnPostInventoryApplicationAndPlayerSpawn );
HookEvent( "player_spawn", OnPostInventoryApplicationAndPlayerSpawn );
}
Next, add the OnPostInventoryApplicationAndPlayerSpawn function.
Code:
public OnPostInventoryApplicationAndPlayerSpawn( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
}
Next, add the client defines in the extention:
Code:
new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) )
After that, add the part where it removes all of the players items before spawning.
Code:
for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
TF2_RemoveWeaponSlot( iClient, iSlot );
Next, add the weapon. we will talk about the weapon code later.
Code:
TF2Items_GiveWeapon(iClient, 9990);
Then add the slot1 and slot2 removers, just in case.
Code:
TF2_RemoveWeaponSlot(iClient, 1);
TF2_RemoveWeaponSlot(iClient, 2);
Then add the SetClass, and then you are done.
Code:
TF2_SetPlayerClass(iClient, TFClass_Pyro, false, true);
So the entire plugin should look like this:
Code:
#include <sourcemod>
#include <tf2items>
#include <tf2_stocks>
#include <tf2items_giveweapon>
new TF2ItemSlot = 8;
public Plugin:myinfo =
{
name = "[TF2] Pyro Battle",
author = "Me",
description = "A gamemode where pyros fight eachother.",
version = "1.0",
url = ""
};
public OnPluginStart()
{
HookEvent( "post_inventory_application", OnPostInventoryApplicationAndPlayerSpawn );
HookEvent( "player_spawn", OnPostInventoryApplicationAndPlayerSpawn );
}
public OnPostInventoryApplicationAndPlayerSpawn( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) )
for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
TF2_RemoveWeaponSlot( iClient, iSlot );
TF2Items_GiveWeapon(iClient, 9990);
TF2_RemoveWeaponSlot(iClient, 1);
TF2_RemoveWeaponSlot(iClient, 2);
TF2_SetPlayerClass(iClient, TFClass_Pyro, false, true)
}
Now, here's the weapon code, create a file named tf2items.givecustom.txt in sourcemod/configs, then put this in the .txt:
Code:
"custom_give_weapons_vlolz"
{
"9990"
{
"classname" "tf_weapon_syringegun_medic"
"index" "527"
"slot" "0"
"quality" "9"
"level" "10"
"attribs" "280 ; 1 ; 6 ; 1.45 ; 31 ; 3 ; 32 ; 1 ; 2 ; 1.4 ; 125 ; -10"
"ammo" "300"
}
}
Then you are done!
You can edit this plugin to your liking, but
DO NOT RELEASE THE PYROBATTLE PLUGIN TO NEW PLUGINS.
Plugin and files included are below.