AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] Set Player's Weapon & Force Fire (https://forums.alliedmods.net/showthread.php?t=132126)

flintb 07-12-2010 07:12

[TF2] Set Player's Weapon & Force Fire
 
I'm making a plugin that allows me to control bots. Right now I'm trying to figure out how to force a bot to change to a specific weapon. I'm also trying to figure out how to force him to shoot. I've been searching through the wiki, forums, existing plugins, and other sites and I can't find anything that would work (for TF2 at least). Any suggestions would be greatly appreciated!

noodleboy347 07-13-2010 13:34

Re: [TF2] Set Player's Weapon & Force Fire
 
bot_forceattack 1

bot_selectweaponslot <0-2> use to work before the Engi Update, I don't think it does anymore though.

flintb 07-15-2010 04:04

Re: [TF2] Set Player's Weapon & Force Fire
 
Thanks for the idea, but this isn't what I was looking for. I want to control bots individually and bot_forceattack forces all the bots to shoot. Also, these commands require sv_cheats 1 and I'd like cheats to be off so plays can receive achievements. Is there a way to do this at the plugin level such as FireEvent()?

DarkEnergy 07-15-2010 12:10

Re: [TF2] Set Player's Weapon & Force Fire
 
Quote:

Originally Posted by flintb (Post 1239815)
Thanks for the idea, but this isn't what I was looking for. I want to control bots individually and bot_forceattack forces all the bots to shoot. Also, these commands require sv_cheats 1 and I'd like cheats to be off so plays can receive achievements. Is there a way to do this at the plugin level such as FireEvent()?

srs? get a friend and an achievement server

flintb 07-17-2010 03:12

Re: [TF2] Set Player's Weapon & Force Fire
 
Wow... these forums are extremely useless... Or at the very least the last two posts are useless. I'm not trying to get my own achievements. If that was my goal, I wouldn't be posting in a forum that is for people developing SM plugins for servers... I'm trying to make my own achievement server and I plan on having features that I haven't found in any other server (or in some cases only 1 or 2 servers, but still). If I wanted help playing TF2 I'd post in the Steam forums. If I wanted to understand server commands I'd Google it. I'm trying to get help with sm plugin functions. Now that I've (hopefully) made that clear, can anyone help me achieve what I'm ACTUALLY trying to do?

Peoples Army 07-17-2010 03:37

Re: [TF2] Set Player's Weapon & Force Fire
 
you can try to create your own NPC and control him like that

flintb 07-17-2010 04:11

Re: [TF2] Set Player's Weapon & Force Fire
 
Let me clarify my last statement. I no way to I want to insult anyone who help me. I'm simply getting angry because I don't think I've really received any actual help yet. I just want to make some quality plugins and I ask for help with the code any everyone starts giving me ideas that have anything to do with writing code. That's where I'm coming from.

Greyscale 07-17-2010 05:21

Re: [TF2] Set Player's Weapon & Force Fire
 
I understand your frustration flintb.

Now hopefully I can help you out.

Look in sdktools_functions.inc and find EquipPlayerWeapon(client, weapon); I think that should help you force a bot to use a weapon. You can combine that with SDKHooks' WeaponEquip hook to prevent them from switching away to the weapon you want them to use.

As for forcing them to attack you can try this, but I don't know if it works:

Code:

new flags = GetEntityFlags(client);
if (!(flags & IN_ATTACK))  // if you know bitwise operators better than me then you can do it the right way.  i think its (flags ~& IN_ATTACK)
{
    SetEntProp(client, Prop_Data, "m_fFlags", flags|IN_ATTACK);
}

I don't know if flags were meant to be set like that, but it's worth a try. You might have to repeat this every game frame. (public OnGameFrame)

flintb 07-17-2010 05:31

Re: [TF2] Set Player's Weapon & Force Fire
 
Thank you for the help! That's what I was looking for. I looked into EquipPlayerWeapon some but I only found how to equip CSS weapons. Do you know where I might be able to find a TF2 weapon index list? I haven't found one yet. I guess I can also do trial and error if worst comes to worst (although that might take a while). Also, the weapon flag description says "CBaseCombatWeapon entity index.". What exectly does "CBase" in "CBaseCombatWeapon" mean (if anything)?

Greyscale 07-17-2010 05:38

Re: [TF2] Set Player's Weapon & Force Fire
 
Code:

GetPlayerWeaponSlot(client, slot);
0 is primary, 1 secondary and so on. This will return the weapon entity index in the client's loadout.

Also, by your wording it seems you think that each weapon as an assigned index. Each weapon in game has a unique entity index. So there can be 10 eyelanders in use in the game, each with their own index. The function above will return that index for you.

"CBase" means it exists for all source games. It's a classname in the engine's source code. There are game-specific classes as well such as CCS and CTF, which is CS:S and TF2 specific, respectively.


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

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