Giter Club home page Giter Club logo

alliedmodders / sourcemod Goto Github PK

View Code? Open in Web Editor NEW
944.0 72.0 418.0 43.9 MB

SourceMod - Source Engine Scripting and Administration

Home Page: http://www.sourcemod.net/

Python 0.90% C++ 32.80% C 32.81% SourcePawn 9.48% Makefile 4.49% Shell 2.58% Smarty 0.01% Pawn 0.02% PLpgSQL 0.01% PLSQL 0.01% Perl 1.65% PHP 0.23% Roff 5.74% HTML 7.13% M4 1.39% Awk 0.02% DIGITAL Command Language 0.07% Raku 0.04% Pascal 0.22% C# 0.39%
sourcemod sourcepawn source-engine modding

sourcemod's Introduction

SourceMod

General

Development

Contact

  • Connect with us on GameSurge IRC in #sourcemod
  • Alternatively feel free to join our Discord server

License

SourceMod is licensed under the GNU General Public License version 3. Special exceptions are outlined in the LICENSE.txt file inside of the licenses folder.

sourcemod's People

Contributors

asherkin avatar bara avatar bl4nk avatar drifter321 avatar dvander avatar dysphie avatar erikminekus avatar ferret99gt avatar flaminsarge avatar fortytwofortytwo avatar fyren avatar god-tony avatar headline avatar iamdang avatar joinedsenses avatar kenzzer avatar kylesanderson avatar mikusch avatar nosoop avatar peace-maker avatar playboy31 avatar powerlord avatar psychonic avatar sirdigbot avatar systematicmania avatar theds avatar vauff avatar voided avatar wend4r avatar wildcard65 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sourcemod's Issues

Feature request: Plugin hash

I would like to request modification for PluginInfo function. I am talking about plugin hash which can be found with sm plugins info <#>

Forwards still push disconnected client indexes

MetaMod:Source v1.11.0-dev+1096V
Stripper v1.2.2
SourceMod v1.9.0.6119
Left 4 Dead (Linux)

Everytime SMAC or other plugins kicks a player (not bot) some sdkhook forwards still fire even when the client has been kicked. Which also floods my sourcemod errors logs for ~1sec.
This only happend after the sdkhook fix (fd87cb6, 29d1187).
Or this this intended after the fix?
Look at the timespan in the logs below.

Connection log:

0/32 Players - 21:45:56 - <[DE]tom_the_teacher> <STEAM_1:0:> <> DISCONNECTED after 31 minutes. <All players idle>

("All players idle" is a plugin which kicks all afk players when there are no non-afk players left)

Sourcemod error logs:

L 07/30/2017 - 21:45:57: [SM] Exception reported: Entity 3 (3) is invalid
L 07/30/2017 - 21:45:57: [SM] Blaming: fo_fatman.smx
L 07/30/2017 - 21:45:57: [SM] Call stack trace:
L 07/30/2017 - 21:45:57: [SM] [0] GetEntPropEnt
L 07/30/2017 - 21:45:57: [SM] [1] Line 976, D:\Left 4 Dead Modding\L4D SERVER\L4D SERVER\scripting\include\smlib/clients.inc::Client_GetActiveWeapon
L 07/30/2017 - 21:45:57: [SM] [2] Line 657, fo_fatman.sp::OnPlayerRunCmd
L 07/30/2017 - 21:45:57: [SM] Exception reported: Client 3 is not in game
L 07/30/2017 - 21:45:57: [SM] Blaming: smac_speedhack.smx
L 07/30/2017 - 21:45:57: [SM] Call stack trace:
L 07/30/2017 - 21:45:57: [SM] [0] IsPlayerAlive
L 07/30/2017 - 21:45:57: [SM] [1] Line 145, smac_speedhack.sp::OnPlayerRunCmd
L 07/30/2017 - 21:45:57: [SM] Exception reported: Client 3 is not in game
L 07/30/2017 - 21:45:57: [SM] Blaming: l4d_teammate_light.smx
L 07/30/2017 - 21:45:57: [SM] Call stack trace:
L 07/30/2017 - 21:45:57: [SM] [0] GetClientTeam
L 07/30/2017 - 21:45:57: [SM] [1] Line 410, l4d_teammate_light.sp::OnPlayerRunCmd
L 07/30/2017 - 21:45:57: [SM] Exception reported: Client 3 is not connected
L 07/30/2017 - 21:45:57: [SM] Blaming: smac_eyetest.smx
L 07/30/2017 - 21:45:57: [SM] Call stack trace:
L 07/30/2017 - 21:45:57: [SM] [0] IsFakeClient
L 07/30/2017 - 21:45:58: [SM] [1] Line 182, smac_eyetest.sp::OnPlayerRunCmd

Full error log:
errors_20170730.zip

Can´t ban players on Server

When i type !admin on the server and now i will ban i player i see not the menu for the times "5min,30min..." after i select the player how i will ban, the banmenu will closed..

any ideas how can i fix ?

Entity health problem

Hi, we where testing the SetEntityHealth command and trying to send by entprop a higher value than 65535 to players but we noticed that there is an overflow there. It would be great if you can patch this as soon as possible.

Thanks for reading.

Add 'Exact Match' feature to plugins search page

I know this isn't exactly SM related but I made an issue here as instructed by psychonic.

A lot of users link to their plugins via:
https://www.sourcemod.net/plugins.php

However, none of the fields (title, author, desc) include an exact match option.
I'm requesting an exact match checkbox be added for each of the above forum inputs so a user can search for plugins matching an exact name, description and most importantly author.

Bug while converting steamid64to2

