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

[TF2Items] Give Weapon (v3.14159, 11/29/2013)


Post New Thread Reply   
 
Thread Tools Display Modes
Vox Dei
Junior Member
Join Date: Sep 2011
Location: Chattanooga, TN
Old 09-24-2011 , 16:09   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #541

Yeah, I attempted to put a small one together for that.

public Action:HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new TFClassType:class = TF2_GetPlayerClass(client);
if (class == TFClass_Medic)
ServerCommand("sm_givew client 9", client)
}

But as of yet, idk enough to understand how to address the userid stored in client in the servercommand line..
ServerCommand("sm_givew client 9", client)

I am sure i messed up the rest of it to, trying to learn by looking at other peoples source and doing as they do, but as of yet, no luck or moment of clarity.


I actually went to college for Programming Concentration 10 years ago, but I never became a coder, nor remember much. Im studying physics now, and my math skills are competent, so I am attempting to make sense of it all and learn how to code- so far, about as clear as mud.
Vox Dei is offline
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 09-24-2011 , 17:22   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #542

That's quite good.
To use a client index, you actually need to use the client's userid.
Hence, ServerCommand("sm_givew #%d 9", GetClientUserId(client));
However, you can actually call giveweapon's functions from within any of your own plugins. Up at the top where the #include lines are, you add #include <tf2items_giveweapon> (Make sure you grab the .inc file from the first post).

From there, instead of ServerCommand(...) you can do TF2Items_GiveWeapon(client, 9);

Here's a snippet that also checks to make sure you're not giving it to somebody who can't get it.
Code:
#include <tf2items_giveweapon>
//...
public Action:HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
     new client = GetClientOfUserId(GetEventInt(event, "userid"));
     if (client <= 0 || client > MaxClients || !IsClientInGame(client)) return Plugin_Continue;          //checks to see if the client is valid
     if (!IsPlayerAlive(client)) return Plugin_Continue;        //checks to see if the spawn actually spawned the client
     if (TF2_GetPlayerClass(client) == TFClass_Medic)
        TF2Items_GiveWeapon(client, 9);
}
I have a tf2items_weaponreplace plugin, that allows you to do sm_wepreplace index index, so that you could essentially do sm_wepreplace 17 9 (replaces syringe gun with shotgun). I might be releasing that soon, if you want to wait. Otherwise, try out the coding for yourself, see how you do
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.

Last edited by FlaminSarge; 09-26-2011 at 00:58.
FlaminSarge is offline
Vox Dei
Junior Member
Join Date: Sep 2011
Location: Chattanooga, TN
Old 09-24-2011 , 17:35   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #543

lol, swt.. thx for the info..

you're a life saver..

Last edited by Vox Dei; 09-24-2011 at 17:39. Reason: im a tard
Vox Dei is offline
Vox Dei
Junior Member
Join Date: Sep 2011
Location: Chattanooga, TN
Old 09-24-2011 , 18:08   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #544

ouch, tried both ways.. compiled fine, but no result..

lol..

any idea on a relase date?

HTML Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <tf2items_giveweapon>
public Action:HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
     new client = GetClientOfUserId(GetEventInt(event, "userid"));
     if (client <= 0 || client > MaxClients || !IsClientInGame(client)) return Plugin_Continue;         
     if (!IsPlayerAlive(client)) return Plugin_Continue;        
     if (TF2_GetPlayerClass(client) == TFClass_Medic)
        TF2Items_GiveWeapon(client, 13);
}
do i need more than that block for it to work?

If ya think I should just wait, or shutup and figure it out myself, I will.

But I appreciate your help, and you're plugin.

Last edited by Vox Dei; 09-24-2011 at 18:53.
Vox Dei is offline
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 09-24-2011 , 23:35   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #545

HTML Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <tf2items_giveweapon>
public OnPluginStart()
{
     HookEvent("post_inventory_application", HookPlayerSpawn);
}
public Action:HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
     new client = GetClientOfUserId(GetEventInt(event, "userid"));
     if (client <= 0 || client > MaxClients || !IsClientInGame(client)) return Plugin_Continue;         
     if (!IsPlayerAlive(client)) return Plugin_Continue;        
     if (TF2_GetPlayerClass(client) == TFClass_Medic)
        TF2Items_GiveWeapon(client, 13);
}
Should do it. Need to initiate the inventory creation hook in OnPluginStart.
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.
FlaminSarge is offline
Vox Dei
Junior Member
Join Date: Sep 2011
Location: Chattanooga, TN
Old 09-25-2011 , 14:13   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #546

I was wondering if plugin_start was necessary lol... thx.. for now on i'll post questions like these in scripting, this was kinda plugin related so I wasn't sure.

You've been a great help.

Currently, I am randomly looking at plugin source of other coders and particualarly the more simple ones that deal with some of the more vital funcs.. its clearing up a bit, visually.

thx again..
Vox Dei is offline
Vox Dei
Junior Member
Join Date: Sep 2011
Location: Chattanooga, TN
Old 09-25-2011 , 14:57   Re: [TF2Items] Give Weapon (v3.05, 09/11/2011)
Reply With Quote #547

worked like a charm, I am rewriting it to effect multiple classes... if you release that other plugin tho, i will definitely change over =)
Vox Dei is offline
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 09-26-2011 , 00:57   Re: [TF2Items] Give Weapon (v3.06, 09/25/2011)
Reply With Quote #548

Updated, 3.06 on 9/25/2011.
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.
FlaminSarge is offline
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 09-28-2011 , 00:38   Re: [TF2Items] Give Weapon (v3.06, 09/25/2011)
Reply With Quote #549

I'm gonna add a custom Buff Banner to this that has the following rage/buff effect:
You gain rage by being healed (actually gaining health while being healed, specifically).
You use the banner to give minicrits, but anybody under its effect cannot be healed (their health just doesn't go up).

It'll be called the "Pocket Protector".
EDIT: Here's the custom config code. When I update the plugin it'll still be 2129.
Code:
    "2129" //Pocket Protector
    {
        "classname"        "tf_weapon_buff_item"
        "index"        "129"
        "slot"        "1"
        "quality"    "4"
        "level"        "3"
        "attribs"    "116 ; 4"
    }
I hope Valve actually uses the name, whenever they implement it.
__________________
Bread EOTL GunMettle Invasion Jungle Inferno 64-bit will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.

Last edited by FlaminSarge; 09-28-2011 at 08:48.
FlaminSarge is offline
TheSpyHunter
Senior Member
Join Date: Jul 2009
Old 10-06-2011 , 21:01   Re: [TF2Items] Give Weapon (v3.06, 09/25/2011)
Reply With Quote #550

Great plugin BTW - I've added a few of the weapons to shop mod so that players can buy weapons with their kill/ round credits.


One issue:
I've searched through the forum and cannot find a way of fixing the ammo/locker resupply issue.

Is there a fix or something you can reccomend?

Thanks
__________________
TheSpyHunter 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 10:26.


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