Raised This Month: $12 Target: $400
 3% 

[CS:GO] VIP System


Post New Thread Reply   
 
Thread Tools Display Modes
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 04-19-2019 , 16:12   Re: [CS:GO/CSS?] VIP System
Reply With Quote #31

Quote:
Originally Posted by lemonpaka View Post
I just added a feature what I need about player can activate their own VIP via A Key, if someone need it just compile plugin with this code, and then what you need to do just generator keys and uplod it to MySQL.(not tested that code about table creation for KEYS, but I think it should work, because at first I create KEY table manualy)
Code:
public void OnPluginStart()
{
	LoadTranslations("common.phrases");
	
	g_cHealthBonus = CreateConVar("sm_vip_health", "10", "Health bonus amount, 0 = Disable", 0, true, 0.0);
	g_cArmorBonus = CreateConVar("sm_vip_armor", "1", "Enable the armor bonus? 0 = Disable, 1 = Enable", 0, true, 0.0, true, 1.0);
	g_cPistolBonus = CreateConVar("sm_vip_pistol", "1", "Enable the pistol bonus? 0 = Disable, 1 = Enable", 0, true, 0.0, true, 1.0);
	g_cPlayerSkins = CreateConVar("sm_vip_skins", "1", "Enable the player skins? 0 = Disable, 1 = Enable", 0, true, 0.0, true, 1.0);
	g_cTablePrefix = CreateConVar("sm_vip_table_prefix", "vip", "Prefix for the database table (Default: vip)");
	g_cVipFlags = CreateConVar("sm_vip_flags", "", "Flags to give the vip users, empty for nothing");
	
	AutoExecConfig();
	
	SQL_MakeConnection(); //The table cvar required in here
	
	g_aBlockedTags = new ArrayList(64);
	
	HookEvent("player_spawn", Event_PlayerSpawn);
	HookEvent("round_start", Event_RoundStart);
	
	RegAdminCmd("sm_addvip", Command_AddVIP, ADMFLAG_ROOT, "Gives a vip access");
	RegAdminCmd("sm_removevip", Command_RemoveVIP, ADMFLAG_ROOT, "Removes a vip access");
	RegConsoleCmd("sm_vip", Command_VIPMenu, "Opens the vip menu");
	RegConsoleCmd("sm_getvip",Command_GetVIP,"Get VIP via A key");
}
Code:
public Action Command_GetVIP(int client, int args)
{
	if (args != 1)
	{
		ReplyToCommand(client, "%s Usage: sm_getvip <cdkey>", PREFIX);
		return Plugin_Handled;
	}
	char szArg[512];
	char query[512];
	char szQuery[512];
	GetCmdArg(1, szArg, sizeof(szArg));
	Format(query, sizeof(query),"SELECT DAYS FROM vipCode WHERE VIPKEY='%s';", szArg);
	g_dDatabase.Query(DaysCallBack,query,client)
	FormatEx(szQuery, sizeof(szQuery), "DELETE FROM `vipCode` WHERE `VIPKEY` = '%s'", szArg);
	g_dDatabase.Query(SQL_CheckForErrors, szQuery, client);
	return Plugin_Handled;
}
public void DaysCallBack(Database db, DBResultSet results, const char[] error, any data)
{
	int client = data;
	if (results.FetchRow())
	{
	int iDays = results.FetchInt(0);
	if(iDays>0)
	{
	char szStamp[512];
	char szNewStamp[512];
	Format(szStamp, sizeof(szStamp), "%i", GetTime() + (iDays * 86400));
	Format(szNewStamp, sizeof(szNewStamp), "%i", GetTime() + ((iDays+g_iDaysLeft[client]) * 86400));
	PrintToChat(client, "%s Trying to give \x02%N \x01a vip access...", client);
	char szQuery[512];
	if (g_bVIP[client])
		FormatEx(szQuery, sizeof(szQuery), "UPDATE `vipUsers` SET `expireStamp`= '%s' WHERE `authId` = '%s'", szNewStamp, g_szAuth[client]);
	else
		FormatEx(szQuery, sizeof(szQuery), "INSERT INTO `vipUsers` (`authId`, `expireStamp`) VALUES ('%s', '%s')", g_szAuth[client], szStamp);
	g_dDatabase.Query(SQL_CheckForErrors, szQuery, GetClientSerial(client));
	
	SQL_FetchUser(client);
	PrintToChat(client, "%s Successfully gave \x02%N \x01a vip access...", PREFIX, client);
	}
	}
	else
	{
		PrintToChat(client, "%s invalid key", PREFIX);
	}
}
Code:
void SQL_MakeConnection()
{
	if (g_dDatabase != null)
		delete g_dDatabase;
	
	char szError[512];
	g_dDatabase = SQL_Connect("vip", true, szError, sizeof(szError));
	if (g_dDatabase == null)
	{
		SetFailState("Cannot connect to datbase error: %s", szError);
	}
	
	char szPrefix[512];
	g_cTablePrefix.GetString(szPrefix, sizeof(szPrefix));
	
	char szQuery[512];
	char szQuery2[512];
	char szQuery3[512];
	FormatEx(szQuery, sizeof(szQuery), "CREATE TABLE IF NOT EXISTS `%sUsers` (`authId` VARCHAR(32) NOT NULL, `expireStamp` INT NOT NULL, UNIQUE (`authId`));", szPrefix);
	g_dDatabase.Query(SQL_CheckForErrors, szQuery);
	FormatEx(szQuery2, sizeof(szQuery), "CREATE TABLE IF NOT EXISTS `%sPerks`(`authId` VARCHAR(32) NOT NULL PRIMARY KEY, `chatTag` VARCHAR(512) NOT NULL DEFAULT '', `clanTag` VARCHAR(512) NOT NULL DEFAULT '', `tagColor` VARCHAR(16) NOT NULL DEFAULT '', `nameColor` VARCHAR(16) NOT NULL DEFAULT '', `chatColor` VARCHAR(16) NOT NULL DEFAULT '', `hpBonus` INT(10) NOT NULL DEFAULT 0, `armorBonus` INT(10) NOT NULL DEFAULT 0, `tSkin` VARCHAR(512) NOT NULL DEFAULT '', `ctSkin` VARCHAR(512) NOT NULL DEFAULT '',UNIQUE (`authId`))", szPrefix);
	g_dDatabase.Query(SQL_CheckForErrors, szQuery2);
	FormatEx(szQuery3, sizeof(szQuery), "CREATE TABLE IF NOT EXISTS `%sCode`(`VIPKEY` VARCHAR(32) NOT NULL, `DAYS` INT(10) NOT NULL DEFAULT 30)", szPrefix);
	g_dDatabase.Query(SQL_CheckForErrors, szQuery3);
	for (int i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i))
			OnClientPostAdminCheck(i);
	}
}
The idea seems nice, but the code has much things to be changed (such as creating the tables, no need in 3 different strings (chars), just use 1 as I did and edit it for each table)
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 04-19-2019 , 16:19   Re: [CS:GO/CSS?] VIP System
Reply With Quote #32