So, while I'm trying to divide cSecondNum (converted to int) by 2, I always getting wrong result, seems like sourcemod rounds to ceil number I provide, as example, I'm trying to convert 76561198301265885 to SteamID2, but always getting wrong result (STEAM_0:0:1705000780 instead of STEAM_0:1:170500078). Also, calc provides correct number after division, but not sourcemod... ( http://joxi.ru/gmvq9N6iLwzllr.png )

stock void Steam64to2(char[] cSteamID, int iSize)
{
	char cInt64[2][11];
	
	//const = 7960265728 (full: 76561197960265728)
	Format(cInt64[0], 10, cSteamID[0]);
	Format(cInt64[1], 11, cSteamID[9]);
	
	int iFirst64Num = StringToInt(cInt64[0][7], 10) - 79;
	int iSecond64Num = StringToInt(cInt64[1], 10) - 60265728;
	
	iSecond64Num = 100000000 + iSecond64Num;
	
	char cSecondNum[32];
	
	Format(cSecondNum, 32, "%i%i", iFirst64Num - 1, iSecond64Num);
	
	float flSecondDiv64 = FloatDiv(StringToFloat(cSecondNum), 2.0); //Seems like bug here...
	
#if defined DEBUG
	PrintToServer("Debug: cInt64[0]: %s, iFirst64Num: %i, cInt64[0][10]: %s, cSecondNum: %s", cInt64[0], iFirst64Num, cInt64[0][9], cSecondNum);
	PrintToServer("Debug: cInt64[1]: %s, iSecond64Num: %i, flSecondDiv64: %.1f", cInt64[1], iSecond64Num, flSecondDiv64);
#endif
	
#if defined DEBUG
	PrintToServer("Debug: Got cSecondNum: %s, cSteamID[7]: %s, cSteamID: %s", cSecondNum, cSteamID[7], cSteamID);
#endif
	
	int iFirstNum = 0;
	
	if (flSecondDiv64 - RoundToFloor(flSecondDiv64) > 0)
		iFirstNum = 1;

	Format(cSteamID, iSize, "STEAM_0:%i:%i", iFirstNum, RoundToFloor(flSecondDiv64));
	
#if defined DEBUG
	PrintToServer("Debug: Got cSteamID: %s", cSteamID);
#endif
	
	return;
}

Any ideas?

Setting a delimiter with dbi extension

Is it possible to set a delimiter in a query using the dbi extension? If so, what is the correct way? If not, is there a possibility of this feature being added?

Currently trying to run a query of the form:

DELIMITER //
DROP TRIGGER IF EXISTS example_trigger //
CREATE TRIGGER example_trigger
	BEFORE INSERT ON example_table
	FOR EACH ROW
BEGIN
	CALL example_procedure(param, param2, ...);
END //

DROP PROCEDURE IF EXISTS example_procedure //
CREATE PROCEDURE example_procedure (IN in_param, IN in_param2, ...)
READS SQL DATA
BEGIN
	SET @@SESSION.max_sp_recursion_depth = 25;
	INSERT INTO example_table2 VALUES ... ON DUPLICATE KEY UPDATE ...;
END //
DELIMITER ;

If there is an alternate way of running something of the above form I'd be very grateful if someone could help.

Change Author Field when user updates AlliedModders forum Username

I know this isn't exactly SM related but I made an issue here as instructed by psychonic.

When a user changes their username via the new username feature Asher added, their old plugins keep their old username here:
https://www.sourcemod.net/plugins.php

I'm suggesting a query be added upon updating a username to change all the old username so it properly shows the correct current username.

As an example, I recently changed my username from: 'InvexByte' to 'Byte'.

GetTickInterval() always returns 0 for CS:GO

Might be something to do with metamod or the hl2sdk, let me know and I will repost there instead.

Other functions related to global variables work fine, e.g. GetGameTime(), etc.

Crash server - update

server crashed.

SourceMod Version Information:
SourceMod Version: 1.8.0.6019
SourcePawn Engine: SourcePawn 1.8, jit-x86 (build 1.8.0.6019)
SourcePawn API: v1 = 4, v2 = 11
Compiled on: Aug 18 2017 06:08:58
Built from: https://github.com/alliedmodders/sou...commit/b952414
Build ID: 6019:b952414
http://www.sourcemod.net/

debug log

---------------------------------------------- CRASH: Fri Aug 18 16:07:43 CEST 2017 Start Line: ./srcds_linux -autorestart -game csgo -usercon +game_type 0 +game_mode 0 -tickrate 128 -maxplayers 20 -maxplayers_override 20 +ip 193.33.176.75 -port 27058 +sv_setsteamaccount -exec server.cfg +tv_enable 1 +tv_maxclients 0 +tv_port 25128 +tv_advertise_watchable 1 +mapgroup mg_active +map de_dust2 -debug -pidfile /data/dd2/logs/522696.cs.pid [New LWP 15089] [New LWP 15239] [New LWP 15238] [New LWP 15207] [New LWP 15253] [New LWP 15241] [New LWP 15255] [New LWP 15263] [New LWP 15258] [New LWP 15256] [New LWP 15265] [New LWP 15269] [New LWP 15264] [New LWP 15267] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by ./srcds_linux -autorestart -game csgo -usercon +game_type 0 +game_mode 0 -tickr'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xf760b936 in ?? () from /lib/i386-linux-gnu/libc.so.6
#0 0xf760b936 in ?? () from /lib/i386-linux-gnu/libc.so.6
#1 0xec76e72f in CForward::PushString(char const*) () from /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/bin/sourcemod.logic.so
#2 0xec423229 in non-virtual thunk to CHalfLife2::EntityToBCompatRef(CBaseEntity*) () from /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/bin/sourcemod.2.csgo.so
#3 0x00000005 in ?? ()
#4 0x0d13b6e0 in ?? ()
#5 0xf23528cb in ?? () from /home/data/dd2/522696.csgo128/csgo/bin/server.so
#6 0xf22d4c8a in ?? () from /home/data/dd2/522696.csgo128/csgo/bin/server.so
#7 0xf1e5baea in ?? () from /home/data/dd2/522696.csgo128/csgo/bin/server.so
#8 0xed0b680a in __SourceHook_FHCls_IServerGameClientsClientCommand0::Func(edict_t*, CCommand const&) () from /home/data/dd2/522696.csgo128/csgo/addons/metamod/bin/metamod.2.csgo.so
#9 0xf5ec0c64 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#10 0xf5ea725d in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#11 0xf5f86200 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#12 0xf5f86535 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#13 0xf5f8818b in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#14 0xf5f887cc in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#15 0xf5f991ce in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#16 0xf5eee88f in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#17 0xf5ebb98c in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#18 0xf5f6ddbe in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#19 0xf5f6ea5c in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#20 0xf5f6f1c8 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#21 0xf5f78414 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#22 0xf5f786e6 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#23 0xf5f787f9 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#24 0xf5fdabba in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#25 0xf5fd7b06 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#26 0xf6ff94ed in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#27 0xf6ff9578 in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#28 0xf5fd7bfd in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#29 0xf610c090 in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#30 0xf5fd8def in ?? () from /home/data/dd2/522696.csgo128/bin/engine.so
#31 0xf6ff9654 in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#32 0xf7056890 in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#33 0xf7057abe in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#34 0xf7056890 in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#35 0xf6ff28f3 in ?? () from /data/dd2/522696.csgo128/bin/dedicated.so
#36 0x080486f9 in main ()
No symbol table info available.
eax 0x0 0
ecx 0x5 5
edx 0x2 2
ebx 0x5 5
esp 0xfffb7c64 0xfffb7c64
ebp 0xfffb7d18 0xfffb7d18
esi 0xae038d0 182466768
edi 0x5 5
eip 0xf760b936 0xf760b936
eflags 0x210283 [ CF SF IF RF ID ]
cs 0x23 35
ss 0x2b 43
ds 0x2b 43
es 0x2b 43
fs 0x3 3
gs 0x63 99
From To Syms Read Shared Object Library
No linux-gate.so.1
0xf776a6e0 0xf77a1fcb Yes () /lib/i386-linux-gnu/libm.so.6
0xf7761a30 0xf7762921 Yes (
) /lib/i386-linux-gnu/libdl.so.2
0xf7748870 0xf7755ef1 Yes () /lib/i386-linux-gnu/libpthread.so.0
0xf75a47f0 0xf76d147f Yes (
) /lib/i386-linux-gnu/libc.so.6
0xf77cf860 0xf77e86bd Yes () /lib/ld-linux.so.2
0xf754b1a0 0xf75678fc Yes (
) /data/dd2/522696.csgo128/bin/libtier0.so
0xf74ecb70 0xf751cf6c Yes () /data/dd2/522696.csgo128/bin/libvstdlib.so
0xf6ff25a0 0xf707fb98 Yes (
) /data/dd2/522696.csgo128/bin/dedicated.so
0xf6fb3d60 0xf6fc91b4 Yes () /data/dd2/522696.csgo128/bin/libsteam_api.so
0xf6f17914 0xf6f5dc78 Yes /data/dd2/522696.csgo128/bin/libstdc++.so.6
0xf6ebde04 0xf6ecd4b8 Yes /data/dd2/522696.csgo128/bin/libgcc_s.so.1
0xf5de9800 0xf6252ae0 Yes (
) /home/data/dd2/522696.csgo128/bin/engine.so
0xf56ccc90 0xf57b2a5c Yes () /home/data/dd2/522696.csgo128/bin/materialsystem.so
0xf515d0d0 0xf5217c6c Yes (
) /home/data/dd2/522696.csgo128/bin/studiorender.so
0xf4f61cb0 0xf50bf9dc Yes () /home/data/dd2/522696.csgo128/bin/vphysics.so
0xf4e4cd80 0xf4ecf704 Yes (
) /home/data/dd2/522696.csgo128/bin/datacache.so
0xf4d724b0 0xf4dee054 Yes () /home/data/dd2/522696.csgo128/bin/vscript.so
0xf662d330 0xf664a050 Yes (
) /home/data/dd2/522696.csgo128/bin/shaderapiempty.so
0xf33dc4c0 0xf4052b04 Yes () /data/dd2/522696.csgo128/bin/steamclient.so
0xf661e840 0xf6621dfc Yes (
) /lib/i386-linux-gnu/librt.so.1
0xf32eff60 0xf33151c0 Yes () /data/dd2/522696.csgo128/bin/crashhandler.so
0xf2e10a40 0xf2e6dae8 Yes (
) /home/data/dd2/522696.csgo128/csgo/bin/matchmaking_ds.so
0xf1c575d0 0xf2722a9c Yes () /home/data/dd2/522696.csgo128/csgo/bin/server.so
0xf18a3b50 0xf18d57d4 Yes (
) /home/data/dd2/522696.csgo128/bin/soundemittersystem.so
0xf18696a0 0xf188511c Yes () /home/data/dd2/522696.csgo128/bin/scenefilecache.so
0xf660aa50 0xf660de92 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/metamod/bin/server.so
0xed0aab60 0xed0e4af0 Yes () /home/data/dd2/522696.csgo128/csgo/addons/metamod/bin/metamod.2.csgo.so
0xf77c5a90 0xf77c61c8 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/bin/sourcemod_mm_i486.so
0xec40b870 0xec57ce59 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/bin/sourcemod.2.csgo.so
0xec72f440 0xec784120 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/bin/sourcemod.logic.so
0xec163700 0xec181294 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/bin/sourcepawn.jit.x86.so
0xf77c04f0 0xf77c3324 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/updater.ext.so
0xec02fa60 0xec057df5 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/webternet.ext.so
0xeb014a80 0xeb01a8f0 Yes (
) /lib/i386-linux-gnu/libnss_files.so.2
0xf6602b50 0xf66057d6 Yes () /lib/i386-linux-gnu/libnss_dns.so.2
0xeaeea690 0xeaef6ba4 Yes (
) /lib/i386-linux-gnu/libresolv.so.2
0xec710800 0xec71626c Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/game.cstrike.ext.2.csgo.so
0xec708c90 0xec70c4d8 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/bintools.ext.so
0xeae92370 0xeaec9c42 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/sdktools.ext.2.csgo.so
0xeae6fdc0 0xeae7b6a6 Yes /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/SteamWorks.ext.so
0xeb00a780 0xeb010e78 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/topmenus.ext.so
0xeb001ae0 0xeb006634 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/clientprefs.ext.so
0xead41e80 0xeae61ea0 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/dbi.sqlite.ext.so
0xec701e30 0xec704698 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/geoip.ext.so
0xeacca320 0xeacfc4d0 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/regex.ext.so
0xe9dd5730 0xe9df4d12 Yes () /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/sdkhooks.ext.2.csgo.so
0xe9cdf410 0xe9d9baa4 Yes /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/socket.ext.so
0xeacb8aa0 0xeacc1b44 Yes /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/dhooks.ext.so
0xe9162490 0xe91ed1f5 Yes (
) /home/data/dd2/522696.csgo128/csgo/addons/sourcemod/extensions/dbi.mysql.ext.so
0xeac8d8f0 0xeac9e122 Yes () /lib/i386-linux-gnu/libz.so.1
(
): Shared library is missing debugging information.
End of Source crash report`

GetConVarInt() and ConVar.IntValue

GetConVarInt() and ConVar.IntValue return wrong number. When number is odd that functions fix it to even number.

Example:

27607405 = 27607404
27607407 = 27607408

Switch Case with default inside a custom function creates a 209 warning

When using switch case with return a value inside a function the compiler throws warning 209 (http://i.imgur.com/5zFD8x5.png) even though there is a return value for every case

Short example script tested with 1.9.0.6128 and 1.8.0.6016:
Tested on Windows 10 64-Bit

#include <sourcemod>
#pragma newdecls required


public void OnPluginStart()
{
	SomeFunction();
}

int SomeFunction()
{
	switch(GetRandomInt(0, 5))
	{
		case 0: return 125;
		case 1: return 75;
		case 2: return 35;
		case 3: return 700;
		default: return 100;
	}
}

SourceMod stopped logging

Hello!
I have problem with logging in SourceMod. SourceMod stops log things (include errors) after some time running. It can be some days, sometimes it's just one day. It started to happen about month ago and it's really annoying to have no logs when I need to do something or fix something. Only restarts can help.
I think it's because I have many plugins, but then it would be weird if I couldn't track all needed things.
Thanks in advance for help.

Plugins randomly unloading

Is anyone else experiencing the issue starting at SM 1.8, where plugins are unloading at random times, without creating any sort of error session? I tried to reload one of the plugins, but it told me I couldn't because a native was unavailable. It doesn't let me know in error session, that this is happening. I had to load a plugin near the top of my native chain, then reload others beneath it, so they worked properly.

OnEntityCreated forward issue

If you don't want to read how I came around the issue please jump to "What's the problem"

Over the last months I've been making plugins relying on this forward to make fun stuff ect...
And sometimes the intended goal didn't work as expected and I thought it was just my code being bad, said plugin ran on 5 different servers and it happened on all of them.

Recently I've been making a plugin to remove the entity tf_ammo_pack on the game TF2, it worked well til I noticed an ammo pack hasn't been removed I remade and remade my code again and again with different approach it always ended up to the same problem, sometimes the ammo pack wasn't removed, so I came to the conclusion OnEntityCreated must be sometimes not called at all.

What's the problem?

It seems the forward OnEntityCreated isn't called sometimes, this issue seems very very rare.

General infos:

  • Linux server
  • Running on game Team Fortress 2

SourceMod Version Information:

  • SourceMod Version: 1.9.0.6059
  • SourcePawn Engine: 1.9.0.6059, jit-x86 (build 1.9.0.6059)
  • SourcePawn API: v1 = 4, v2 = 12
  • Compiled on: Mar 5 2017 14:12:07
  • Built from: 9924a28
  • Build ID: 6059:9924a28
  • http://www.sourcemod.net/

Metamod:Source version 1.10.6

How reproduce the bug?

In order to reproduce the bug easily I recommend spawning a group of 32 red bots on the map itemtest set nb_blind on 1, noclip to test room, slay all the bots so they respawn in that test room, and then load the plugin I've provided with that issue, and start melee crit kill every single bot til you see one ammo box on the ground.

Screenshot of the bug occurring, I killed several bots all ammo packs got kill except one: https://steamuserimages-a.akamaihd.net/ugc/848216256556038176/657D9768A29C20226867FCCA6C7F223A98B17BCD/

Chat debug:

Entity 1178 spawned (tf_ragdoll)
Entity 1175 spawned (tf_ammo_pack)
Entity 1181 spawned (tf_ragdoll)
Entity 1222 spawned (tf_ammo_pack)
Entity 1238 spawned (tf_ragdoll)
Entity 1202 spawned (tf_ammo_pack)
Entity 1207 spawned (tf_ragdoll)
//Missing debug chat line for a newly spawned tf_ammo_pack (the one we see in the screenshot)

Plugin code

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

#pragma newdecls required

public Plugin myinfo = 
{
	name = "[TF2] OnEntityCreated bug", 
	author = "Benoist3012", 
	description = "", 
	version = "0.1", 
	url = ""
};

public void OnEntityCreated(int iEntity, const char[] classname)
{
	//Filtering out some spammy entity
	if (strncmp(classname, "tf_weapon", 9) != 0 && strcmp(classname, "instanced_scripted_scene") != 0 && strcmp(classname, "env_sniperdot") != 0 && strcmp(classname, "tf_dropped_weapon") != 0)
		PrintToChatAll("Entity %d spawned (%s)", iEntity, classname);
	if (strcmp(classname, "tf_ammo_pack") == 0)
	{
		SDKHook(iEntity, SDKHook_SetTransmit, Hook_PackSpawn);
		SDKHook(iEntity, SDKHook_Spawn, Hook_PackSpawn);
		AcceptEntityInput(iEntity, "Kill");
	}
}

public Action Hook_PackSpawn(int iEntity)
{
	return Plugin_Handled;
}

Theory

There's maybe some kind of check that gets activated randomly that blocks the call of created entity on the game, I don't know what exactly.
I have tried to kill all bots at once see if I could get (if the theory is right) the ammo packs of all bots.
And after countless try of all bots killed at once and no single ammo pack dropped I got this:
https://steamuserimages-a.akamaihd.net/ugc/848216256556177325/10FD4705AB09338823CAA97B5B63E80EA6BA6485/
The ammo pack of all bots spawned not even one missing, even though they should have all been deleted by the plugin, and as you can see in the chat all ammo pack debug line missing.
And on this screenshot we have the normal behavior
https://steamuserimages-a.akamaihd.net/ugc/848216256556197018/A4AE6DFA6E67D083368A33086D1EE5A25FB3186F/

Ps: I did upgrade my sourcemod to latest version, and I've also downgraded it, nothing worked for me. The same issue is happening with a similar plugin I stated in my intro on 5 different servers.

Issue with the DBI driver

After the csgo update around a week ago, i started getting crashes on my server.
I have many plugins which makes use of the DBI extension, so hard to pinpoint the exact behaviour that causes the crash, especially since they appear randomly, and need quite a few players on the server (15+ players) to trigger a crash. But they all tend to happen at the start of the map, when everyone is connecting, and a lot of database calls needs to be made.

Stack trace:
https://crash.limetech.org/sg4jaud5vyu3

Server info:
Linux version 4.9.30 (gcc version 6.3.0 20170516 (Debian 6.3.0-18) )
Metamod:Source version 1.10.7-dev
SourceMod Version: 1.8.0.6025

Also worth noting that im running the server in an lxc container.

Had a look at some crash statistics, and seems like im not the only one with the driver issue:
https://crash.limetech.org/stats/dbi.mysql.ext.so

Add .editorconfig for Resharper C++ 2017 users

Crashing Insurgency Server

Since Insurgency was updated the other day I cannot run Sourcemod 1.8.0 even with git6024.
The server log shows this:-
For FCVAR_REPLICATED, ConVar must be defined in client and game .dlls (sv_radial_spam_delay_leaderfrac)
Parent cvar in server.dll not allowed (ins_bot_arousal_suppression_falloff)
Unable to restore Weapon_p2a1.Empty from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.OpenBarrel from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.RemoveEmptyFlare from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.FlareInStart from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.FlareIn from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.FlareDrop from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.CloseBarrel from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_p2a1.CockHammer from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_M67.ArmDraw from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_C4.InsurgentDetonator from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.
Unable to restore Weapon_IED.Throw from the soundcache, no sound index! Ensure game_sounds_manifest.txt includes the script containing this.

Build 6016 - Insurgency SRCDS Segfault

Build 6016 is causing segfault when on vanilla install of Insurgency dedicated server on Linux (not sure about Windows).
Roll back to 6015 resolves issue.

No useful error message provided to console or debug.log.

Plugin Debugging Request Stack Trace

This is a github remake of the older Dump call stack request, but I wanted to have some more discussion about it in regards to how it'll look in the SM API, and how it'll actually be implemented. I'm thinking that the usage will look something like this

public void OnPluginStart() {
     RequestStackTrace("Some message");
}

and the expected output would be something like

L 09/16/2017 - 22:40:21: [SM] Stack trace requested: Some message
L 09/16/2017 - 22:40:21: [SM] Displaying call stack trace for plugin "test.smx":
L 09/16/2017 - 22:40:21: [SM] [0] Line 1, test.sp::OnPluginStart()
L 09/16/2017 - 22:40:21: [SM] [1] Line 2, test.sp::RequestStackTrace()

As far as implementation here are my notes I took while brainstorming. This is where I'd like anyone's criticisms

Looked at the definition for DebugReport::ReportError ; https://github.com/alliedmodders/sourcemod/blob/master/core/logic/DebugReporter.cpp#L158

Looking to either create 'DebugReport::GetTrace(IFrameIterator)', but the problem is that the trace is logged step by step, and not cached at all.
This means that DebugReport::GetTrace would have to return a 2d char array. One column per line of the stack trace. Then I'd have to change DebugReport::ReportError
and have it just loop that array and throw it's contents to logs.

This adds an extra step for DebugReport::ReportError, but also allows us to make stack traces more dynamically. In fact, the presence of a bool 'isIntentional' could
allow us to determine if "Stack trace requested: %s" should be used instead of "Exception reported: %s"

I'd like to implement this myself, but this issue is primarily for discussion & approval from SM Core devs

KeyValues.SetUInt64 only sets high (?) bits

Leveraging KeyValues to work with SteamID64 strings, found that the high bits aren't set in the KeyValues at all.

(Aside, KeyValues.SetUInt64 documentation indicates 0 = high, seems to be the opposite in practice?)

Test plugin available here (.txt since Github doesn't like .sp).

Plugin outputs the following on SM:1.9.0.6115 / MMS:1.10.8-dev for Team Fortress 2 on Ubuntu 16.04, SM:1.8.0.5973 / MMS:1.11.0-dev+1034 for TF2 on Debian 9 (64-bit).

[keyvalues_uint64_test.smx] SteamID64: 76561198006980102 -> AccountID: 46714374
[keyvalues_uint64_test.smx]    (hex: 02C8CE06 01100001)
[keyvalues_uint64_test.smx] AccountID: 46714374 -> SteamID64: 46714374
[keyvalues_uint64_test.smx]    (hex: 02C8CE06 00000000)

Expected behavior is that SteamID64 in the third line matches that of the first line, and that the hex values in the second and fourth lines match.

GetCmdArg Can't Get Korean Character.

I'm running My CS:GO Server in Ubuntu 16.04.3 Machine.
One day, I put SourceBans++ Plugin in My Server.
But Sourcebans can't read Korean Character.
So, I see sourcebans's SourceCode and I can find SourceBans use GetCmdArg.
After this Test, I make Test Plugin And Test My Server, but My Plugin Can't Get Korean Character.

P.S. : CSGO In-Game Chat can't write quote.

My Test Plugin SourceCode :

#include <sourcemod> 

public OnPluginStart()
{
	RegAdminCmd("sm_testcmd", Test_Command, ADMFLAG_BAN, "sm_ban <#userid|name> <minutes|0> [reason]");
}

public Action:Test_Command(client, args)
{
	decl String:buffer[100];
	GetCmdArg(1, buffer, sizeof(buffer));
	PrintToChatAll("Buffer : %s", buffer);
	return Plugin_Handled;
}

SM Version :
sm version
SourceMod Version Information:
SourceMod Version: 1.8.0.6027
SourcePawn Engine: SourcePawn 1.8, jit-x86 (build 1.8.0.6027)
SourcePawn API: v1 = 4, v2 = 11
Compiled on: Sep 8 2017 05:52:48
Built from: cf633f7
Build ID: 6027:cf633f7
http://www.sourcemod.net/

SM Exts :
[SM] Displaying 13 extensions:
[01] Automatic Updater (1.8.0.6027): Updates SourceMod gamedata files
[02] Webternet (1.8.0.6027): Extension for interacting with URLs
[03] CS Tools (1.8.0.6027): CS extended functionality
[04] BinTools (1.8.0.6027): Low-level C/C++ Calling API
[05] SDK Tools (1.8.0.6027): Source SDK Tools
[06] Top Menus (1.8.0.6027): Creates sorted nested menus
[07] Regex (1.8.0.6027): Provides regex natives for plugins
[08] DHooks (2.1.1): Dynamic Hooks
[09] SDK Hooks (1.8.0.6027): Source SDK Hooks
[10] Client Preferences (1.8.0.6027): Saves client preference settings
[11] SQLite (1.8.0.6027): SQLite Driver
[12] GeoIP (1.8.0.6027): Geographical IP information
[13] MySQL-DBI (1.8.0.6027): MySQL driver implementation for DBI

CS_GetWeaponPrice returning wrong value

I'm getting the wrong price for weapons
How to get the price for a revolver?

CT
AK47 - 3100
M4A1 - 3100
T
AK47 - 2700
M4A1 - 2700

#pragma newdecls required
#pragma semicolon 1
#include <cstrike>

public void OnPluginStart()
{
	RegConsoleCmd("sm_sr", Cmd_sr);
}

public Action Cmd_sr(int client, int args)
{
	PrintToChat(client, "AK47 - %d", CS_GetWeaponPrice(client, CSWeapon_AK47));
	PrintToChat(client, "M4A1 - %d", CS_GetWeaponPrice(client, CSWeapon_M4A1));
	return Plugin_Handled;
}

Build 6025

Server Spamming "All players have connected. ..." with Sourcemod (BFG Warmod)

Hello,

Just got a problem here with our servers we actually run on a event. It seems that since the update something changed, just tested this over months and never got this situation. As soon as all 10 players are connected the server starts to spam this in the chat:

All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.
All players have connected. Match will start in 60 seconds.

Were running our servers with Sourcemod and BFG Warmod, everything up to date. The warmod also continues to work as he should. The problem only appears in the warmup time (unlimited time with warmod). As soon as all 10 players are ready the warmod just starts the match and the massage dissapears. Just searched for this problem, but cant find anything.

Got an idea? Would be really fine if we got a sollution as fast as possible, as i said were running the servers at this moment at a event.

KeyValues ExportToFile Not Including Colors

Test case:

public void OnPluginStart()
{
	char path[PLATFORM_MAX_PATH];
	BuildPath(Path_SM, path, sizeof(path), "configs/somefile.txt");
	
	KeyValues kv = CreateKeyValues("some_kv");
	kv.SetColor("some_color", 255, 0, 0, 0);
	
	int r, g, b, a;
	kv.GetColor("some_color", r, g, b ,a);
	
	PrintToServer("%i %i %i %i", r, g, b, a);
	
	kv.ExportToFile(path);
	
}

Console output:

255 0 0 0
[SM] Plugin kv_testcase.smx reloaded successfully.

File output:

"some_kv"
{
}

This was reported to me by Drixevel, so thanks to him for reporting it.

Edit: I guess it's unimplemented in hl2sdk ref:https://github.com/alliedmodders/hl2sdk/blob/sdk2013/tier1/KeyValues.cpp#L973

Add natives for grenade management for cstrike extension

Ammo indexes common used in plugins that need to check/add/remove players' grenades (before we used CreateEntityByName, but now it is broken).
Functions based on this: Getting ammo type (particularly grenades)
I see two ways for it:

  1. I suggest to add new function to extention for getting ammo indexes.
    native int CS_GetAmmoTypeIndex(const char[] ammotype);
  2. (I think is better) Add two native to grenade direct management
#define CS_GRENADE_HE 0
#define CS_GRENADE_FLASHBANG 1
#define CS_GRENADE_SMOKE 2
#define CS_GRENADE_MOLOTOV 3
#define CS_GRENADE_DECOY 4
// place for player tracer grenade
native int CS_GetGrenadeCount(int client, int type);
native void CS_SetGrenadeCount(int client, int type, int value);

Seems to be better because:
Not need to store offsets in each plugin.
3) Maybe add both.

Goal of this:
Help plugin that manage grenades.
Plugin not need to have own gamedata for it.

typedef'ing extended to identifiers/variables feature req

'ello m8s, I would like to put an official request for typedefing to extend to variables.
I know that using "enum" with a name can technically do this by implicitly typedefing int to the enum's name but I'd the option to typedef other names as well as arrays.
I'll just code in my examples

#include <sourcemod>

// makes declaring vec3 an array of float.
typedef float[3] vec3_t;
...
// is really 'float origin[3];'
vec3_t origin;

or another example case with strings

typedef char[64] StrNameBuffer_t;
StrNameBuffer_t name;
strcopy(name, sizeof(name), "example typedef");

more complex example

typedef StringMap PlayerFields_t;
...
PlayerFields_t fields;
fields = new PlayerFields_t();
methodmap Player {
	public Player() {
	}
	property int iEquipment
	{
		public get() {
			int i; fields.GetValue("iEquipment", i);
			return i;
		}
		public set(const int val) {
			fields.SetValue("iEquipment", val);
		}
	}
};
// player methodmap is defined, we can typedef it now
typedef Player Enemy_t, Friendly_t;

[CS:GO] KeyValues clamp to int32's max value

When using kv.GetString() from KeyValues in CS:GO, if the string happens to be a number, it'll be clamped to 2147483647. Adding a letter to anywhere in the string inside the KeyValues avoids the 2147483647 clamping.

To test, use "3000000000" as a string to read from KeyValues with kv.GetString(). The string output will be "2147483647".

CS:S is fine. Haven't tested other games. Tested on both Windows and Linux. Latest Steam versions of CS:S and CS:GO.

Versions:

meta version
Metamod:Source version 1.10.7-dev
Built from: https://github.com/alliedmodders/metamod-source/commit/4a27e2f
Build ID: 959:4a27e2f
Loaded As: Valve Server Plugin
Compiled on: Apr 26 2017
Plugin interface version: 15:14
SourceHook version: 5:5
http://www.metamodsource.net/

sm version
SourceMod Version Information:
    SourceMod Version: 1.8.0.6015
    SourcePawn Engine: SourcePawn 1.8, jit-x86 (build 1.8.0.6015)
    SourcePawn API: v1 = 4, v2 = 11
    Compiled on: Jul  6 2017 12:16:00
    Built from: https://github.com/alliedmodders/sourcemod/commit/b94620e
    Build ID: 6015:b94620e

Trouble with FileToKeyValues

I'm having troubles trying to read a KeyValues tree from a file that is saved as UTF-8. I was having unexpected behaves in my code, so I decided to read and output the following file, just to see what happens:

"Test0"
{
	"test1"
	{
		"test"		"123"
	}
	"test2"
	{
		"test"		"123"
	}
}

And I read and output the file using:

char file[PLATFORM_MAX_PATH];
BuildPath(Path_SM, file, PLATFORM_MAX_PATH, "test1.txt");
Handle kv = CreateKeyValues("Test0");
FileToKeyValues(kv, file);
BuildPath(Path_SM, file, PLATFORM_MAX_PATH, "test2.txt");
KeyValuesToFile(kv, file);
CloseHandle(kv);

I received these on console:

KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\test1.txt

KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\test1.txt

KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\test1.txt

KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\test1.txt

KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\test1.txt
(*test2*),

And my output was:

""
{
}

I think the symbols used by the file to tell it's an UTF-8, is messing with the sourcemod reading it.

P.S.: Ok, so I realized the cause of it, it's the BOM, the UTF-8 without BOM will work, but since I need to use special characters, it's useless, so I just request a feature to allow us to read an UTF-8 file with BOM.

[CS:GO] Basevotes error

L 07/27/2017 - 22:39:23: [SM] Exception reported: Client index 5 is invalid
L 07/27/2017 - 22:39:23: [SM] Blaming: basevotes.smx
L 07/27/2017 - 22:39:23: [SM] Call stack trace:
L 07/27/2017 - 22:39:23: [SM]   [0] BanClient
L 07/27/2017 - 22:39:23: [SM]   [1] Line 349, /home/builds/sourcemod/linux-1.8/build/plugins/basevotes.sp::Handler_VoteCallback

Add new native for TraceAttack

Hi,

I would like to know if new 'TakeDamage' & 'TraceAttack' natives could be added to permit plugin developers to create easily new dangerous objects (Claymore, Sentry...) without the need of an extension.

Gamedata offsets are already present, so it shouldn't be hard to maintain these new natives.

1 - TakeDamage

I already know about SDKHooks_TakeDamage, but this native doesn't fire the hooks created in other plugins.

I know it's intended, but it can be a pain if you have a plugin A to inflict damage and a plugin B to reduce the damage received.

When all the plugins for a mode are created by the same developer, solutions can be found (Common API, ...). But if I would like for example to share in the AM forum a new plugin which uses SDKHooks_TakeDamage, then users will have issues if they have on their server another plugin which reduces / cancels damage (A shop item, a zombie class, ...).

The new native would have the same arguments than SDKHooks_TakeDamage, the only difference would be that it doesn't bypass the hooks.

2 - TraceAttack

To look like TakeDamage, 2 natives could be created (With / Without bypass). The prototype could be:

SDKHooks_TraceAttack(int entity, int inflictor, int attacker, float damage, int damageType, int weapon, const float damageForce[3], const float damagePosition[3], const float damageDirection[3], Handle trace);

Argument 'Handle trace' -> Can be built using TR_TraceRayEx for example.

Remark: calling this TraceAttack native alone will be useless. ClearMultiDamage() & ApplyMultiDamage() are necessary to make it work. Plugin developers will be able to call these two functions easily using SDKCall (They don't have any arguments - The only difficulty is to find their signature).


If needed (Because you don't have a lot of free time / whatever reason), I can work on a solution and request a pull. But I would like to avoid to work if it's already a NO .

Thank you for reading 😺.

Fix pls weapons!!!! ERROR

Hello my FRIENDSSSS
L 08/19/2017 - 15:41:13: [CSTRIKE] Failed to locate function.
L 08/19/2017 - 17:10:26: [CSTRIKE] Failed to lookup AliasToWeaponID signature.

Loading plugin from full path

I am currently adding workshop support for Empires Mod and want to make it possible for people to submit and load SourceMod workshop items.

Because workshop items are placed outside the game directory by steam the workshop code mounts them in using the gameinfo.txt search paths.

SourceMod seems to load plugins from a fixed relative directory and doesn't seem to use the steam filesystem:

g_pSM->BuildPath(Path_SM, fullpath, sizeof(fullpath), "plugins/%s", file);

Is there a way to load a plugin using a full path? Or can workshop loading be accomplished in a different way?

a newbie question

hi:
I want to ask an question about how an function is implement.
In sourcemod/plugins/include/clients.inc , there is an function called KickClient,
but I can not find where this function is implemented.
I just want to call KickClient in my dll(windows dynamic library), but I can not figure how it was implemented. please help, thank you!

CS:GO message strings parsing into menus

Couldn't find this elsewhere, but basically:

  • If a user has one of the cs:go strings in their name, #buy, #SFUI_* etc; when the names are displayed into menus, it causes the game to display the strings as the game engine would usually use them.

Example:

image
image2

Note: Not plugin related.

Add a new SDKType to manage some handles

Hi,

This feature can answer the issue #675.

Currently with SDKCall there're:

SDKType_CBaseEntity
SDKType_CBasePlayer
SDKType_Vector
SDKType_QAngle
SDKType_PlainOldData
SDKType_Float
SDKType_Edict
SDKType_String
SDKType_Bool

What do you think about a new type 'SDKType_Handle'?

To start, only CGameTrace & CTakeDamageInfo could be supported (-> New natives would be needed to build a CTakeDamageInfo in a plugin).

Then we could do something like:

StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "TraceAttack");
PrepSDKCall_AddParameter(SDKType_Handle, SDKPass_ByRef); // CTakeDamageInfo &
PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef); // Vector &
PrepSDKCall_AddParameter(SDKType_Handle, SDKPass_Pointer); // CGameTrace *
hTraceAttack = EndPrepSDKCall();

This could help in the future to call any function using CGameTrace / CTakeDamageInfo.

Remark: It forces to have in SourceMod CGameTrace & CTakeDamageInfo classes up to date, but I don't think they will change every day 😺.

Thanks.


EDIT:

For a better simplicity and readibility, SDKType_CGameTrace & SDKType_CTakeDamageInfo could be created instead of a generic SDKType_Handle.

"Suicide Timers" throw exceptions when closing themselfs with delete/CloseHandle

 SourceMod Version Information:
    SourceMod Version: 1.9.0.6003
    SourcePawn Engine: 1.9.0.6003, jit-x86 (build 1.9.0.6003)
    SourcePawn API: v1 = 4, v2 = 12
    Compiled on: Nov 17 2016 15:44:53
    Built from: https://github.com/alliedmodders/sourcemod/commit/87b0a85
    Build ID: 6003:87b0a85
    http://www.sourcemod.net/

The CreateTimer info states that you should use CloseHandle to end a timer. But thats causing errors when closing a timer handle when the timer is in the same call stack and the timer runs out.
Not sure if this is a bug, but probably annoying to trace down errors for some people, especially with no real stack trace.
CloseHandle in the CreateTimer info should be replaced with KillTimer instead, since KillTimer closes the timer on next frame.

public Action tDeleteTimer(Handle timer)
{
        delete timer;

        //Throws exception when timer runs out
}

Full testing code:

#define DEBUG

#define PLUGIN_NAME           "My plugin"
#define PLUGIN_AUTHOR         ""
#define PLUGIN_DESCRIPTION    ""
#define PLUGIN_VERSION        "1.0"
#define PLUGIN_URL            ""

#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

Handle g_hCallmeTimer;

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

public OnPluginStart()
{
	RegConsoleCmd("sm_test", RunTests);
	RegConsoleCmd("sm_callme", RunCallme);
}

public Action RunTests(int client, int args)
{
	CreateTimer(1.0, tDeleteTimer);
	CreateTimer(1.0, tKillTimer);
	
	DataPack pack;
	CreateDataTimer(1.0, tDeleteDataTimer, pack);
	CreateDataTimer(1.0, tKillDataTimer, pack);
	
	g_hCallmeTimer = CreateTimer(1.0, tStackKillTimer);
}

public Action tDeleteTimer(Handle timer)
{
	delete timer;
}

public Action tKillTimer(Handle timer)
{
	KillTimer(timer);
}

public Action tDeleteDataTimer(Handle timer, Handle hndl)
{
	delete timer;
}

public Action tKillDataTimer(Handle timer, Handle hndl)
{
	KillTimer(timer);
}

public Action tStackKillTimer(Handle timer)
{
	for(int i = 1; i <= MaxClients; i++) {
		if(!IsClientInGame(i))
			continue;
			
		FakeClientCommand(i, "sm_callme");
		break;
	}
	
	g_hCallmeTimer = null;
	return Plugin_Stop;
}

public Action RunCallme(int client, int args)
{
	PrintToChatAll("Killing timer now!");
	delete g_hCallmeTimer;
}

Exceptions:

L 09/15/2017 - 10:27:59: [SM] Plugin "BasicPawnDebug-60463caa-1fd9-4d5e-800e-801bcfe2ce37.smx" encountered error 23: Native detected error
L 09/15/2017 - 10:27:59: [SM] Invalid timer handle 1aec0074 (error 3) during timer end, displayed function is timer callback, not the stack trace
L 09/15/2017 - 10:27:59: [SM] Unable to call function "tDeleteTimer" due to above error(s).
L 09/15/2017 - 10:27:59: [SM] Plugin "BasicPawnDebug-60463caa-1fd9-4d5e-800e-801bcfe2ce37.smx" encountered error 23: Native detected error
L 09/15/2017 - 10:27:59: [SM] Invalid timer handle 1aef0070 (error 3) during timer end, displayed function is timer callback, not the stack trace
L 09/15/2017 - 10:27:59: [SM] Unable to call function "tDeleteDataTimer" due to above error(s).
L 09/15/2017 - 10:27:59: [SM] Plugin "BasicPawnDebug-60463caa-1fd9-4d5e-800e-801bcfe2ce37.smx" encountered error 23: Native detected error
L 09/15/2017 - 10:27:59: [SM] Invalid timer handle 1af20073 (error 3) during timer end, displayed function is timer callback, not the stack trace
L 09/15/2017 - 10:27:59: [SM] Unable to call function "tStackKillTimer" due to above error(s).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.