Giter VIP home page Giter VIP logo

smlib's Introduction

smlib's People

Contributors

berni2288 avatar crimsontautology avatar davenonymous avatar joinedsenses avatar peace-maker avatar shavitush avatar splewis avatar themadsword avatar they4kman 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

smlib's Issues

Any plan on fixing it for the latest sourcemod?

Now you can't compile anymore since it gives errors.

  • smlib/entities.inc(33) : error 138: const was specified twice.
  • smlib/crypt.inc(426) : error 173: 'in' is a newly reserved keyword that may be used in the future; use a different name as an identifier
  • smlib/effects.inc(158) : warning 237: coercing functions to and from primitives is unsupported and will be removed in the future.

Latest Sourcemod (1.7.2) & Latest Metamod(1.10.5)

New stock to add to smlib

stock Handle:FindPluginByName(const String:PluginName[], bool:Sensitivity=true, bool:Contains=false)
{
new Handle:iterator = GetPluginIterator();

new Handle:PluginID;

new String:curName[PLATFORM_MAX_PATH];

while(MorePlugins(iterator))
{
	PluginID = ReadPlugin(iterator)
	GetPluginInfo(PluginID, PlInfo_Name, curName, sizeof(curName));

	if(StrEqual(PluginName, curName, Sensitivity) || (Contains && StrContains(PluginName, curName, Sensitivity) != -1))
	{
		CloseHandle(iterator);
		return PluginID;
	}
}

CloseHandle(iterator);
return INVALID_HANDLE;

}

Client_HasWeapon non-functional with weapon_m4a1_silencer (csgo)

if(Client_HasWeapon(client, "weapon_m4a1_silencer"))
{
ReplyToCommand(client, "You are holding an m4a1-s");
return Plugin_Handled;
}
else
{
ReplyToCommand(client, "You are not holding an m4a1-s");
return Plugin_Handled;
}

Will always return false even when the condition is met.

Weird results with Math_IsInBounds

Hi,

