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

I need help with my plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lnteresting
Junior Member
Join Date: Jan 2019
Old 02-26-2019 , 15:03   I need help with my plugin
Reply With Quote #1

The plugin im trying to make sets players clan tags as their userID here's an expample


the plugin compiles but doesnt work in game

Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Interesting"
#define PLUGIN_VERSION "1.00"

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


public Plugin myinfo = 
{
	name = "UserID",
	author = PLUGIN_AUTHOR,
	description = "Sets player's clan tag as their userID'",
	version = PLUGIN_VERSION,
	url = "https://steamcommunity.com/id/AAAAAAGGHHH/"
};

public void OnClientPostAdminCheck(int client)
{
	int ID = GetClientUserId(client);
	char userID[6];
	
	for(int i = 0; ID > 0; i++)
	{
		userID[i] = ID % 10;
		ID = ID / 10;
	}
	
	CS_SetClientClanTag(client, userID);
}
Attached Files
File Type: sp Get Plugin or Get Source (userID.sp - 101 views - 647 Bytes)

Last edited by lnteresting; 02-26-2019 at 15:03.
lnteresting is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 02-27-2019 , 03:45   Re: I need help with my plugin
Reply With Quote #2

Why are you doing this?

Code:
for(int i = 0; ID > 0; i++)
{
	userID[i] = ID % 10;
	ID = ID / 10;
}
You should only need to do this:
Code:
public void OnClientPostAdminCheck(int client)
{
	int ID = GetClientUserId(client);
	char userID[6];
	IntToString(ID, userID, sizeof(userID));

	CS_SetClientClanTag(client, userID);
}
CliptonHeist is offline
lnteresting
Junior Member
Join Date: Jan 2019
Old 02-27-2019 , 07:33   Re: I need help with my plugin
Reply With Quote #3

Quote:
Originally Posted by CliptonHeist View Post
Why are you doing this?

Code:
for(int i = 0; ID > 0; i++)
{
	userID[i] = ID % 10;
	ID = ID / 10;
}
You should only need to do this:
Code:
public void OnClientPostAdminCheck(int client)
{
	int ID = GetClientUserId(client);
	char userID[6];
	IntToString(ID, userID, sizeof(userID));

	CS_SetClientClanTag(client, userID);
}
Im new to coding so I didnt know about that I'll try doing that and see if it helps

Last edited by lnteresting; 02-27-2019 at 07:33.
lnteresting is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 02-27-2019 , 10:52   Re: I need help with my plugin
Reply With Quote #4

For your purpose, it sounds like you want the clan tag to be 1234, so you always have the option to easily find the id, and do e.g. "sm_kick #1234 bye", etc.

OnClientPostAdminCheck isn't being re-called if people are changing their clan tags in the middle of the game, so I'd say this place may not be the best place for this purpose, at least not alone.

You can try adding something to block the clantag change, e.g.:

PHP Code:
public Action OnClientCommandKeyValues(int clientKeyValues kv)
{
    
char kvKey[256];

    if (!
kv.GetSectionName(kvKeysizeof(kvKey))
        return 
Plugin_Continue;

    if (
StrEqual(kvKey"ClanTagChanged")) {
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

and then add your custom clantag just like you do in OnClientPostAdminCheck as well.

Or simply change it back above within the if returning Plugin_Handled, and eventually add further things such as admin exceptions, etc. if necessary.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL 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:29.


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