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

Changing from client name to SteamID args


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nickolay
Member
Join Date: Jan 2020
Old 06-30-2020 , 23:46   Changing from client name to SteamID args
Reply With Quote #1

Got zero knowledge when it comes to this, so any help would be great.
Trying to change the code so instead of typing in client name or userid, I can just type in steamid.


Code:
{
	RegAdminCmd("sm_addvip", Command_Addvip, ADMFLAG_SLAY, "Adds an admin to admins_simple.ini");
}

public Action:Command_Addvip(client, args)
{
	if(args < 1)
	{
		ReplyToCommand(client, "[SM] Usage: sm_addvip <name or #userid>");
		return Plugin_Handled;
	}
	decl String:buffer[64];
	GetCmdArg(1, buffer, sizeof(buffer));
	new target = FindTarget(client, buffer, true, false);
	decl String:steamid[64];
	GetClientAuthId(target, AuthId_Steam2, steamid, sizeof(steamid));
	
	new String:szFile[256];
	BuildPath(Path_SM, szFile, sizeof(szFile), "configs/admins_simple.ini");

	new Handle:hFile = OpenFile(szFile, "at");

	WriteFileLine(hFile, "\"%s\" \"5:a\"  //%N", steamid, target);

	CloseHandle(hFile);

	return Plugin_Handled;
}
Nickolay is offline
Cruze
Veteran Member
Join Date: May 2017
Old 06-30-2020 , 23:58   Re: Changing from client name to SteamID args
Reply With Quote #2

PHP Code:
public OnPluginStart()
{
    
RegAdminCmd("sm_addvip"Command_AddvipADMFLAG_SLAY"Adds an admin to admins_simple.ini");
}

public 
Action:Command_Addvip(clientargs)
{
    if(
args != 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_addvip <steamid>");
        return 
Plugin_Handled;
    }
    
decl String:steamid[64];
    
GetCmdArg(1steamidsizeof(steamid));
    
    new 
String:szFile[256];
    
BuildPath(Path_SMszFilesizeof(szFile), "configs/admins_simple.ini");

    new 
Handle:hFile OpenFile(szFile"at");

    
WriteFileLine(hFile"\"%s\" \"5:a\""steamid);

    
CloseHandle(hFile);

    return 
Plugin_Handled;

__________________
Taking paid private requests! Add me on steam/discord!

AlliedModders Releases | Github | Private Plugins | PayPal | Steam | Discord: Cruze#4947
Cruze is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 07-01-2020 , 11:38   Re: Changing from client name to SteamID args
Reply With Quote #3

Shouldn't this be in Scripting forum?
__________________
MAGNAT2645 is offline
Nickolay
Member
Join Date: Jan 2020
Old 07-01-2020 , 14:16   Re: Changing from client name to SteamID args
Reply With Quote #4

Yeah noticed now It's the wrong section, sadly I can't move it myself.
Thank you Cruze, highly appreciated =)

On another subject, would it be possible to change from needing the title, to just a flag?
In this case, it would be "ADMFLAG_RESERVATION".

Quote:
public Action Command_Vip(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;

if (!g_bflagTitles[client][0])
{
PrintToChat(client, "[%cCK%c] This command requires the VIP title.", MOSSGREEN, WHITE);
return Plugin_Handled;
}
Nickolay 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 18:40.


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