I get a weird issue with Math_IsInBounds in the sm1.7 branch of smlib (didn't tested with old syntax).

I wrote a script for reproduce this bug :
tests.zip (sp & smx)

Here the source code :

#pragma semicolon 1

#include <sourcemod>
#include <smlib>

#pragma newdecls required

#define print_vec(%1) %1[0], %1[1], %1[2]
#define print_bool(%1) %1 ? "true" : "false"

public Plugin myinfo = 
{
    name        = "Math_IsInBound Bug test",
    author      = "No'",
    description = "",
    version     = "1.0",
	url = "http://www.sourcemod.net"
};

public void OnPluginStart() {
	float min[3], max[3], pos1[3], pos2[3], pos3[3];
	bool result_1, result_2, result_3;

	// Min and max vectors
	Math_MakeVector(-384.0, -384.0, -63.0, min);
	Math_MakeVector(384.0, 384.0, 384.0, max);

	// Point to check
	Math_MakeVector(-3186.0, -2474.0, -63.9, pos1); // out
	Math_MakeVector(-2465.0, 2113.0, -63.9, pos2); // out
	Math_MakeVector(-93.0, 12.0, -47.9, pos3); // in

	// With Math_IsInBounds
	
	PrintToServer("Min : [%f, %f, %f]", print_vec(min));
	PrintToServer("Max : [%f, %f, %f]", print_vec(max));
	PrintToServer("Position #1 : [%f, %f, %f]", print_vec(pos1));
	PrintToServer("Position #2 : [%f, %f, %f]", print_vec(pos2));
	PrintToServer("Position #3 : [%f, %f, %f]", print_vec(pos3));

	result_1 = (
		Math_IsInBounds(pos1[0], min[0], max[0]) && 
		Math_IsInBounds(pos1[1], min[1], max[1]) && 
		Math_IsInBounds(pos1[2], min[2], max[2])
	);

	PrintToServer("Resutl #1 : %s", print_bool(result_1));

	result_2 = (
		Math_IsInBounds(pos2[0], min[0], max[0]) && 
		Math_IsInBounds(pos2[1], min[1], max[1]) && 
		Math_IsInBounds(pos2[2], min[2], max[2])
	);

	PrintToServer("Resutl #2 : %s", print_bool(result_2));

	result_3 = (
		Math_IsInBounds(pos3[0], min[0], max[0]) && 
		Math_IsInBounds(pos3[1], min[1], max[1]) && 
		Math_IsInBounds(pos3[2], min[2], max[2])
	);

	PrintToServer("Resutl #2 : %s", print_bool(result_3));
	
	/*
		Min : [-384.000000, -384.000000, -63.000000]
		Max : [384.000000, 384.000000, 384.000000]
		Position #1 : [-3186.000000, -2474.000000, -63.900001]
		Position #2 : [-2465.000000, 2113.000000, -63.900001]
		Position #3 : [-93.000000, 12.000000, -47.900001]
		Resutl #1 : true
		Resutl #2 : false
		Resutl #3 : false
	*/
	
	// Without Math_IsInBounds
	
	PrintToServer("Min : [%f, %f, %f]", print_vec(min));
	PrintToServer("Max : [%f, %f, %f]", print_vec(max));
	PrintToServer("Position #1 : [%f, %f, %f]", print_vec(pos1));
	PrintToServer("Position #2 : [%f, %f, %f]", print_vec(pos2));
	PrintToServer("Position #3 : [%f, %f, %f]", print_vec(pos3));
	
	result_1 = (
		(min[0] <= pos1[0] <= max[0]) && 
		(min[1] <= pos1[1] <= max[1]) && 
		(min[2] <= pos1[2] <= max[2])
	);

	PrintToServer("Resutl #1 : %s", print_bool(result_1));

	result_2 = (
		(min[0] <= pos2[0] <= max[0]) && 
		(min[1] <= pos2[1] <= max[1]) && 
		(min[2] <= pos2[2] <= max[2])
	);

	PrintToServer("Resutl #2 : %s", print_bool(result_2));

	result_3 = (
		(min[0] <= pos3[0] <= max[0]) && 
		(min[1] <= pos3[1] <= max[1]) && 
		(min[2] <= pos3[2] <= max[2])
	);

	PrintToServer("Resutl #2 : %s", print_bool(result_3));
	
	/*
		Min : [-384.000000, -384.000000, -63.000000]
		Max : [384.000000, 384.000000, 384.000000]
		Position #1 : [-3186.000000, -2474.000000, -63.900001]
		Position #2 : [-2465.000000, 2113.000000, -63.900001]
		Position #3 : [-93.000000, 12.000000, -47.900001]
		Resutl #1 : false
		Resutl #2 : false
		Resutl #3 : true
	*/
}

I don't know where this issue come from but, the code inside the function is ok.
So it's maybe a Sourcemod bug.

Compiled with SM1.8 build 5961.
Tested on :

sm version
 SourceMod Version Information:
    SourceMod Version: 1.8.0.5964
    SourcePawn Engine: SourcePawn 1.8, jit-x86 (build 1.8.0.5964)
    SourcePawn API: v1 = 4, v2 = 11
    Compiled on: Dec  9 2016 10:38:26
    Built from: https://github.com/alliedmodders/sourcemod/commit/9eae3c7
    Build ID: 5964:9eae3c7
    http://www.sourcemod.net/

Bugs on compiling bot2player

On compiling plugin "bot2player" I've got some errors:

  • smlib/entities.inc(33) : error 138: const was specified twice
  • smlib/crypt.inc(426) : error 173: 'in' is a newly reserved keyword that may be used in the future; use a different name as an identifier

Plugin link.

Regards,
Nerus.

Add support for CS:GO to the colors API

CS:GO Color List:

Default: \x01
Dark Red: \x02
Purple: \x03
Green: \x04
Light Green: \x05
Lime Green: \x06
Red: \x07
Grey: \x08
Orange: \x09

Also, it seems csgo has an issue with coloring the very first character so you need to use a vertical tab like so ...

PrintToChat(client, " \x01\x0B\x03This works ...");
PrintToChat(client, " \x03This does not work ...");

Also, by adding the vertical tab it kinda makes the chat look a little weird due to the random space at the beginning, so maybe make this tab an option too?

⚠️ Math_Min() and Math_Max() are doing the opposite of what you would expect

In smlib, Math_Min() returns the biggest of two given numbers and Math_Max() returns the smallest of two given numbers:

/**
* Sets the given value to min
* if the value is smaller than the given.
*
* @param value Value
* @param min Min Value used as lower border
* @return Correct value not lower than min
*/
stock any:Math_Min(any:value, any:min)
{
if (value < min) {
value = min;
}
return value;
}
/**
* Sets the given value to max
* if the value is greater than the given.
*
* @param value Value
* @param max Max Value used as upper border
* @return Correct value not upper than max
*/
stock any:Math_Max(any:value, any:max)
{
if (value > max) {
value = max;
}
return value;
}

In doing so, they are doing the exact opposite of what anyone who has ever used max and min functions in other languages will expect them to do.

In other programming/scripting languages, the max function returns the maximum value (i.e. the biggest) of a given set and min returns the minimum (the smallest) number of a given set.
I bet that everyone who scripts some SourcePawn and uses the functions provided here will be very confused about the results, then start debugging their code and at some point read the source code of the functions - and then be even more confused about why they are "inverted" and pull their hair out.

Transitional branch -> Master

Is there any problems with transitional syntax branch?
If no, could you make it a master, since 1.10 is already stable and current master branch raise fatal error on compilation attempt.

Compile Error

Hello,

I downloaded Sourcemode 1.11/1.10/1.7.3 and tried any smlib and when i tried to compile smlib_test
everytime i got the same error
"...addons\sourcemod\scripting\include\smlib/effects.inc(65) : fatal error 196: deprecated syntax; see https://wiki.alliedmods.net/SourcePawn_Transitional_Syntax#Typedefs"

i dont know what i need to do to fix this, any help ?

I'm newbie here and i just need to restrict AUG and SG553 from retake and i need smlib to compile that plugin...

Bugs in String_StartsWith and _EndsWith

The functions String_StartsWith and String_EndsWith have a behaviour inconsistent with other languages.

In C#, "a".StartsWith("ab") returns false.
In JavaScript, 'a'.startsWith('ab') returns false.
But in SMLIB, String_StartsWith("a", "ab") returns true.

It is the same problem with String_EndsWith.
String_EndsWith("a", "ba") returns true when it should return false.

Add support for the new custom colors to the colors API (CS:S, TF2, HL2:DM, DOD:S)

The following games now support the new custom colors:

  • TF2
  • CS:S
  • HL2:DM
  • DOD:S

The following new control characters can be used now in the usermessage SayText2:

\x07

Followup bytes (as string): RRGGBB

\x08 (supports alpha)

Followup bytes (as string): RRGGBBAA

Todo: implement this in the smlib colors API

I don't know why Valve decided to specify the color code as string, as this is not efficient, 1 byte for each color part would have been better to save banwidth, but ok.

https://forums.alliedmods.net/showthread.php?t=185016
https://forums.alliedmods.net/showthread.php?p=1717390

Entity_GetAbsOrigin returns zero for func_door_rotating

Entity_GetAbsOrigin uses m_vecOrigin rather than m_vecAbsOrigin for some reason. We've only recently discovered that when used on a func_door_rotating, it returns the world origin (0, 0, 0). Are there any historical reasons for this function using m_vecOrigin rather than m_vecAbsOrigin? From the SDK, CBaseEntity::GetAbsOrigin uses m_vecAbsOrigin instead.

UPDATE: (If it wasn't obvious, the latter prop solves this case, causing to return the correct origin)

Small optimization.

Replace
new entity = INVALID_ENT_REFERENCE;
to
decl entity;
Because you re-write this value in next step:
while ((entity = FunctionName(arg1, arg2)) != INVALID_ENT_REFERENCE) { /.../ }

SMLIB steamid

I noticed with the source from the git when using "Client_FindBySteamId("steamidhere");
you get the warning

\smlib/clients.inc(162) : warning 234: symbol "GetClientAuthString" is marked as deprecated: Use GetClientAuthId

Maybe a fix for this?

JSON formatting

This is a feature request. Can you add a json string formatting function, if it can be done?

Personally, I'm interested in logging all the events with some additional data, and outputting everything as json formatted strings, so they can be read by a web service receiving all the logs.

Later edit: i am aware of the jansson extension, but the extension as dependency would be overkill, because i don't intend to do any parsing in srcds, just something like NativeObject.toJSONString()

Crypt warnings

Tested with 1.7.0-dev+5106

(precise lines were not specified only)

symbol is never used: "MD5Transform"
symbol is never used: "MD5Transform_FF"
symbol is never used: "MD5Transform_GG"
symbol is never used: "MD5Transform_HH"
symbol is never used: "MD5Transform_II"

Compile Issue

I seem to be having the following issue when attempting to compile this plugin

// G:\CSGO\a_Plugins\Compile\executes.sp(353) : error 017: undefined symbol "PQ_Clear" // G:\CSGO\a_Plugins\Compile\executes.sp(354) : error 017: undefined symbol "PQ_Clear" // G:\CSGO\a_Plugins\Compile\executes.sp(879) : warning 217: loose indentation // G:\CSGO\a_Plugins\Compile\executes.sp(977) : error 017: undefined symbol "PQ_Clear" // G:\CSGO\a_Plugins\Compile\executes.sp(986) : warning 213: tag mismatch // G:\CSGO\a_Plugins\Compile\executes.sp(995) : warning 213: tag mismatch

This is happening when compiling on both the current stable SM release and the dev release. I've attempted to troubleshoot and have ensured all dependencies are in place in their correct paths. Any help on this would be appreciated.

The Client_ShowScoreboard function is no longer working (CS:GO)

The Client_ShowScoreboard stock found in clients.inc does not seem to work anymore, at least not on CS:GO, - Do note that I have not tested if it works for CS:S, so it may still work perfectly fine on there.

I received no errors from my compiler, nor did anything show in my error logs. The code I used for testing was this:

public void OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}

public void Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));

    if(IsValidClient(client))
    {
        if(!IsFakeClient(client))
        {
            Client_ShowScoreboard(client);

            PrintToChatAll("Debug - 2");
        }
    }
}

1.10 Compilation Warning on transitional_syntax branch

When compiling with transitional syntax branch on 1.10-6463, this warning occurs:

/include/smlib/colors.inc(78) : warning 241: Array-based enum structs will be removed in 1.11. See https://wiki.alliedmods.net/SourcePawn_Transitional_Syntax#Enum_Structs

NEw syntax 1.11 need update

Compiling sm_dev_cmds.sp...
SourcePawn Compiler 1.11.0.6934
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

./include/smlib/entities.inc(1773) : error 418: deprecated syntax; see https://wiki.alliedmods.net/SourcePawn_Transitional_Syntax#Typedefs
./include/smlib/entities.inc(1773) : error 001: expected token: "-identifier-", but found "public"
./include/smlib/entities.inc(1773) : error 122: expected type expression

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.