Raised This Month: $32 Target: $400
 8% 

[L4D2] Shop [v4.5 | 20 March 2022]


Post New Thread Reply   
 
Thread Tools Display Modes
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 04-10-2022 , 00:00   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #131

Way to add a new SF lost add new translation step
kazya3 is offline
RichardHafer
Junior Member
Join Date: Dec 2020
Old 04-18-2022 , 11:56   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #132

Plugin is now officially broken, yay! It won't open the shop menu with the command altough it still gives points for killing stuff. Can't even recompile the .sp because of 4 errors

Last edited by RichardHafer; 04-18-2022 at 11:57.
RichardHafer is offline
VYRNACH_GAMING
Member
Join Date: Sep 2021
Old 04-21-2022 , 03:34   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #133

https://pastebin.com/QsM4Cvdc
I've recently added your SRS statistic plugin to my server and I realized the old memory leak issue has returned. Can't confirm if it's related to the stats plugin. My server running for about 6 hours return 600+ "l4d2_shop.smx IPreparedQuery" values.

I also check error logs etc and did not find anything. Do you think adding the delete handle to error clauses will fix this?

(this code is just a sample!)
Code:
int LoadPoints(int client)
{
	Database db = ConnectDB();
	if (db != null)
	{
		char steamId[32];
		int db_points = 0;
		char error[255];

		Handle hSelectStmt = INVALID_HANDLE;

		GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));

		///////////////////////// Load special functions
		if ((hSelectStmt = SQL_PrepareQuery(db, "SELECT functionNo, isEnabled FROM SpecialFunctions WHERE steamId = ?", error, sizeof(error))) == INVALID_HANDLE)
		{
			LogError("[ERROR]: SELECT SQL_PrepareQuery: \"%s\"", error);
delete hInsertStmt;
delete hSelectStmt;
return 1;
		}

		// Disabled all special function first
		for(int i =0; i< SF_SIZE; i++)
		{
			g_bClientSF[client][0][i] = false;
			g_bClientSF[client][1][i] = false;
		}
		SQL_BindParamString(hSelectStmt, 0, steamId, false);
		if (SQL_Execute(hSelectStmt))
		{
			while(SQL_FetchRow(hSelectStmt))
			{
				char functionNo[32];
				SQL_FetchString(hSelectStmt, 0, functionNo, sizeof(functionNo));
				int index = GetFunctionIndex(functionNo);
				bool isEnabled = SQL_FetchInt(hSelectStmt, 1) == 1;
				g_bClientSF[client][0][index] = isEnabled;
				g_bClientSF[client][1][index] = true;
			}
		}
		///////////////////////////////////////////////////

		////////////////////////////////// Load points
		if ((hSelectStmt = SQL_PrepareQuery(db, "SELECT steamId,points FROM Shop WHERE steamId = ?", error, sizeof(error))) == INVALID_HANDLE)
		{
			LogError("[ERROR]: SELECT SQL_PrepareQuery: \"%s\"", error);
			return db_points;
		}
		SQL_BindParamString(hSelectStmt, 0, steamId, false);

		// Find the client in the database
		if (SQL_Execute(hSelectStmt))
		{
			char playerName[64];
			GetClientName(client, playerName, sizeof(playerName));
			if(SQL_FetchRow(hSelectStmt))
			{
				SQL_FetchString(hSelectStmt, 0, steamId, sizeof(steamId));
				db_points = SQL_FetchInt(hSelectStmt, 1);
				LogAction(client, -1, "[LOAD]: \"%L\" loaded the record successfully! Points: \"%d\"", client, db_points);
			}
			else //INSERT
			{
				// if the user is not existed in the database, insert new one.
				Handle hInsertStmt = INVALID_HANDLE;
				if ((hInsertStmt = SQL_PrepareQuery(db, "INSERT INTO Shop(steamId, points) VALUES(?,?)", error, sizeof(error))) == INVALID_HANDLE)
				{
					LogError("[ERROR]: INSERT SQL_PrepareQuery: \"%s\"", error);
delete hInsertStmt;
delete hSelectStmt;
return 1;
				}
				else
				{
					SQL_BindParamString(hInsertStmt, 0, steamId, false);
					SQL_BindParamInt(hInsertStmt, 1, 0, false); // Default point is 0
					if (!SQL_Execute(hInsertStmt))
					{
						LogError("[ERROR]: INSERT error Error: \"%s\"", error);
					}
					int rs = SQL_GetAffectedRows(hInsertStmt);
					if(rs>0)
					{
						LogAction(client, -1, "[INSERT]: \"%L\" is a new user!!", client);
					}else
					{
						LogError("[ERROR]: \"%L\" made insert error \"%s\"", client, error);
delete hInsertStmt;
delete hSelectStmt;
return 1;
					}
				}
	  		    delete hInsertStmt;
			}

		}
	    delete hSelectStmt;
		return db_points;
	}
	delete db;
	return 0;

}
or can the plugin just clear/delete all the handles on map change? so that it does not accumulate over time?
__________________

