AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Error detected in plugin startup (https://forums.alliedmods.net/showthread.php?t=334336)

Diggingwolf2605 09-16-2021 10:54

Error detected in plugin startup
 
I am having an issue with this plugin and i can't seem to figure out what is causing such errors.


L 09/15/2021 - 12:32:25: [SM] Exception reported: Invalid message id supplied (-1)
L 09/15/2021 - 12:32:25: [SM] Blaming: L4D2FFKickProtection.smx
L 09/15/2021 - 12:32:25: [SM] Call stack trace:
L 09/15/2021 - 12:32:25: [SM] [0] HookUserMessage
L 09/15/2021 - 12:32:25: [SM] [1] Line 34, D:\plugins\L4DFFKickProtect\L4D2FFKickProtect ion.sp::OnPluginStart
L 09/15/2021 - 12:32:25: [SM] Unable to load plugin "L4D2FFKickProtection.smx": Error detected in plugin startup (see error logs)
L 09/15/2021 - 12:33:14: Error log file session closed.

PHP Code:

#pragma semicolon 1
#pragma newdecls required


#define PLUGIN_NAME "L4D2 FF Kick Protection"
#define PLUGIN_DESCRIPTION "Prevents assholes from friendly firing when being kicked."
#define PLUGIN_AUTHOR "jackzmc"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_URL ""

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

static int disableFFClient//client to disable FF for
static float  ffDamageDone//amount of damage offending user has attempted
static ConVar forceKickFFThreshold;

public 
Plugin myinfo = {
    
name PLUGIN_NAME
    
author PLUGIN_AUTHOR
    
description PLUGIN_DESCRIPTION
    
version PLUGIN_VERSION
    
url PLUGIN_URL
};

public 
void OnPluginStart() {
    
EngineVersion g_Game GetEngineVersion();
    if(
g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
    {
        
SetFailState("This plugin is for L4D/L4D2 only.");    
    }
    
AddCommandListener(VoteStart"callvote");
    
HookUserMessage(GetUserMessageId("VotePass"), VotePassFail);
    
HookUserMessage(GetUserMessageId("VoteFail"), VotePassFail);

    
forceKickFFThreshold CreateConVar("sm_votekick_force_threshold","0","The threshold of damage where the offending player is just immediately kicked. 0 -> Any attempted damage, -1 -> No auto kick."FCVAR_NONEtrue, -1.0);

    
//HookEvent("vote_started",Event_VoteStarted);
}

public 
void OnClientPutInServer(int client) {
    
int team GetClientTeam(client);
    if(
team == 2) {
        
SDKHook(clientSDKHook_OnTakeDamageAliveOnTakeDamage);
    }
}

public 
void Event_PlayerTeam(Event event, const char[] namebool dontBroadcast) {
    if(!
event.GetBool("disconnect")) {
        
int team event.GetInt("team");
        
int userid GetClientOfUserId(event.GetInt("userid"));
        if(
team == 2) {
            
SDKHook(useridSDKHook_OnTakeDamageAliveOnTakeDamage);
            
//add new hook
        
}else{
            
SDKUnhook(useridSDKHook_OnTakeDamageAliveOnTakeDamage);
        }
    }
}

public 
Action VoteStart(int client, const char[] commandint argc) {
    if(
GetClientCount(true) == || client == 0) return Plugin_Handled//prevent votes while server is empty or if server tries calling vote
    
if(argc >= 1) {
        
char issue[32];
        
char caller[32];

        
GetCmdArg(1issuesizeof(issue));
        
Format(callersizeof(caller), "%N"client);

        if(
StrEqual(issue"Kick"true)) {
            
char option[32];
            
GetCmdArg(2optionsizeof(option));
            if(
strlen(option) < 1) { //empty userid/console can't call votes
                
int target GetClientOfUserId(StringToInt(option));
                
int team GetClientTeam(target);
                if(
team == 2) {
                    
disableFFClient target;
                    
ffDamageDone = -1.0;
                }
                return 
Plugin_Handled;
            }    
            
//Kick vote started
            
PrintToServer("KICK VOTE STARTED | Issue=%s Option=%s Caller=%N"issueoptionclient);
        }
    }    
    return 
Plugin_Handled//if it wasn't handled up there I would start panicking
}

public 
Action VotePassFail(UserMsg msg_idBfRead msg, const int[] playersint playersNumbool reliablebool init) {
    
disableFFClient = -1;
    
ffDamageDone = -1.0;
}    

public 
Action OnTakeDamage(int victim,  intattackerintinflictorfloatdamageintdamagetypeintweaponfloat damageForce[3], float damagePosition[3]) {
    if(
disableFFClient == attacker) {
        if(
ffDamageDone == -1) {
            
PrintToServer("Player in vote to be kicked has done ff damage");
        }
        
ffDamageDone damage;
        if(
forceKickFFThreshold.FloatValue > -1.0) {
            
//auto kick
            
if(forceKickFFThreshold.FloatValue == 0.0) {
                
KickClient(disableFFClient"Kicked for excessive friendly fire");
            }else if(
FloatCompare(ffDamageDoneforceKickFFThreshold.FloatValue) == 1) {
                
KickClient(disableFFClient"Kicked for excessive friendly fire");
            }
        }
        
damage 0.0;
        return 
Plugin_Handled;
    } 
    return 
Plugin_Continue;



Marttt 09-16-2021 11:21

Re: Error detected in plugin startup
 
seems okay, maybe was too soon to get the message id
did some search in the forum and people always do like that
this always happen or was it a specific scenario?

Diggingwolf2605 09-16-2021 11:39

Re: Error detected in plugin startup
 
This seems to happen upon server startup, plugin refuses to load at all and by looking in plugins list it gives me the following errors:

15 <Error> "L4D2 FF Kick Protection" (1.0) by jackzmc

Errors:
L4D2FFKickProtection.smx (L4D2 FF Kick Protection): Error detected in plugin startup (see error logs)

Bacardi 09-17-2021 04:58

Re: Error detected in plugin startup
 
In server console, try command: meta game
Code:

meta game
GameDLL Information
  Description: Counter-Strike: Source
  Mod Path: G:\server\counter-strike source\cstrike
  DLL Path: g:\server\counter-strike source\cstrike\bin\server.dll
  Interface: ServerGameDLL010
  Engine: Counter-Strike: Source (Valve Orange Box)
  User Messages:  Name                              Index  Size
                  Geiger                            0      1
                  Train                            1      1
                  HudText                          2      -1
                  SayText                          3      -1
                  SayText2                          4      -1
                  TextMsg                          5      -1
                  HudMsg                            6      -1
                  ResetHUD                          7      1
                  GameTitle                        8      0
                  ItemPickup                        9      -1
                  ShowMenu                          10    -1
                  Shake                            11    13
                  Fade                              12    10
                  VGUIMenu                          13    -1
                  Rumble                            14    3
                  CloseCaption                      15    -1
                  SendAudio                        16    -1
                  RawAudio                          17    -1
                  VoiceMask                        18    25
                  RequestState                      19    0
                  BarTime                          20    -1
                  Damage                            21    -1
                  RadioText                        22    -1
                  HintText                          23    -1
                  KeyHintText                      24    -1
                  ReloadEffect                      25    2
                  PlayerAnimEvent                  26    -1
                  AmmoDenied                        27    2
                  UpdateRadar                      28    -1
                  KillCam                          29    -1
                  MarkAchievement                  30    -1
                  CallVoteFailed                    31    -1
                  VoteStart                        32    -1
                  VotePass                          33    -1
                  VoteFailed                        34    2
                  VoteSetup                        35    -1
                  SPHapWeapEvent                    36    4
                  HapDmg                            37    -1
                  HapPunch                          38    -1
                  HapSetDrag                        39    -1
                  HapSetConst                      40    -1
                  HapMeleeContact                  41    0
                  PlayerStatsUpdate_DEPRECATED      42    -1
                  AchievementEvent                  43    -1
                  MatchEndConditions                44    -1
                  MatchStatsUpdate                  45    -1
                  PlayerStatsUpdate                46    -1
  47 user messages in total


You could expand your code to check error.
Code:

public void OnPluginStart() {
    EngineVersion g_Game = GetEngineVersion();
    if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2)
    {
        SetFailState("This plugin is for L4D/L4D2 only.");   
    }
    AddCommandListener(VoteStart, "callvote");

        UserMsg messageid;
        messageid = GetUserMessageId("VotePass");
       
        if( messageid == INVALID_MESSAGE_ID)
        {
                LogError("Game don't have User Message called - VotePass");
        }
        else
        {
                HookUserMessage(messageid, VotePassFail);
        }

        messageid = GetUserMessageId("VoteFail");

        if( messageid == INVALID_MESSAGE_ID)
        {
                LogError("Game don't have User Message called - VoteFail");
        }
        else
        {
                HookUserMessage(messageid, VotePassFail);
        }


    forceKickFFThreshold = CreateConVar("sm_votekick_force_threshold","0","The threshold of damage where the offending player is just immediately kicked. 0 -> Any attempted damage, -1 -> No auto kick.", FCVAR_NONE, true, -1.0);


Diggingwolf2605 09-17-2021 07:12

Re: Error detected in plugin startup
 
Here is my meta game when typing in console:

PHP Code:

meta game
GameDLL Information
  Description
L4D Co-op Expert
  Mod Path
D:\testserver\left4dead
  DLL Path
d:\testserver\left4dead\bin\server.dll
  
Interface: ServerGameDLL005
  Engine
Left 4 Dead (2008)
  
User Messages:  Name                              Index  Size 
                  Geiger                            0      1    
                  Train                             1      1    
                  HudText                           2      
-1   
                  SayText                           3      
-1   
                  SayText2                          4      
-1   
                  TextMsg                           5      
-1   
                  HudMsg                            6      
-1   
                  ResetHUD                          7      1    
                  GameTitle                         8      0    
                  ItemPickup                        9      
-1   
                  ShowMenu                          10     
-1   
                  Shake                             11     13   
                  Fade                              12     10   
                  VGUIMenu                          13     
-1   
                  Rumble                            14     3    
                  CloseCaption                      15     
-1   
                  CloseCaptionDirect                16     
-1   
                  SendAudio                         17     
-1   
                  RawAudio                          18     
-1   
                  VoiceMask                         19     9    
                  RequestState                      20     0    
                  BarTime                           21     
-1   
                  Damage                            22     
-1   
                  RadioText                         23     
-1   
                  HintText                          24     
-1   
                  KeyHintText                       25     
-1   
                  ReloadEffect                      26     4    
                  PlayerAnimEvent                   27     
-1   
                  AmmoDenied                        28     2    
                  UpdateRadar                       29     
-1   
                  KillCam                           30     
-1   
                  MarkAchievement                   31     
-1   
                  Splatter                          32     1    
                  SplatterClear                     33     0    
                  MessageText                       34     
-1   
                  TransitionRestore                 35     0    
                  Spawn                             36     1    
                  CreditsLine                       37     
-1   
                  CreditsMsg                        38     0    
                  StatsCrawlMsg                     39     0    
                  StatsSkipState                    40     2    
                  ShowStats                         41     
-1   
                  MusicCmd                          42     
-1   
                  WitchBloodSplatter                43     
-1   
                  AchievementEvent                  44     
-1   
                  PZDmgMsg                          45     
-1   
                  AllPlayersConnectedGameStarting   46     0    
                  VoteRegistered                    47     1    
                  DisconnectToLobby                 48     0    
                  CallVoteFailed                    49     1    
                  SteamWeaponStatData               50     
-1   
                  SPHapWeapEvent                    51     4    
                  HapDmg                            52     
-1   
                  HapPunch                          53     
-1   
                  HapSetDrag                        54     
-1   
                  HapSetConst                       55     
-1   
                  HapMeleeContact                   56     0    
  57 user messages in total 


Bacardi 09-17-2021 07:19

Re: Error detected in plugin startup
 
...so. Do you see "VotePass" or "VoteFail" usermessages in Left 4 Dead (2008) - game ?

Diggingwolf2605 09-17-2021 09:22

Re: Error detected in plugin startup
 
I wasn't aware that the VotePass and VoteFail usermessages we're different since the plugin is compatible with both L4D and L4D2. If there is something that needs to be changed such as trying "VotePassed" or "VoteFailed" would that work as well?

Marttt 09-17-2021 11:18

Re: Error detected in plugin startup
 
You should always mention the game, the plugin name mislead to the L4D2 game.

Check if BuiltinVotes has what you need.

Diggingwolf2605 09-28-2021 07:55

Re: Error detected in plugin startup
 
I checked BuiltinVotes and i didn't find any usermessages for L4D1. I did look at NativeVotes 0.8.3 and i found these.

#L4D_vote_kick_player
#L4D_vote_passed_kick_player


All times are GMT -4. The time now is 02:16.

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