Raised This Month: $51 Target: $400
 12% 

[TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode


Post New Thread Reply   
 
Thread Tools Display Modes
Bitl
Senior Member
Join Date: Jul 2012
Old 01-26-2013 , 22:45   Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
Reply With Quote #11

Quote:
Originally Posted by Leonardo View Post
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_CreateWeaponMY_WEAPON_ID"tf_weapon_syringegun_medic"5270910"280 ; 1 ; 6 ; 1.45 ; 31 ; 3 ; 32 ; 1 ; 2 ; 1.4 ; 125 ; -10"300_true );
}

public 
OnPostInventoryApplicationAndPlayerSpawnHandle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
    new 
iClient GetClientOfUserIdGetEventInthEvent"userid" ) )
    if( 
iClient <= || iClient MaxClients || !IsClientInGame(iClient/*|| !IsPlayerAlive(iClient)*/ )
        return;
    
    for( new 
iSlot 0iSlot _:TF2ItemSlotiSlot++ )
        
TF2_RemoveWeaponSlotiClientiSlot );
    
    
TF2_SetPlayerClassiClientTFClass_Pyro_true );
    
    
TF2Items_GiveWeaponiClientMY_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 );
}
__________________
My Plugins
Modified Plugins:
Building Spawner
Monster
It's Raining Men!
Tutorials:
Custom Gamemode

I DON'T DO PLUGIN REQUESTS.
Bitl is offline
Alurict
Junior Member
Join Date: Feb 2013
Old 02-16-2013 , 06:54   Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
Reply With Quote #12

Just wondering, would there be a simple way to detect which class the user selected and force them to equip items for that class? Perhaps with TF2_GetPlayerClass?

This way the user can still pick their class, but not customize the class loadout.

I'm pretty new at all this stuff, so just curious. Thanks!

Edit: I tried the following code change to no avail:
PHP Code:
    if (TF2_GetPlayerClass(iClient)&TFClass_Scout)
    {
        
TF2Items_GiveWeapon(iClient9990);
        
TF2Items_GiveWeapon(iClient9989);
    } 

Last edited by Alurict; 02-16-2013 at 07:24.
Alurict is offline
Alurict
Junior Member
Join Date: Feb 2013
Old 02-16-2013 , 07:29   Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
Reply With Quote #13

Scratch that, I figured it out. New to all this code so I'm guessing around at syntax haha.

PHP Code:
    if (TF2_GetPlayerClass(iClient) == TFClass_Scout)
    {
        
TF2Items_GiveWeapon(iClient9990);
        
TF2Items_GiveWeapon(iClient9989);
    } 
Then, you'd just have to include a statement for every class with the items you want it them to use and it works wonders.

Thanks for the helpful post! =]

Last edited by Alurict; 02-16-2013 at 08:24.
Alurict is offline
Riotline
AlliedModders Donor
Join Date: Oct 2015
Location: Half Life 3
Old 05-14-2017 , 06:43   Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
Reply With Quote #14

how can i make default fists work with any class with the heavy POV
__________________
Riotline is offline
Firewolf24
Junior Member
Join Date: Apr 2017
Location: IKEA
Old 05-16-2017 , 04:52   Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
Reply With Quote #15

Interesting tutorial, learned quite some things from this, such as how to properly use the tf2 custom weapons plugin with sourcepawn

Last edited by Firewolf24; 05-16-2017 at 04:56.
Firewolf24 is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 05-17-2017 , 03:00   Re: [TF2 + TF2Items + TF2Items GiveWeapon] How to make a custom gamemode
Reply With Quote #16

This is a pretty basic way of doing things, but it works and I can't argue with that.

Side note: Requirement of the Give Weapon plugin can be phased out entirely and the custom weapon generation can be handled right in the plugin. The TF2Items extension would still be required of course. I'd rather handle it directly in the plugin itself as opposed to relying on using another plugin unless absolutely necessary.

Last edited by 404UserNotFound; 05-17-2017 at 03:03.
404UserNotFound is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode