AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [REQ-TF2] Give/Equip player flare gun (https://forums.alliedmods.net/showthread.php?t=232945)

Avaray 01-07-2014 04:43

[REQ-TF2] Give/Equip player flare gun
 
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.

napalm00 01-07-2014 05:12

Re: [REQ-TF2] Give/Equip player flare gun
 
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 :o

Avaray 01-07-2014 06:12

Re: [REQ-TF2] Give/Equip player flare gun
 
Isn't only Hat's thing? Randomizer servers working still.

napalm00 01-07-2014 07:22

Re: [REQ-TF2] Give/Equip player flare gun
 
Quote:

Originally Posted by Avaray (Post 2082404)
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.

MasterOfTheXP 01-07-2014 10:06

Re: [REQ-TF2] Give/Equip player flare gun
 
2 Attachment(s)
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.

Avaray 01-09-2014 21:57

Re: [REQ-TF2] Give/Equip player flare gun
 
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 :)

MasterOfTheXP 01-09-2014 22:52

Re: [REQ-TF2] Give/Equip player flare gun
 
2 Attachment(s)
Sorry; here's another version that works. Tested this time around :bacon:
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.

Oshizu 01-10-2014 10:50

Re: [REQ-TF2] Give/Equip player flare gun
 
Quote:

Originally Posted by MasterOfTheXP (Post 2083741)
Sorry; here's another version that works. Tested this time around :bacon:
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 :bacon:

Avaray 01-11-2014 22:41

Re: [REQ-TF2] Give/Equip player flare gun
 
@MasterOfTheXP: Works great! Thanks!


All times are GMT -4. The time now is 13:31.

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