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

Solved Get players who used command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Qes
AlliedModders Donor
Join Date: Jul 2014
Old 11-14-2017 , 08:42   Get players who used command
Reply With Quote #1

Hello,
How I can get players who used commands and give the first player a gift?

For example,
Players used commands sm_gift and I get all players, but only first player get a gift.
Command sm_pgift show all players who used commands sm_gift, but in the order they typed it.

Last edited by Qes; 11-15-2017 at 13:17.
Qes is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 11-14-2017 , 11:40   Re: Get players who used command
Reply With Quote #2

http://sourcemod.net/new-api/console/AddCommandListener
__________________
luki1412 is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 11-14-2017 , 12:28   Re: Get players who used command
Reply With Quote #3

Way to hook chat commands:

PHP Code:
public void OnPluginStart(){
    
RegConsoleCmd("say"hookchat);
    
RegConsoleCmd("say_team"hookchat);
}

public 
Action hookchat(int clientint args){
    
char saytxt[128]; GetCmdArgString(saytxtsizeof(saytxt)-1);
    
StripQuotes(saytxt); TrimString(saytxt);

    if(
StrEqual(saytxt"!command")){
          
// do things
        
}

Way to check all console commands and chat sm_ commands:

PHP Code:
public void OnPluginStart()
{
    
AddCommandListener(lookatweapon"+lookatweapon");
    
AddCommandListener(ping"sm_ping");
}

public 
Action lookatweapon(int client, const char[] commandint argc){
    
PrintToChat(client"You pressed F!");
    return 
Plugin_Handled;
}

public 
Action ping(int client, const char[] commandint argc){
        
// do things

Remember some client side commands like radio1, cant hooked.

Regards.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM

Last edited by rodrigo286; 11-14-2017 at 12:29.
rodrigo286 is offline
Qes
AlliedModders Donor
Join Date: Jul 2014
Old 11-14-2017 , 14:54   Re: Get players who used command
Reply With Quote #4

#EDIT
1. The point is, here is how to save all the players who used command it and then sort them in order from the fastest.
a) How can I get the nickname of the first player?
b) How can I remove the first person from this set so that the first person then is the other person who wrote this command?
It's about something like a queue

for example:
Code:
public Action:ShowVIPsList(id, args)
{
	if(!IsValidClient(id))
		return;
	
	PrintToChat(id, " \x03VIPs ONLINE");
	
	new x = 0;
	
	for(new i=1; i<=MaxClients; i++)
	{
		if(IsClientInGame(i) && bVIP[i])
		{
			PrintToChat(id, "%N", i);
			x++;
		}
	}
	
	if(!x)
		PrintToChat(id, "*Nothing*");
}
This code check players who have VIP and print to chat their nickname

Last edited by Qes; 11-14-2017 at 15:06.
Qes is offline
Qes
AlliedModders Donor
Join Date: Jul 2014
Old 11-15-2017 , 10:12   Re: Get players who used command
Reply With Quote #5

Okay, I got it, but I have a problem with print nicknames on HUD.
Code:
public Action:UpdateHUD(Handle:timer, any:client)
{	
	if(IsClientInGame(client) && IsValidClient(client))
	{
		decl String:format_array[256];
		Format(format_array, sizeof(format_array), "NOTHING");
		
		new size = GetArraySize(PlayersKol);
		for(new i=0; i<size; i++)
		{
			if(!IsValidClient(GetArrayCell(PlayersKol, i)) || !IsPlayerAlive(GetArrayCell(PlayersKol, i)))
			{
				RemoveFromArray(PlayersKol, i);
				return;
			}
			
			if(GetArrayCell(PlayersKol, i) > 0)
			{
				Format(format_array, sizeof(format_array), "%d. %N\n", i+1, GetArrayCell(PlayersKol, i));
			}
		}
			
		SetHudTextParams(0.25, 0.125, 10.0, 0, 255, 0, 1, 0, 1.0, 2.0);
		ShowHudText(client, 5, "PLAYERS:\n%s\n", format_array);
	}
}
This code always show ONE nickname :/
For Example
First player say command and HUD show his nickname, but if second player say command then name second player is show on HUD.


And this code
Code:
public Action:ArrayTEST1(id, args)
{
	if(!IsValidClient(id))
	return;
	
	new size = GetArraySize(PlayersKol);
	for(new i=0; i<size; i++)
	{
		PrintToChatAll("%N", GetArrayCell(PlayersKol, i))
	}
}
Works correctly.
Shows all players nickname who say command.

Last edited by Qes; 11-15-2017 at 13:17. Reason: I did it
Qes 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 00:12.


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