Last edited by VYRNACH_GAMING; 04-21-2022 at 03:49. Reason: more suggestions
VYRNACH_GAMING is offline
thewintersoldier97
Senior Member
Join Date: Aug 2021
Location: Vietnam
Old 04-26-2022 , 07:42   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #134

Anyone can guide me on adding a plugin feature to the shop? Like Hats by Silvers for example. Sorry I'm a dum dum when come to this coding stuff.
__________________

Looking for some fun!
thewintersoldier97 is offline
pan0s
Senior Member
Join Date: Nov 2017
Old 04-29-2022 , 14:24   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #135

Quote:
Originally Posted by VYRNACH_GAMING View Post
https://pastebin.com/QsM4Cvdc
I've recently added your SRS statistic plugin to my server and I realized the old memory leak issue has returned. Can't confirm if it's related to the stats plugin. My server running for about 6 hours return 600+ "l4d2_shop.smx IPreparedQuery" values.

I also check error logs etc and did not find anything. Do you think adding the delete handle to error clauses will fix this?

(this code is just a sample!)
Code:
int LoadPoints(int client)
{
	Database db = ConnectDB();
	if (db != null)
	{
		char steamId[32];
		int db_points = 0;
		char error[255];

		Handle hSelectStmt = INVALID_HANDLE;

		GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));

		///////////////////////// Load special functions
		if ((hSelectStmt = SQL_PrepareQuery(db, "SELECT functionNo, isEnabled FROM SpecialFunctions WHERE steamId = ?", error, sizeof(error))) == INVALID_HANDLE)
		{
			LogError("[ERROR]: SELECT SQL_PrepareQuery: \"%s\"", error);
delete hInsertStmt;
delete hSelectStmt;
return 1;
		}

		// Disabled all special function first
		for(int i =0; i< SF_SIZE; i++)
		{
			g_bClientSF[client][0][i] = false;
			g_bClientSF[client][1][i] = false;
		}
		SQL_BindParamString(hSelectStmt, 0, steamId, false);
		if (SQL_Execute(hSelectStmt))
		{
			while(SQL_FetchRow(hSelectStmt))
			{
				char functionNo[32];
				SQL_FetchString(hSelectStmt, 0, functionNo, sizeof(functionNo));
				int index = GetFunctionIndex(functionNo);
				bool isEnabled = SQL_FetchInt(hSelectStmt, 1) == 1;
				g_bClientSF[client][0][index] = isEnabled;
				g_bClientSF[client][1][index] = true;
			}
		}
		///////////////////////////////////////////////////

		////////////////////////////////// Load points
		if ((hSelectStmt = SQL_PrepareQuery(db, "SELECT steamId,points FROM Shop WHERE steamId = ?", error, sizeof(error))) == INVALID_HANDLE)
		{
			LogError("[ERROR]: SELECT SQL_PrepareQuery: \"%s\"", error);
			return db_points;
		}
		SQL_BindParamString(hSelectStmt, 0, steamId, false);

		// Find the client in the database
		if (SQL_Execute(hSelectStmt))
		{
			char playerName[64];
			GetClientName(client, playerName, sizeof(playerName));
			if(SQL_FetchRow(hSelectStmt))
			{
				SQL_FetchString(hSelectStmt, 0, steamId, sizeof(steamId));
				db_points = SQL_FetchInt(hSelectStmt, 1);
				LogAction(client, -1, "[LOAD]: \"%L\" loaded the record successfully! Points: \"%d\"", client, db_points);
			}
			else //INSERT
			{
				// if the user is not existed in the database, insert new one.
				Handle hInsertStmt = INVALID_HANDLE;
				if ((hInsertStmt = SQL_PrepareQuery(db, "INSERT INTO Shop(steamId, points) VALUES(?,?)", error, sizeof(error))) == INVALID_HANDLE)
				{
					LogError("[ERROR]: INSERT SQL_PrepareQuery: \"%s\"", error);
delete hInsertStmt;
delete hSelectStmt;
return 1;
				}
				else
				{
					SQL_BindParamString(hInsertStmt, 0, steamId, false);
					SQL_BindParamInt(hInsertStmt, 1, 0, false); // Default point is 0
					if (!SQL_Execute(hInsertStmt))
					{
						LogError("[ERROR]: INSERT error Error: \"%s\"", error);
					}
					int rs = SQL_GetAffectedRows(hInsertStmt);
					if(rs>0)
					{
						LogAction(client, -1, "[INSERT]: \"%L\" is a new user!!", client);
					}else
					{
						LogError("[ERROR]: \"%L\" made insert error \"%s\"", client, error);
delete hInsertStmt;
delete hSelectStmt;
return 1;
					}
				}
	  		    delete hInsertStmt;
			}

		}
	    delete hSelectStmt;
		return db_points;
	}
	delete db;
	return 0;

}
or can the plugin just clear/delete all the handles on map change? so that it does not accumulate over time?
If I don't remember wrong, handle will be cleared after map changed.
For IPreparedQuery issue, it is because every time round end/start or player joins the game, that will be called once every time.
all sql handle delete has been written after using them, so I think the problem is not there.

