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

[REQ-TF2] Give/Equip player flare gun


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Avaray
Member
Join Date: Dec 2011
Location: Germany
Old 01-07-2014 , 04:43   [REQ-TF2] Give/Equip player flare gun
Reply With Quote #1

Im making pyro-paintball map.
One problem that I cant solve in map editor is giving weapons - thats impossible to do.
Not every player have Flare Gun in his inventory (because its Unlockable weapon).
Can anyone write simple plugin for me? My scripting skills are too low to write this plugin.

I dont know how it works with tf2items extension, but I want something like this:

When player is spawning:
- plugin is giving (equpping) him TF_Weapon_FlareGun
- plugin is changing players weapon model (if needed)
- plugin is changing players weapon viewmodel (if needed)

No need any CVAR's.
__________________

Last edited by Avaray; 01-07-2014 at 04:48.
Avaray is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 01-07-2014 , 05:12   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #2

It won't be visible unless they own it unfortunately. I think asherkin mentioned that changing weapons was broken after Valve introduced the system that merges CEconItemViews... I've yet to understand if that's serverside or clientside
__________________
napalm00 is offline
Avaray
Member
Join Date: Dec 2011
Location: Germany
Old 01-07-2014 , 06:12   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #3

Isn't only Hat's thing? Randomizer servers working still.
__________________

Last edited by Avaray; 01-07-2014 at 06:31.
Avaray is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 01-07-2014 , 07:22   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #4

Quote:
Originally Posted by Avaray View Post
Isn't only Hat's thing? Randomizer servers working still.
It's not only for hats and regarding Randomizer, I think it still applies to the "player owns it" rule: you'll see a weapon only if the player has it in their backpack.
I might be completely wrong though, I myself haven't yet realized why TF2Items can't spawn weapons anymore.
__________________
napalm00 is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 01-07-2014 , 10:06   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #5

Lazy version. Requires TF2Items and Give Weapon.
lern 2 test before posting code n00b
You can do this pretty easily without Give Weapon (heck, without TF2Items even) but I'm just keeping it simple and will probably accidentally break it otherwise.
Attached Files
File Type: smx flareguns.smx (3.2 KB, 204 views)
File Type: sp Get Plugin or Get Source (flareguns.sp - 102 views - 483 Bytes)
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 01-09-2014 at 22:53.
MasterOfTheXP is offline
Avaray
Member
Join Date: Dec 2011
Location: Germany
Old 01-09-2014 , 21:57   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #6

Unfortunately your plugin doesn't work for me. Player is not obtaining weapon.
But nevermind, You gave me another idea! The Map is executing commands from "Give Weapon" plugin and I dont need plugin to force weapon
Big thanks
__________________
Avaray is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 01-09-2014 , 22:52   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #7

Sorry; here's another version that works. Tested this time around
PHP Code:
#include <tf2_stocks>
#include <tf2items>
#include <tf2items_giveweapon>

public TF2Items_OnGiveNamedItem_Post(clientString:classname[], itemDefinitionIndexitemLevelitemQualityentityIndex)
{
    if (
StrEqual(classname"tf_weapon_flaregun"false) || StrEqual(classname"tf_weapon_flaregun_revenge"false))
        return; 
// It's a flare gun already
    
new Handle:data;
    
CreateDataTimer(0.0Timer_CheckFlareGundataTIMER_FLAG_NO_MAPCHANGE);
    
WritePackCell(dataGetClientUserId(client));
    
WritePackCell(dataEntIndexToEntRef(entityIndex));
    
ResetPack(data);
}

public 
Action:Timer_CheckFlareGun(Handle:timerHandle:data)
{
    new 
client GetClientOfUserId(ReadPackCell(data));
    if (!
client) return;
    new 
entityIndex EntRefToEntIndex(ReadPackCell(data));
    if (
entityIndex <= MaxClients) return;
    
    if (
entityIndex != GetPlayerWeaponSlot(client1)) return;
    
TF2Items_GiveWeapon(client39);

You could just do point_servercommand, but then you'd be overriding players' own Flare Guns, and ensuring that they'd be invisible 100% of the time.
Attached Files
File Type: smx flareguns.smx (3.8 KB, 196 views)
File Type: sp Get Plugin or Get Source (flareguns.sp - 216 views - 922 Bytes)
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 01-09-2014 at 22:53.
MasterOfTheXP is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-10-2014 , 10:50   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #8

Quote:
Originally Posted by MasterOfTheXP View Post
Sorry; here's another version that works. Tested this time around
PHP Code:
#include <tf2_stocks>
#include <tf2items>
#include <tf2items_giveweapon>

public TF2Items_OnGiveNamedItem_Post(clientString:classname[], itemDefinitionIndexitemLevelitemQualityentityIndex)
{
    if (
StrEqual(classname"tf_weapon_flaregun"false) || StrEqual(classname"tf_weapon_flaregun_revenge"false))
        return; 
// It's a flare gun already
    
new Handle:data;
    
CreateDataTimer(0.0Timer_CheckFlareGundataTIMER_FLAG_NO_MAPCHANGE);
    
WritePackCell(dataGetClientUserId(client));
    
WritePackCell(dataEntIndexToEntRef(entityIndex));
    
ResetPack(data);
}

public 
Action:Timer_CheckFlareGun(Handle:timerHandle:data)
{
    new 
client GetClientOfUserId(ReadPackCell(data));
    if (!
client) return;
    new 
entityIndex EntRefToEntIndex(ReadPackCell(data));
    if (
entityIndex <= MaxClients) return;
    
    if (
entityIndex != GetPlayerWeaponSlot(client1)) return;
    
TF2Items_GiveWeapon(client39);

You could just do point_servercommand, but then you'd be overriding players' own Flare Guns, and ensuring that they'd be invisible 100% of the time.
Unless he uses Attachables
__________________
...
Oshizu is offline
Avaray
Member
Join Date: Dec 2011
Location: Germany
Old 01-11-2014 , 22:41   Re: [REQ-TF2] Give/Equip player flare gun
Reply With Quote #9

@MasterOfTheXP: Works great! Thanks!
__________________
Avaray 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:47.


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