Update: Fixed a bug with the table prefix cvar
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
lemonpaka
Member
Join Date: Sep 2018
Location: China
Old 04-19-2019 , 19:24   Re: [CS:GO/CSS?] VIP System
Reply With Quote #33

Quote:
Originally Posted by BraveFox View Post
The idea seems nice, but the code has much things to be changed (such as creating the tables, no need in 3 different strings (chars), just use 1 as I did and edit it for each table)
i see. i just for sure it create the table because i am a newbee, and looking forward to your version( Will we get the arms change for skins? )

Last edited by lemonpaka; 04-20-2019 at 01:57.
lemonpaka is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 04-20-2019 , 04:22   Re: [CS:GO/CSS?] VIP System
Reply With Quote #34

Update:
Added the option to put a skin arms, simply edit the config (configs/vip/skins.txt) like this:
Quote:
"1"
{
"name" "Connor Kenway"
"model" "models/player/custom_player/caleon1/connor/connor.mdl"
"arms" "arms path here"
"team" "1"
}
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
Summer Solder
Junior Member
Join Date: May 2018
Location: New Delhi, India
Old 04-20-2019 , 05:12   Re: [CS:GO/CSS?] VIP System
Reply With Quote #35

Quote:
Originally Posted by BraveFox View Post
Update: Fixed a bug with the table prefix cvar
sorry to say brother but it's still same for me, I am not getting the new table with the prefix added through cvar, tried with deleting old table 'vipUsers' and starting the server with prefix 'test' according to which new table is supposed to be 'testUsers' but still got vipUsers.