For srs, you can add the follow code to fix the memory lead.
Name:  擷取.JPG
Views: 848
Size:  60.1 KB
__________________

Last edited by pan0s; 04-29-2022 at 14:43.
pan0s is offline
pan0s
Senior Member
Join Date: Nov 2017
Old 04-29-2022 , 14:25   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #136

Quote:
Originally Posted by thewintersoldier97 View Post
Anyone can guide me on adding a plugin feature to the shop? Like Hats by Silvers for example. Sorry I'm a dum dum when come to this coding stuff.
Just follow the guideline
Way to add a new SF.
__________________
pan0s is offline
zaviier
Senior Member
Join Date: Aug 2017
Location: Indonesia
Old 08-07-2022 , 19:27   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #137

i change my question.

where to disable notification everytime player got kill? it's spam and i dont like it...

Last edited by zaviier; 08-09-2022 at 14:29.
zaviier is offline
AloongSleep
Junior Member
Join Date: Sep 2022
Old 10-05-2022 , 01:41   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #138

excellent complement
Any chance to add custom purchases like spawning cars?
I reference the following plugin:
• "sm_alarmcar_spawn"
https://forums.alliedmods.net/showthread.php?t=139352

Last edited by AloongSleep; 10-05-2022 at 01:53. Reason: Aclarar la duda
AloongSleep is offline
pan0s
Senior Member
Join Date: Nov 2017
Old 10-08-2022 , 05:55   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #139

Quote:
Originally Posted by zaviier View Post
i change my question.

where to disable notification everytime player got kill? it's spam and i dont like it...
Search KillPoints

Replace
Code:
			if(AddPoints(client, points))
				CPrintToChat(client, "%T%T%T%T","SYSTEM", client, "KILLED_INFECTED", client, cvar_earn_infected_num.IntValue, "REWARD_POINTS", client, cvar_earn_infected.IntValue, "ADVERTISEMENT", client);
To:
Code:
AddPoints(client, points);
__________________

Last edited by pan0s; 10-08-2022 at 05:56.
pan0s is offline
pan0s
Senior Member
Join Date: Nov 2017
Old 10-08-2022 , 05:56   Re: [L4D2] Shop [v4.5 | 20 March 2022]
Reply With Quote #140

Quote:
Originally Posted by AloongSleep View Post
excellent complement
Any chance to add custom purchases like spawning cars?
I reference the following plugin:
• "sm_alarmcar_spawn"
https://forums.alliedmods.net/showthread.php?t=139352
Yes, you can do it by following my guideline..
__________________

Last edited by pan0s; 10-08-2022 at 05:56.
pan0s is offline
Reply



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 10:13.


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