Raised This Month: $32 Target: $400
 8% 

TF2 Give player unlockable weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NothingButSciFi
New Member
Join Date: Sep 2009
Old 09-28-2009 , 14:51   TF2 Give player unlockable weapon
Reply With Quote #1

Hi, I want to give a player a specific unlockable weapon (eg. the sniper the huntsman).
I do that like this:
Code:
new Handle:giveNamedItem = INVALID_HANDLE;
new Handle:weaponEquip = INVALID_HANDLE;

public OnPluginStart()
{
    StartPrepSDKCall(SDKCall_Player);
    PrepSDKCall_SetFromConf(OffsCfg, SDKConf_Virtual, "WeaponEquip");
    PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
    weaponEquip = EndPrepSDKCall();

    StartPrepSDKCall(SDKCall_Player);
    PrepSDKCall_SetFromConf(OffsCfg, SDKConf_Virtual, "GiveNamedItem");
    PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
    PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Plain);
    giveNamedItem = EndPrepSDKCall();
}

public GiveWeapon(client, String:weapon[])
{
    new weapon = SDKCall(giveNamedItem , client, weapon, 0);
    SDKCall(weaponEquip, client, weapon);
}
The OffsCfg contains the correct offsets.
Now, if I call GiveWeapon(client, "tf_weapon_compound_bow"); to give the client the huntsman the client gets the huntsman and it's fully usable but the model is wrong, in first person it shows the engineers pistol... I don't know how it looks like in 3rd person view since I can't taunt with this weapon.

Somebody knows what I have to do to use the correct model and make it tauntable?
NothingButSciFi is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-28-2009 , 14:56   Re: TF2 Give player unlockable weapon
Reply With Quote #2

The last param for GiveNamedItem is suppose to be an instance of CScriptCreatedItem that tells the server the information needed to properly spawn the weapon. Sadly, we don't really have access to that, so unless you reverse engineer the class and use an extension, I don't think there's a way to do it.
bl4nk is offline
NothingButSciFi
New Member
Join Date: Sep 2009
Old 09-28-2009 , 14:59   Re: TF2 Give player unlockable weapon
Reply With Quote #3

And that will never be part of the core?
NothingButSciFi is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-28-2009 , 15:55   Re: TF2 Give player unlockable weapon
Reply With Quote #4

Quote:
Originally Posted by NothingButSciFi View Post
And that will never be part of the core?
The "core"? No. The SM TF2 extension? Possibly, if someone cares to go to the work of figuring it out and implementing it.
psychonic is offline
EHG
Senior Member
Join Date: May 2009
Location: 127.0.0.1
Old 09-29-2009 , 22:54   Re: TF2 Give player unlockable weapon
Reply With Quote #5

There is a very easy way to do it.
Write a script to check for client buttons.
Or to check if client is using the compound bow.
If the client switches to his primary weapon set the weapon alpha to 0 and use the code from the equipment manager to attach the compound bow model to the client.
And of course if the client switches to another weapon, set alpha to 255 and remove compound bow model.

I will need to make a script with this myself actually, so if you are willing to wait I will have it done in a week or so.

Last edited by EHG; 09-29-2009 at 22:56.
EHG is offline
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 09-30-2009 , 08:50   Re: TF2 Give player unlockable weapon
Reply With Quote #6

You can set the item definition index to the bow's before equipping it to the client. It will appear correctly as the bow but with wrong animations IIRC.
__________________
Dat annoying guy
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
EHG
Senior Member
Join Date: May 2009
Location: 127.0.0.1
Old 09-30-2009 , 10:18   Re: TF2 Give player unlockable weapon
Reply With Quote #7

If my method is used with the sniper the animations should be correct since the equipment manager attaches the joints in the bow to the correct joints on the sniper skeleton.
Thus as the sniper moves so will the bow.

I will test it as soon as I get home.
EHG is offline
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 09-30-2009 , 12:46   Re: TF2 Give player unlockable weapon
Reply With Quote #8

The view model won't be shown correctly, though.
__________________
Dat annoying guy
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
EHG
Senior Member
Join Date: May 2009
Location: 127.0.0.1
Old 09-30-2009 , 16:37   Re: TF2 Give player unlockable weapon
Reply With Quote #9

What if our two methods are combined?
Mine to fix world model animations and yours to fix client view model
EHG 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 16:15.


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