Get players medigun TF2
Intro:
Hello, I'm new here :> Recently I started working on plugin for TF2 that logs events. I am completely new to sourcemod. Could use some help. Context: There is an event in TF2 called "player_chargedeployed". It launches as it states when uber charge is deployed. It provides us with two values userid and targetid. Question: I would like to know if one could get type of uber used based on that information. Stock, kritz, quick-fix, vax. My attempt: PHP Code:
Expected output: name of specific medicgun for exampl tf_weapon_vaccinator Outro: If I broke any of your forum standards plz let me know, happy to improve! |
Re: Get players medigun TF2
Welcome Cieniu97! You posted in the correct place for a scripting question.
Here's what I came up with for you. I tested it and it works. Maybe someone more experienced than I can chime in if there is a better way to do it. The stocks at the bottom of the code originated from Chdata. They're very useful: PHP Code:
|
Re: Get players medigun TF2
Thanks! That works excellent. You are awesome.
I just have few fallow up questions while we are on it. Are there some advantages of using this PHP Code:
PHP Code:
And is that a crime over humanity if I simplify the whole thing to this? PHP Code:
Plugin gonna be used in very specific environment. Competitive matches to be precise. And when event happens we know that medic used this, so for example why verify if that was medic who called it? |
Re: Get players medigun TF2
PHP Code:
The reason for vaccinator is that every vaccination provides 1 charge deployed, but after 4 vaccination deploys, a player is awarded 1 point. The LogPlayerEvent requires loghelper.inc include file to compile. |
Re: Get players medigun TF2
Cieniu97, you are correct on all counts. I updated and shared the weapon stocks from Chdata because you may find them useful.
Good luck with your project. It sounds interesting. |
Re: Get players medigun TF2
So far the answers above depend on the item definition index and don't take into account that serve mods (ex. Freak Fortress 2) can change the charge type or a game update could add more weapon skins.
The following example code gets the charge type by reading attributes and it's shorter (depends on nosoop's TF2Attributes): PHP Code:
|
Re: Get players medigun TF2
I ended up using PC Gamer suggestion.
As for heavyisgps answer. The old syntax doesnt seem to work in spEdit compiler. Naydef, your code looks super slick! But I dont understand why it works ;) and using that without knowledge would be risky for me. I still struggle with understanding enums. For example in PC Gamer solution there is switch statment that takes from tf2stocks.inc. Idk why wouldn't I be able to just get the name from that data structure. In other languages its easy. Just tf2weapons[x] would return the name. Do I have to make switch statments for each enum in tf2 hahah? PS: How do I mark it as solved? |
Re: Get players medigun TF2
I'm glad we were able to help, and I'm glad other people added their code. That's how we all get better at coding.
Part of reason for different answers in this thread is that you asked for two different things. In the text of your original post you asked for the type of uber used, which is what Naydef brilliantly provided. You also stated that your expected output was the name of the specific medigun used, which is what I provided. In the end, I also learned something new from this thread so I thank people for sharing. To mark a post as 'solved', as stated by Maxximou5 in a post somewhere: At the beginning of the thread: 1. Click the edit button (top right of post, next to quote) 2. Click on "go advanced" (bottom right of edited post) 3. At the top, under reason for editing, select TITLE you will see "no prefix", select [Solved] |
All times are GMT -4. The time now is 11:55. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.