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

[L4D2] [REQ] sm_goto executable by ghosts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 05-31-2022 , 20:09   [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #1

Hello guys

I would love to see if there is a way for only ghost infected to execute commands like:
1- sm_goto > ghost infected will be able to go to any player (survivors, SI both ghost and non ghost)
2- sm_bring > which u can bring only ghost infected and can be executed by both ghost and non ghost infected > this command should have delay time once executed like 30 seconds or if "sm_bring XXX" executed, The XXX player will have a panel to accept or refuse the teleportation request


I don't know if that is possible

I would suggest this mainly for two reasons:
I was playing in few "Competitive Versus" with +8 players, and its chaos, sometimes someone wants you to steel a player or helping him/her but you are far away and you don't have a lot of time to search or spectate.

The second reason is, many times specially when there are +8 players, spectating will bugged and only focus on few players not able to spectate rest and even unable to press "E" to check for others as a ghost. This is really common, last game it was 10 v 10, 2 ppl rushed, rest are back, and I only able to spectate those who rushed and went to the saferoom. costing me a lot of time, I had to move as a ghost to reach to back players every time which is really annoying.

I hope I made my point clear

thanks

Last edited by alasfourom; 05-31-2022 at 20:30.
alasfourom is offline
Toranks
Senior Member
Join Date: Dec 2021
Location: Spain
Old 05-31-2022 , 21:10   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #2

I'm sure I saw a plugin that was dedicated to solving just those versus issues when more than 8 players.
It had some demo images. But now I can't find it! Dammit
Another problem that it solved is that it does not count the score properly when some survivors are too far away from the others. And only count the points of the first 4 survivors.
Do a search, and if I happen to find it, I'll put the link here.
Toranks is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-01-2022 , 09:22   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #3

If that would fix this annoying issue, I would be really glad to try it out.

Thanks Toranks
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-02-2022 , 16:46   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #4

Is there a way to make commands executable only by ghosts at least?

If so, please share the way, thanks
alasfourom is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-04-2022 , 21:46   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #5

Just check the netprop:

PHP Code:
bool IsPlayerGhost(int client)
{
    return (
GetEntProp(clientProp_Send"m_isGhost") == 1);

__________________
Marttt is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-05-2022 , 00:25   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #6

Thanks Marttt

I will try, thanks as always ����

Last edited by alasfourom; 06-05-2022 at 04:55.
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-05-2022 , 12:17   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #7

Hey Marttt, I was able to make it work

Thanks a lot

Last edited by alasfourom; 06-05-2022 at 20:20.
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-06-2022 , 02:23   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #8

Here is the script


This will allow only ghost infected to use the "sm_goto" command, which will save you time specially in +4 players versus

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "Ghost Goto Command",
    
author "alasfourom",
    
description "Ghost Infected Can Use Goto Command",
    
version "1.0",
    
url "https://www.sourcemod.net/"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_goto"Command_Goto"Allow Ghost Infected To Use Goto Command");
        
    
LoadTranslations("common.phrases");
}

bool IsPlayerGhost (int client)
{
    return (
GetEntProp(clientProp_Send"m_isGhost") == 1);
}

public 
Action Command_Goto(int clientint args)
{
    
    if (
args == 0)
    {
        
ReplyToCommand(client"\x04[Ghost] \x01Usage: sm_goto \x03<#userid|name>");
        return 
Plugin_Handled;
    }
    
    if (!
IsPlayerGhost(client))
    {
        
ReplyToCommand(client"\x04[Ghost] \x01Only \x03ghost infected \x01can teleport to players.");
        return 
Plugin_Handled;
    }
    
    if (
IsPlayerGhost(client))
    {
        
float fTeleportOrigin[3];
        
float fPlayerOrigin[3];

        
char sArg1[MAX_NAME_LENGTH];
        
GetCmdArg(1sArg1sizeof(sArg1));
        
int destination FindTarget(clientsArg1);
        
        if (!
IsPlayerAlive(destination))
        {
            
ReplyToCommand(client"\x04[Ghost] \x01Player \x03%N \x01is currently dead."destination);
            return 
Plugin_Stop;
        }
        
        
GetClientAbsOrigin(destinationfPlayerOrigin);

        
fTeleportOrigin[0] = fPlayerOrigin[0];
        
fTeleportOrigin[1] = fPlayerOrigin[1];
        
fTeleportOrigin[2] = (fPlayerOrigin[2] + 5);
    
        
TeleportEntity(clientfTeleportOriginNULL_VECTORNULL_VECTOR);
        
ReplyToCommand(client"\x04[Ghost] \x01You have been successfully brought to \x03%N\x01."destination);
        return 
Plugin_Handled;
        
    }
    return 
Plugin_Handled;

You can also remove these lines if you want to be teleported even to the location of the last destination of dead players.

PHP Code:
        if (!IsPlayerAlive(destination))
        {
            
ReplyToCommand(client"\x04[Ghost] \x01Player \x03%N \x01is currently dead."destination);
            return 
Plugin_Stop;
        } 
Attached Files
File Type: sp Get Plugin or Get Source (ghost_goto.sp - 78 views - 1.7 KB)

Last edited by alasfourom; 06-06-2022 at 06:10.
alasfourom is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-06-2022 , 06:08   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #9

can someone tell me why I have this error and how to fix it

PHP Code:
L 06/06/2022 12:07:58: [SMException reportedInvalid client index -1
L 06
/06/2022 12:07:58: [SMBlamingghost_goto.smx
L 06
/06/2022 12:07:58: [SMCall stack trace:
L 06/06/2022 12:07:58: [SM]   [0IsPlayerAlive
L 06
/06/2022 12:07:58: [SM]   [1Line 52, /home/groups/sourcemod/upload_tmp/phpG6TWU8.sp::Command_Goto 
alasfourom is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-06-2022 , 07:29   Re: [L4D2] [REQ] sm_goto executable by ghosts
Reply With Quote #10

You should always check if is a valid client index (between 0~32 L4D2) and if the client is in-game (IsClientInGame) when not sure if it will return a client or while trying to access "client" props values.

Usually, I create a stock with that helpers:

PHP Code:
bool IsValidClient(int client)
{
    return (
<= client && client <= MaxClients && IsClientInGame(client));

According to the docs FindTarget
PHP Code:
Return Value
Index of target client
, or -1 on error
So you should check if FindTarget returned -1, in this case ignore/exit the function.

Also you probably will get "Client not in game" error if you call sm_goto from the server console.
__________________

Last edited by Marttt; 06-06-2022 at 07:33.
Marttt 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 04:05.


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