Raised This Month: $ Target: $400
 0% 

how to fix badf stat on a module ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ultrv
New Member
Join Date: Jan 2025
Old 01-13-2025 , 15:09   how to fix badf stat on a module ?
Reply With Quote #1

Hello,i compiled this zombie_reloaded module and added it to amxx, but i get this badf stat when i type meta list.

PHP Code:
Currently loaded plugins:
      
description                 stat pend  file                      vers          src  load  unload
 
1AMX Mod X                   RUN   -    amxmodx_mm.dll            v1.10.0.5467  ini  Start ANY
 
2Engine                      RUN   -    engine_amxx.dll           v1.10.0.5467  pl1  ANY   ANY
 
3FakeMeta                    RUN   -    fakemeta_amxx.dll         v1.10.0.5467  pl1  ANY   ANY
 
4] <zombie_reloaded_amxx.dll>  badf load  zombie_reloaded_amxx.dll  v -           pl1   -     -
 [ 
5CStrike                     RUN   -    cstrike_amxx.dll          v1.10.0.5467  pl1  ANY   ANY
 
6CSX                         RUN   -    csx_amxx.dll              v1.10.0.5467  pl1  ANY   ANY
 
7Ham Sandwich                RUN   -    hamsandwich_amxx.dll      v1.10.0.5467  pl1  ANY   ANY
 
8GeoIP                       RUN   -    geoip_amxx.dll            v1.10.0.5467  pl1  ANY   ANY
 
9Fun                         RUN   -    fun_amxx.dll              v1.10.0.5467  pl1  ANY   ANY
 
[10MySQL                       RUN   -    mysql_amxx.dll            v1.10.0.5467  pl1  ANY   ANY
10 plugins
9 running 
Any help will be appreciated

And i apologise if this is not the right place to post this.
ultrv is offline
Nicosg
Junior Member
Join Date: May 2021
Location: Algiers, Algeria
Old 01-23-2025 , 05:45   Re: how to fix badf stat on a module ?
Reply With Quote #2

it seems you're working on a C++ (CPP) file designed for Linux, and you're aiming to adapt it for Windows. While this is entirely achievable, you'll need to make a few adjustments within the C++ file to ensure compatibility with the Windows environment.

1. File Paths
  1. On Windows, file paths use backslashes (\) instead of forward slashes (/). Update all file paths in the code to use \\ for Windows compatibility.

Example:
PHP Code:
// Linux
snprintf(File256"%s/addons/amxmodx/configs/maps/%s.cfg"GameSTRING(gpGlobals->mapname));

// Windows
snprintf(File256"%s\\addons\\amxmodx\\configs\\maps\\%s.cfg"GameSTRING(gpGlobals->mapname)); 
2. System-Specific Functions

Replace Linux-specific functions with their Windows equivalents. For example:
  1. pread is not available on Windows. Replace it with _lseek and _read from the Windows API.
  2. Use _snprintf instead of snprintf for better compatibility with Windows.


Example:
PHP Code:
#if !defined __linux__
static signed int pread(signed int Numbervoid *pBuffersize_t Countlong Offset) {
    return (
_lseek(NumberOffsetSEEK_SET) != Offset) ? ((signed int)(-1)) : ((signed int)(_read(NumberpBufferCount)));
}
#endif 
3. Compiler Directives
  1. Update compiler directives to account for Windows-specific code. Use
    HTML Code:
    #ifdef _WIN32
    for Windows-specific blocks.

Example:
PHP Code:
#ifdef _WIN32
// Windows-specific code
#else
// Linux-specific code
#endif 
4. Case Sensitivity
  1. Windows file systems are case-insensitive, while Linux is case-sensitive. Ensure all file paths and string comparisons are consistent with Windows conventions.

5. Dynamic Linking
  1. If the code uses dynamic linking (e.g., dlopen, dlsym), replace these with Windows equivalents (LoadLibrary, GetProcAddress).

Example:
PHP Code:
#ifdef _WIN32
HMODULE handle LoadLibrary("mydll.dll");
if (
handle) {
    
MyFunction = (MyFunctionType)GetProcAddress(handle"MyFunction");
}
#else
voidhandle dlopen("mydll.so"RTLD_LAZY);
if (
handle) {
    
MyFunction = (MyFunctionType)dlsym(handle"MyFunction");
}
#endif 
6. Endianness
  1. If the code deals with binary data or network protocols, ensure proper handling of endianness. Windows and Linux may have different default byte orders.

7. Build System
  1. Update the build system (e.g., Makefile or CMake) to compile the code on Windows. Use Visual Studio or MinGW for Windows compilation.

Updated Code for Windows
Here’s an example of how you can modify the code for Windows:

PHP Code:
#include "amxxmodule.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#ifdef _WIN32
#include <io.h> // For _lseek and _read
#else
#include <unistd.h> // For pread on Linux
#endif

#if !defined __linux__
static signed int pread(signed int Numbervoid *pBuffersize_t Countlong Offset) {
    return (
_lseek(NumberOffsetSEEK_SET) != Offset) ? ((signed int)(-1)) : ((signed int)(_read(NumberpBufferCount)));
}
#endif

// Rest of the code remains the same, but update file paths and system-specific functions as needed.

// Example: File path handling
void LoadConfig() {
    
char File[256];
    
char Game[25];
    
GET_GAME_DIR(Game);

#ifdef _WIN32
    
snprintf(File256"%s\\addons\\amxmodx\\configs\\maps\\%s.cfg"GameSTRING(gpGlobals->mapname));
#else
    
snprintf(File256"%s/addons/amxmodx/configs/maps/%s.cfg"GameSTRING(gpGlobals->mapname));
#endif

    
FILE *pFile fopen(File"r");
    if (
pFile) {
        
// Read and process the file
        
fclose(pFile);
    }

Summary of Changes
  • File Paths: Replace / with \\ for Windows.
  • System-Specific Functions: Use Windows equivalents (e.g., _lseek, _read).
  • Compiler Directives: Use #ifdef _WIN32 for Windows-specific code.
  • Case Sensitivity: Ensure consistent case usage for file paths and strings.
  • Dynamic Linking: Replace dlopen/dlsym with LoadLibrary/GetProcAddress.
  • Build System: Update the build system for Windows compilation.

To adapt this Makefile for Windows, you'll need to make several changes. Windows uses different tools (e.g., gcc is replaced by mingw32-gcc or cl for MSVC) and has different flags and file extensions (e.g., .dll instead of .so). Below is the updated Makefile for Windows:

PHP Code:
PROJECT zombie_reloaded_amxx.dll  # Windows uses .dll instead of .so

INCLUDE = -I. \
    -
IHLSDK -IMETAMOD

OBJECTS 
amxxmodule.cpp \
    
Zombie_Reloaded.cpp

# Windows-specific flags
FLAGS = -DNDEBUG -O2 -funroll-loops -fomit-frame-pointer -pipe \
    -
fvisibility=hidden -fvisibility-inlines-hidden -DWIN32 \
    -
shared -m32 -lm -lws2_32 -DPAWN_CELL_SIZE=32 -DJIT -DASM32 \
    -
DHAVE_STDINT_H -fno-strict-aliasing -fno-exceptions \
    -
fno-rtti --Wno-delete-non-virtual-dtor -static-libgcc \
    -
D_snprintf=snprintf -D_strcpy=strcpy -D_strcat=strcat \
    -
D_snprintf_s=snprintf -D_strncpy=strncpy -D_strncat=strncat \
    -
D_stricmp=stricmp -D_strcmp=strcmp -D_strncmp=strncmp \
    -
D_strnicmp=strnicmp -Dstrnicmp=strnicmp \
    -
Dstricmp=stricmp -fpermissive

# Compiler for Windows (MinGW)
CC mingw32-gcc

default:
    $(
CC) $(OBJECTS) $(FLAGS) $(INCLUDE) -$(PROJECT
After making these changes, the code should compile and run on Windows without issues. Let me know if you need further assistance!
Nicosg is offline
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 01-23-2025 , 05:58   Re: how to fix badf stat on a module ?
Reply With Quote #3

@Nicosg, thanks nice explaining , ive posted here to quicker fiind your reply for later use
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 01-23-2025 , 17:35   Re: how to fix badf stat on a module ?
Reply With Quote #4

it is certainly a module for css
__________________
mlibre is offline
Reply


Thread Tools
Display Modes

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 02:06.


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