Senior Member
|
01-26-2013
, 22:45
Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
|
#11
|
Quote:
Originally Posted by Leonardo
as longer as TF2Items GiveWeapon uses TF2ItemsInfo,
there's already TF2ItemSlot enum
so you have to check for it
Code:
#if !defined _tf2itemsinfo_included
new TF2ItemSlot = 8;
#endif
you also can crate weapon with TF2Items GiveWeapon' natives
Code:
public OnAllPluginsLoaded()
{
TF2Items_CreateWeapon( 9990, "tf_weapon_syringegun_medic", 527, 0, 9, 10, "280 ; 1 ; 6 ; 1.45 ; 31 ; 3 ; 32 ; 1 ; 2 ; 1.4 ; 125 ; -10", 300, _, true );
}
also someone told me do not use function/variable names longer than 32 chars.
so plugin should look like:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <tf2_stocks>
#define REQUIRE_EXTENSIONS
#define AUTOLOAD_EXTENSIONS
#include <tf2items>
#undef REQUIRE_PLUGIN
#tryinclude <tf2itemsinfo>
#define REQUIRE_PLUGIN
#include <tf2items_giveweapon>
#define MY_WEAPON_ID 9090
#if !defined _tf2itemsinfo_included
new TF2ItemSlot = 8;
#endif
public Plugin:myinfo =
{
name = "[TF2] Pyro Battle",
author = "You",
description = "A gamemode where pyros fight each others.",
version = "1.1",
url = "http://forums.alliedmods.net/showthread.php?t=203225"
};
public OnPluginStart()
{
HookEvent( "post_inventory_application", OnHookedEvent );
HookEvent( "player_spawn", OnHookedEvent );
}
public OnAllPluginsLoaded()
{
TF2Items_CreateWeapon( MY_WEAPON_ID, "tf_weapon_syringegun_medic", 527, 0, 9, 10, "280 ; 1 ; 6 ; 1.45 ; 31 ; 3 ; 32 ; 1 ; 2 ; 1.4 ; 125 ; -10", 300, _, true );
}
public OnPostInventoryApplicationAndPlayerSpawn( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) )
if( iClient <= 0 || iClient > MaxClients || !IsClientInGame(iClient) /*|| !IsPlayerAlive(iClient)*/ )
return;
for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
TF2_RemoveWeaponSlot( iClient, iSlot );
TF2_SetPlayerClass( iClient, TFClass_Pyro, _, true );
TF2Items_GiveWeapon( iClient, MY_WEAPON_ID );
}
EDIT:
oh
any reason why it's a tf_weapon_syringegun_medic with item ID #527 ( widowmaker)?
|
Here is a fixed version of the code above:
Code:
#pragma semicolon 1
#include <sourcemod>
#include <tf2_stocks>
#define REQUIRE_EXTENSIONS
#define AUTOLOAD_EXTENSIONS
#include <tf2items>
#undef REQUIRE_PLUGIN
#tryinclude <tf2itemsinfo>
#define REQUIRE_PLUGIN
#include <tf2items_giveweapon>
#define BATTLE_RIFLE_ID 9090
#if !defined _tf2itemsinfo_included
new TF2ItemSlot = 8;
#endif
public Plugin:myinfo =
{
name = "[TF2] Pyro Battle",
author = "Bitl",
description = "A gamemode where pyros fight each others.",
version = "1.1",
url = "http://forums.alliedmods.net/showthread.php?t=203225"
};
public OnPluginStart()
{
HookEvent( "post_inventory_application", OnPostInventoryApplicationAndPlayerSpawn );
HookEvent( "player_spawn", OnPostInventoryApplicationAndPlayerSpawn );
}
public OnAllPluginsLoaded()
{
TF2Items_CreateWeapon( BATTLE_RIFLE_ID, "tf_weapon_syringegun_medic", 527, 0, 9, 10, "280 ; 1 ; 6 ; 1.45 ; 31 ; 3 ; 32 ; 1 ; 2 ; 1.4 ; 125 ; -10", 300, _, true );
}
public OnPostInventoryApplicationAndPlayerSpawn( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) );
if( iClient <= 0 || iClient > MaxClients || !IsClientInGame(iClient) /*|| !IsPlayerAlive(iClient)*/ )
return;
for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
TF2_RemoveWeaponSlot( iClient, iSlot );
TF2_SetPlayerClass( iClient, TFClass_Pyro, _, true );
TF2Items_GiveWeapon( iClient, BATTLE_RIFLE_ID );
}
__________________
|
|