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

L4D2 Change warp_far_survivor_here to work only on bots?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 07-25-2014 , 16:09   L4D2 Change warp_far_survivor_here to work only on bots?
Reply With Quote #1

L4D2
I would like to change the functionality of this command so that
it only warps bots not humans.

warp_far_survivor_here

Right now the command warps whoever is the farthest away human or bot.

I would like it to only warp the bot that is the farthest away
ignoring all humans players.

I am good at sourcemod plugins but don't know how to start on this plugin.
Austin is offline
Austin
Senior Member
Join Date: Oct 2005
Old 04-24-2015 , 23:01   Re: L4D2 Change warp_far_survivor_here to work only on bots?
Reply With Quote #2

Austin,
this is simple.
Just make a new command.

[code]
public Action:Command_WarpBots(client, args)
{
if(!client)
{
PrintToServer("[SM] Unable to execute this command from the server console!");
return Plugin_Handled;
}

GetClientAbsOrigin(client, VecOrigin);
for (new i = 1; i <= MAXPLAYERS + 1; i++)
{
if (IsClientInGame(i) && IsFakeClient(i) && GetClientTeam(i) == TEAM_SURVIVOR)
{
TeleportEntity(i, VecOrigin, NULL_VECTOR, NULL_VECTOR);
}
}
return Plugin_Handled;
}
[\code]
Austin is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 04-25-2015 , 00:06   Re: L4D2 Change warp_far_survivor_here to work only on bots?
Reply With Quote #3

...Did you just answer your own question?

Try this. I don't know what TEAM_SURVIVOR is though so be sure to define it.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

#define TEAM_SURVIVOR 2 //DeathChaos25


public OnPluginStart() {
    
RegAdminCmd("sm_warpbots"Command_warpBotsADMFLAG_SLAY);
}

public 
Action Command_warpBots(int clientint args) {
    if (!
client) {
        
PrintToServer("[SM] Unable to execute this command from the server console!");
        return 
Plugin_Handled;
    }
    
float clientPos[3];
    
GetEntPropVector(clientProp_Data"m_vecOrigin"clientPos);
    
int farthestBotIndex getFarthestBot(client);
    if (
farthestBotIndex 1) {
        
ReplyToCommand(client"[SM] Could not find a bot to teleport.");
        return 
Plugin_Handled;
    }
    
TeleportEntity(farthestBotIndexclientPosNULL_VECTORNULL_VECTOR);
    
ReplyToCommand(client"[SM] Teleported %N to you."farthestBotIndex);
    return 
Plugin_Handled;
}

int getFarthestBot(client) {
    
int farthestBotIndex = -1;
    
float maxDist;
    
float otherPos[3], clientPos[3];
    
GetEntPropVector(clientProp_Data"m_vecOrigin"clientPos);
    for (
int i 1<= MaxClientsi++) {
        if (!
IsClientInGame(i)) continue;
        if (!
IsPlayerAlive(i)) continue;
        if (!
IsFakeClient(i)) continue;
        if (
GetClientTeam(i) != TEAM_SURVIVOR) continue;
        
GetEntPropVector(iProp_Data"m_vecOrigin"otherPos);
        if (
GetVectorDistance(clientPosotherPosfalse) > maxDist) {
            
maxDist GetVectorDistance(clientPosotherPosfalse);
            
farthestBotIndex i;
        }
    }
    return 
farthestBotIndex;


Last edited by Darkness_; 05-30-2015 at 18:16.
Darkness_ is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 04-25-2015 , 17:21   Re: L4D2 Change warp_far_survivor_here to work only on bots?
Reply With Quote #4

Team Survivors is team #2, so it'd be,
PHP Code:
#define TEAM_SURVIVOR 2 
__________________
DeathChaos25 is offline
Austinbots
Member
Join Date: Jan 2010
Old 05-30-2015 , 17:43   Re: L4D2 Change warp_far_survivor_here to work only on bots?
Reply With Quote #5

Quote:
Originally Posted by Darkness_ View Post
...Did you just answer your own question?
It was taking a while to get an answer!, but i kept trying to figure this out and came up
with a plugin on my own that just warps all bots right to where I am,
which actually worked out better.

Thanks for the example code.
I will file it away for possible later use.

Last edited by Austinbots; 05-30-2015 at 17:44.
Austinbots 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 03:02.


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