Raised This Month: $ Target: $400
 0% 

The Machina Block


Post New Thread Reply   
 
Thread Tools Display Modes
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-15-2013 , 14:31   Re: The Machina Block
Reply With Quote #11

Quote:
Originally Posted by SmackDaddy View Post
Anyone have any instruction on how to do this? (using tf2items to replace one weapon for another) Thanks in advance.
Something like
PHP Code:
public Action:TF2Items_OnGiveNamedItem(clientString:classname[], iItemDefinitionIndex, &Handle:hItem)
{
    
// This section is to prevent Handle leaks
    
static Handle:item INVALID_HANDLE;
    if (
item != INVALID_HANDLE)
    {
        
CloseHandle(item);
        
item INVALID_HANDLE;
    }

    
// Machina is item 526    
    
if (iItemDefinitionIndex == 526)
    {
        
item TF2Items_CreateItem(OVERRIDE_ITEM_DEF|OVERRIDE_ITEM_LEVEL|OVERRIDE_ITEM_QUALITY|OVERRIDE_ATTRIBUTES);
        
// Sniper rifle is index 14
        
TF2Items_SetItemIndex(item14);
        
TF2Items_SetQuality(item0);
        
TF2Items_SetLevel(item1);
        
TF2Items_SetNumAttributes(item0);
        
hItem item;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;

Note that this only works for items with the same classname. Attempting to change the classname will cause the game to remove said item and leave the player with nothing in that slot.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 11-15-2013 at 14:32.
Powerlord is offline
DarthNinja
SourceMod Plugin Approver
Join Date: Mar 2009
Location: PreThinkHook()
Old 11-15-2013 , 18:10   Re: The Machina Block
Reply With Quote #12

https://forums.alliedmods.net/showthread.php?p=838018

Or better yet you could just alter the attributes for the Machina and make it acceptable to your preferences.
__________________

Last edited by DarthNinja; 11-15-2013 at 18:10.
DarthNinja is offline
SmackDaddy
Veteran Member
Join Date: Oct 2009
Old 11-15-2013 , 19:29   Re: The Machina Block
Reply With Quote #13

Quote:
Originally Posted by Powerlord View Post
Something like
PHP Code:
    // Machina is item 526    
    
if (iItemDefinitionIndex == 526)
    {
        
item TF2Items_CreateItem(OVERRIDE_ITEM_DEF|OVERRIDE_ITEM_LEVEL|OVERRIDE_ITEM_QUALITY|OVERRIDE_ATTRIBUTES);
        
// Sniper rifle is index 14
        
TF2Items_SetItemIndex(item14);
        
TF2Items_SetQuality(item0);
        
TF2Items_SetLevel(item1);
        
TF2Items_SetNumAttributes(item0);
        
hItem item;
        return 
Plugin_Changed;
    } 
Powerlord, cool, thanks....now, my question isn't on a Machina but a guillotine (tf_weapon_cleaver) -- where the Guillotine has a seperate weapon index for the normal guillotine and one for the genuine guillotine....how would the above code be modified for to remove either of those (2 of them) - I don't care whether it gets replaced or not (since there is no other tf_weapon_cleaver to use to replace it), just want to have ONE plugin instead of two (for each guillotine type)....
SmackDaddy is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-15-2013 , 21:47   Re: The Machina Block
Reply With Quote #14

Quote:
Originally Posted by SmackDaddy View Post
...how would the above code be modified for to remove either of those (2 of them)
PHP Code:
// Valve at their best
if (iItemDefinitionIndex == 812 || iItemDefinitionIndex == 833
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
SmackDaddy
Veteran Member
Join Date: Oct 2009
Old 01-11-2014 , 15:46   Re: The Machina Block
Reply With Quote #15

Master of the XP, thanks for your reply (sorry for the delay - apparently I missed it when you replied)

1. Can this be modified to block multiple weapons instead of making a plugin for each specific weapon? I have modified this plugin twice (two different instance of it for two different weapons) and I am worried it's causing some lag on the server (since doing this, people are reporting increased lag and this was the only change/addition I made).....thank you in advance.


2. In the original plugin (machinablock.sp) -- the index is defined as:

"#define WEP_DEX_Rifle 526"

How could that plugin be modifed to also include an additional index (i.e. genuine)?


3. What is the tfclass_xxxxx name for Demo man? I was trying to modify this plugin for a demo weapon -- and tried Demo, Demoman, Demomen (upper and lower case -- and in compiling, I get an error stating: error 017: undefined symbol "TFClass_Demoman" (regardless of which name I try)

Thanks in advance.

Last edited by SmackDaddy; 01-11-2014 at 20:37.
SmackDaddy is offline
SmackDaddy
Veteran Member
Join Date: Oct 2009
Old 01-11-2014 , 16:12   Re: The Machina Block
Reply With Quote #16

Quote:
Originally Posted by Powerlord View Post
Something like
PHP Code:
public Action:TF2Items_OnGiveNamedItem(clientString:classname[], iItemDefinitionIndex, &Handle:hItem)
{
    
// This section is to prevent Handle leaks
    
static Handle:item INVALID_HANDLE;
    if (
item != INVALID_HANDLE)
    {
        
CloseHandle(item);
        
item INVALID_HANDLE;
    }

    
// Machina is item 526    
    
if (iItemDefinitionIndex == 526)
    {
        
item TF2Items_CreateItem(OVERRIDE_ITEM_DEF|OVERRIDE_ITEM_LEVEL|OVERRIDE_ITEM_QUALITY|OVERRIDE_ATTRIBUTES);
        
// Sniper rifle is index 14
        
TF2Items_SetItemIndex(item14);
        
TF2Items_SetQuality(item0);
        
TF2Items_SetLevel(item1);
        
TF2Items_SetNumAttributes(item0);
        
hItem item;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;

Note that this only works for items with the same classname. Attempting to change the classname will cause the game to remove said item and leave the player with nothing in that slot.

Also, I should have asked this before, but would this be made into it's own .sp file and then compiled (with tf2items)?
SmackDaddy 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 13:07.


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