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

A mixed programming question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
keyboard1333
Senior Member
Join Date: Aug 2013
Old 12-01-2013 , 03:46   A mixed programming question
Reply With Quote #1

G'Day all!

First Question:
This code works, but is there a more efficient way? And also there's a small bug. While the user changes weapons their speed changes as well.

PHP Code:
public OnGameFrame()
{
    for(new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
SetEntPropFloat(iProp_Send"m_flMaxspeed"256.0); //Make all classes the same speed
        
}
    }

Second Question:
I currently use the below code to stop engineers building, but I would prefer it if I just removed their PDA and DESTROYTHINGO completely. How would I do this? (I've been searching for most of the day; I can't find it )

PHP Code:
public Action:CommandListener_Build(client, const String:command[], argc)
{
    return 
Plugin_Handled;

Third Question:
I use the below code to prevent ammunition from being dropped when a player dies. Is it possible to change this to only prevent it based on a condition related to the player dying? (e.g. their team, their class, etc.)

PHP Code:
public OnEntityCreated(entity, const String:classname[]) {
    if(
IsValidEntity(entity)) {
        if(
StrContains(classname"tf_ammo_pack"false) != -1) {
            
AcceptEntityInput(entity"Kill"); //Prevent ammo drops
        
}
    }

Thankyou all very much!
keyboard1333 is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 12-01-2013 , 04:14   Re: A mixed programming question
Reply With Quote #2

1 - not a bug. Different weapons have different impact on max running speed. You will have to force it either on gameframe or hook weapon switching event.
3 - You will probably have to hook player death event and get the coordinates and other stuff from it. Kinda unreliable, but i never touched tf2, so there might be a better solution.
xf117 is offline
Send a message via ICQ to xf117
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 12-01-2013 , 07:46   Re: A mixed programming question
Reply With Quote #3

1. You could maybe use TF2Attributes with a move speed attribute + TF2_AddCondition(i, TFCond_SpeedBuffAlly, 0.01); and set it to something based on the user's m_flMaxspeed that they already have...and then maybe still force it on game frame? If you did that, it would work properly most of the time, and still be really close to the desired move speed when they spam weapon switch.

2. TF2_RemoveWeaponSlot on slots 3 and 4. Don't remove that command listener, though, as they might still be able to build if they don't have it by manually using the build command. Not sure.

3. Check m_hOwnerEntity on each tf_ammo_pack, and see if one matches the client. You're going to have to do this after a 0.0-second timer, though (on the next frame).
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 12-01-2013 at 07:46.
MasterOfTheXP is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-01-2013 , 08:32   Re: A mixed programming question
Reply With Quote #4

Quote:
Originally Posted by MasterOfTheXP View Post
[...]3. Check m_hOwnerEntity on each tf_ammo_pack, and see if one matches the client. You're going to have to do this after a 0.0-second timer, though (on the next frame).
Meh, there is a spawn-output for that.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-02-2013 , 21:45   Re: A mixed programming question
Reply With Quote #5

Quote:
Originally Posted by MasterOfTheXP View Post
2. TF2_RemoveWeaponSlot on slots 3 and 4. Don't remove that command listener, though, as they might still be able to build if they don't have it by manually using the build command. Not sure.
I would suggest removing slot 5 instead (the actual tf_weapon_builder), but I seem to recall that crashes the server...
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-02-2013 at 21:46.
Powerlord is offline
keyboard1333
Senior Member
Join Date: Aug 2013
Old 12-03-2013 , 19:38   Re: A mixed programming question
Reply With Quote #6

Quote:
Originally Posted by MasterOfTheXP View Post
1. You could maybe use TF2Attributes with a move speed attribute + TF2_AddCondition(i, TFCond_SpeedBuffAlly, 0.01); and set it to something based on the user's m_flMaxspeed that they already have...and then maybe still force it on game frame? If you did that, it would work properly most of the time, and still be really close to the desired move speed when they spam weapon switch.
Is there any way to do this without using TF2Attributes?

Quote:
Originally Posted by MasterOfTheXP View Post
2. TF2_RemoveWeaponSlot on slots 3 and 4. Don't remove that command listener, though, as they might still be able to build if they don't have it by manually using the build command. Not sure.
Worked like a charm! Thanks!

Quote:
Originally Posted by MasterOfTheXP View Post
3. Check m_hOwnerEntity on each tf_ammo_pack, and see if one matches the client. You're going to have to do this after a 0.0-second timer, though (on the next frame).
Quote:
Originally Posted by Dr. Greg House View Post
Meh, there is a spawn-output for that.
Sorry, but I have no idea what a "spawn-output" is.
keyboard1333 is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-04-2013 , 02:33   Re: A mixed programming question
Reply With Quote #7

http://docs.sourcemod.net/api/index....=show&id=1025&
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 12-04-2013 , 07:35   Re: A mixed programming question
Reply With Quote #8

You can still build without a pda if you use the console and type build 0 1 etc. I think it's buggy but you can get a dispenser going most of the time... Unless this changed recently.

You could hook event player buildobject and just kill the entity, or onentitycreated and kill obj_...
A better option, is to use tf2 attributes to make building cost really high, and remove the gunslinger attribute. Then they can never build.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 12-04-2013 at 07:39.
friagram is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 12-04-2013 , 07:36   Re: A mixed programming question
Reply With Quote #9

Or just block the "build" command.
bl4nk is offline
keyboard1333
Senior Member
Join Date: Aug 2013
Old 12-04-2013 , 16:51   Re: A mixed programming question
Reply With Quote #10

Quote:
Originally Posted by friagram View Post
You can still build without a pda if you use the console and type build 0 1 etc. I think it's buggy but you can get a dispenser going most of the time... Unless this changed recently.

You could hook event player buildobject and just kill the entity, or onentitycreated and kill obj_...
A better option, is to use tf2 attributes to make building cost really high, and remove the gunslinger attribute. Then they can never build.
Quote:
Originally Posted by bl4nk View Post
Or just block the "build" command.
Quote:
Originally Posted by MasterOfTheXP View Post
2. TF2_RemoveWeaponSlot on slots 3 and 4. Don't remove that command listener, though, as they might still be able to build if they don't have it by manually using the build command. Not sure.
As MasterOfTheXP suggested, I both removed slots 3 and 4 and left in the command listener on "build" that prevents building. This problem has already been resolved. Can you give me any help with the other two problems anyone?
keyboard1333 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 07:05.


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