Please let me know if I am doing something wrong or anyone else also having the same issue.

EDIT: I manually changed the value of prefix in code and recompiled the plugin and this time I got the table with new default prefix.
in my case plugin keeps using the default value of prefix no matter to what and how many time I change it.
g_cTablePrefix = CreateConVar("sm_vip_table_prefix", "viptest", "Prefix for the database table (Default: vip)");
Attached Thumbnails
Click image for larger version

Name:	old.PNG
Views:	170
Size:	1.4 KB
ID:	175125   Click image for larger version

Name:	new.PNG
Views:	145
Size:	2.4 KB
ID:	175126  
__________________
Admin at Gang Gaming
-------------------------------
My Plugins
VMPanel
NonPrimePlayerKicker
CSGO Advanced Custom Rounds
-------------------------------
Github: Summer Soldier
Discord: Summer_Soldier#5591

Last edited by Summer Solder; 04-20-2019 at 12:42. Reason: Did some more experimenting after first response.
Summer Solder is offline
Frenzi3d
Member
Join Date: Nov 2018
Location: Thailand
Old 04-20-2019 , 06:28   Re: [CS:GO/CSS?] VIP System
Reply With Quote #36

Quote:
Originally Posted by miXXed View Post
sm_vip_pistol 1 - the pistol function is very good, but not for RETAKES servers..

can you make that the selected Pistol will be saved for the gamesession ?
a round on retakes can be played in 15 seconds.. and always showing up the pistol menu... would be nice if there
is a way to fix it.. instead of disable vip pistol menu.. maybe !vp ? "Vip Pistol"

i have tested any other stuff evrythign works great.
hope you can make somthing about the Pistol..
Yeah is not for retakes and deathmatch.

I disabled it but still show in everyround.

How to fix it ?
Frenzi3d is offline
lemonpaka
Member
Join Date: Sep 2018
Location: China
Old 04-20-2019 , 06:32   Re: [CS:GO/CSS?] VIP System
Reply With Quote #37

Quote:
Originally Posted by BraveFox View Post
Update:
Added the option to put a skin arms, simply edit the config (configs/vip/skins.txt) like this:
nice, but what I am confusing now is how to use official arms for official models( for exmple player choose FBI Model but even I set the arm "models/weapons/ct_arms_fbi.mdl" it doesn't work)
and if you dont set amrs' path...your arms will disapear, plz let them use default arms if you dont set the arm for your model

Last edited by lemonpaka; 04-20-2019 at 13:01.
lemonpaka is offline
Frenzi3d
Member
Join Date: Nov 2018
Location: Thailand
Old 04-20-2019 , 06:59   Re: [CS:GO/CSS?] VIP System
Reply With Quote #38

Quote:
Originally Posted by BraveFox View Post
Update:
Added the option to put a skin arms, simply edit the config (configs/vip/skins.txt) like this:
Name Color not working check Please.
Frenzi3d is offline
wolvez04
Senior Member
Join Date: Feb 2016
Location: Andora
Old 04-20-2019 , 08:20   Re: [CS:GO/CSS?] VIP System
Reply With Quote #39

Nice work
I will send a donation


Just some suggestions


Should have arms menu to select custom arm which will override the arm set for the skin

Should have defuse kit with cvar to enable/disable

Should have grenades menu to spawn with X grenades with cvar to enable/disable. Maybe they can only just choose one.

Should have cvar to enable/disable join and leave message
and/or
Should have cvar to disable join/leave message for player with flag eg. b (for admins)

Should have cash bonus per round with cvar to change bonus cash (also cvar to enable/disable)
__________________
Hiring developers of all sorts for small or big jobs.
Paying nicely. Just PM for any available jobs.

wolvez04 is offline
lemonpaka
Member
Join Date: Sep 2018
Location: China
Old 04-21-2019 , 09:05   Re: [CS:GO/CSS?] VIP System
Reply With Quote #40

Should have VIP reserved slots(my mistake...It can connect via console..)...for real...I dont know how to make your plugin works with reservedslots.smx..even I put "a" with sm_vip_flags

Last edited by lemonpaka; 04-22-2019 at 09:12.
lemonpaka 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 10:39.


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