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

How to make this autoshow without cmd?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GBLTeam
Senior Member
Join Date: Mar 2012
Location: Republic of Macedonia
Old 11-09-2019 , 16:45   How to make this autoshow without cmd?
Reply With Quote #1

I found the plugin over here i want it to work without typing sm_info, i mean when you join to the server to show this message, for new players? How is that possible. Thanks for answer!

Code:
#include <sourcemod>
#include <multicolors>

#define PLUGIN_VERSION "1.1.0"

public Plugin myinfo =
{
	name = "Server Info",
	author = "EmreBulut",
	description = "Shows info about server.",
	version = PLUGIN_VERSION,
	url = "http://steamcommunity.com/id/emrebulut"
}

public OnPluginStart()
{
	RegConsoleCmd("sm_info", CMD_Info)
}

public Action:CMD_Info(client, args)
{
	char sBuffer[256];
	GetConVarString(FindConVar("hostname"), sBuffer,sizeof(sBuffer));
	CPrintToChat(client, "{darkred}Server name :{default} %s", sBuffer)

	int pieces[4];
	int longip = GetConVarInt(FindConVar("hostip"));
	int port = GetConVarInt(FindConVar("hostport"));
	pieces[0] = (longip >> 24) & 0x000000FF;
	pieces[1] = (longip >> 16) & 0x000000FF;
	pieces[2] = (longip >> 8) & 0x000000FF;
	pieces[3] = longip & 0x000000FF;

	char NetIP[32];
	Format(NetIP, sizeof(NetIP), "%d.%d.%d.%d:%d", pieces[0], pieces[1], pieces[2], pieces[3], port);  
	CPrintToChat(client, "{darkred}==============================================");
	CPrintToChat(client, "{darkred}Server IP: {default}%d.%d.%d.%d:%d", pieces[0], pieces[1], pieces[2], pieces[3], port)
	
	decl String:AdminNames[MAXPLAYERS+1][MAX_NAME_LENGTH+1];
	new count = 0;
	for(new i = 1 ; i <= GetMaxClients();i++)
	{
		if(IsClientInGame(i))
		{
			new AdminId:AdminID = GetUserAdmin(i);
			if(AdminID != INVALID_ADMIN_ID)
			{
				GetClientName(i, AdminNames[count], sizeof(AdminNames[]));
				count++;
			}
		} 
	}
	decl String:buffer[1024];
	ImplodeStrings(AdminNames, count, ",", buffer, sizeof(buffer));
	CPrintToChat(client, "{darkred}Online admins:{default} %s", buffer);

	GetNextMap(sBuffer, sizeof(sBuffer));
	CPrintToChat(client, "{darkred}Next map:{default} %s", sBuffer)

	GetCurrentMap(sBuffer, sizeof(sBuffer));
	CPrintToChat(client, "{darkred}Current map:{default} %s", sBuffer)

	int i_Minutes;
	int i_Seconds;
	int i_Time;
	if(GetMapTimeLeft(i_Time) && i_Time > 0)
	{
		i_Minutes = i_Time / 60;
		i_Seconds = i_Time % 60;
	}
	Format(sBuffer, sizeof(sBuffer), "%d:%02d", i_Minutes, i_Seconds);
	CPrintToChat(client, "{DarkRed}Timeleft:{default} %s", sBuffer)
}

stock bool IsValidPlayer(int client, bool alive = false)
{
	if(client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)))
	{
		return true;
	}
	return false;
}
stock bool IsPlayerAdmin(client)
{
	if (GetAdminFlag(GetUserAdmin(client), Admin_Generic))
	{
		return true;
	}
	return false;
}
GBLTeam is offline
Send a message via MSN to GBLTeam Send a message via Skype™ to GBLTeam
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 11-09-2019 , 19:06   Re: How to make this autoshow without cmd?
Reply With Quote #2

try to add this.

PHP Code:

public OnClientPutInServer(client)
{
    
CreateTimer(5.0WelcomeMsgclient);
    
}

public 
Action:WelcomeMsg(Handle:timerany:client)
{
CMD_Info(clienttimer);


Last edited by foxhound27; 11-09-2019 at 19:09.
foxhound27 is offline
GBLTeam
Senior Member
Join Date: Mar 2012
Location: Republic of Macedonia
Old 11-10-2019 , 06:50   Re: How to make this autoshow without cmd?
Reply With Quote #3

EDIT: FIXED
Thanks!


Like this?

PHP Code:
#include <sourcemod>
#include <multicolors>

#define PLUGIN_VERSION "1.1.0"

public Plugin myinfo =
{
    
name "Server Info",
    
author "EmreBulut",
    
description "Shows info about server.",
    
version PLUGIN_VERSION,
    
url "http://steamcommunity.com/id/emrebulut"
}
public 
OnClientPutInServer(client)
{
    
CreateTimer(5.0WelcomeMsgclient);
    
}

public 
Action:WelcomeMsg(Handle:timerany:client)
{
CMD_Info(clienttimer);

public 
Action:CMD_Info(clientargs)
{
    
char sBuffer[256];
    
GetConVarString(FindConVar("hostname"), sBuffer,sizeof(sBuffer));
    
CPrintToChat(client"{darkred}Server name :{default} %s"sBuffer)

    
int pieces[4];
    
int longip GetConVarInt(FindConVar("hostip"));
    
int port GetConVarInt(FindConVar("hostport"));
    
pieces[0] = (longip >> 24) & 0x000000FF;
    
pieces[1] = (longip >> 16) & 0x000000FF;
    
pieces[2] = (longip >> 8) & 0x000000FF;
    
pieces[3] = longip 0x000000FF;

    
char NetIP[32];
    
Format(NetIPsizeof(NetIP), "%d.%d.%d.%d:%d"pieces[0], pieces[1], pieces[2], pieces[3], port);  
    
CPrintToChat(client"{darkred}==============================================");
    
CPrintToChat(client"{darkred}Server IP: {default}%d.%d.%d.%d:%d"pieces[0], pieces[1], pieces[2], pieces[3], port)
    
    
decl String:AdminNames[MAXPLAYERS+1][MAX_NAME_LENGTH+1];
    new 
count 0;
    for(new 
<= GetMaxClients();i++)
    {
        if(
IsClientInGame(i))
        {
            new 
AdminId:AdminID GetUserAdmin(i);
            if(
AdminID != INVALID_ADMIN_ID)
            {
                
GetClientName(iAdminNames[count], sizeof(AdminNames[]));
                
count++;
            }
        } 
    }
    
decl String:buffer[1024];
    
ImplodeStrings(AdminNamescount","buffersizeof(buffer));
    
CPrintToChat(client"{darkred}Online admins:{default} %s"buffer);

    
GetNextMap(sBuffersizeof(sBuffer));
    
CPrintToChat(client"{darkred}Next map:{default} %s"sBuffer)

    
GetCurrentMap(sBuffersizeof(sBuffer));
    
CPrintToChat(client"{darkred}Current map:{default} %s"sBuffer)

    
int i_Minutes;
    
int i_Seconds;
    
int i_Time;
    if(
GetMapTimeLeft(i_Time) && i_Time 0)
    {
        
i_Minutes i_Time 60;
        
i_Seconds i_Time 60;
    }
    
Format(sBuffersizeof(sBuffer), "%d:%02d"i_Minutesi_Seconds);
    
CPrintToChat(client"{DarkRed}Timeleft:{default} %s"sBuffer)
}

stock bool IsValidPlayer(int clientbool alive false)
{
    if(
client >= && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)))
    {
        return 
true;
    }
    return 
false;
}
stock bool IsPlayerAdmin(client)
{
    if (
GetAdminFlag(GetUserAdmin(client), Admin_Generic))
    {
        return 
true;
    }
    return 
false;

Show:

welcome.sp(22) : warning 213: tag mismatch
welcome.sp(45) : warning 234: symbol "GetMaxClients" is marked as deprecated: Use MaxClients variable instead.

Well 22 tag is the CMD_Info from your line.

Last edited by GBLTeam; 11-10-2019 at 08:30. Reason: Fixed it!
GBLTeam is offline
Send a message via MSN to GBLTeam Send a message via Skype™ to GBLTeam
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-10-2019 , 09:04   Re: How to make this autoshow without cmd?
Reply With Quote #4

Try this.

Code:
#include <sourcemod>
#include <multicolors>

#define PLUGIN_VERSION "1.1.0"

public Plugin myinfo =
{
    name = "Server Info",
    author = "EmreBulut",
    description = "Shows info about server.",
    version = PLUGIN_VERSION,
    url = "http://steamcommunity.com/id/emrebulut"
}
public OnClientPutInServer(client)
{
    CreateTimer(5.0, WelcomeMsg, client);
    
}

public Action:WelcomeMsg(Handle:timer, any:client)
{
    CMD_Info(client, 0);
}

public Action:CMD_Info(client, args)
{
    char sBuffer[256];
    GetConVarString(FindConVar("hostname"), sBuffer,sizeof(sBuffer));
    CPrintToChat(client, "{darkred}Server name :{default} %s", sBuffer)

    int pieces[4];
    int longip = GetConVarInt(FindConVar("hostip"));
    int port = GetConVarInt(FindConVar("hostport"));
    pieces[0] = (longip >> 24) & 0x000000FF;
    pieces[1] = (longip >> 16) & 0x000000FF;
    pieces[2] = (longip >> 8) & 0x000000FF;
    pieces[3] = longip & 0x000000FF;

    char NetIP[32];
    Format(NetIP, sizeof(NetIP), "%d.%d.%d.%d:%d", pieces[0], pieces[1], pieces[2], pieces[3], port);  
    CPrintToChat(client, "{darkred}==============================================");
    CPrintToChat(client, "{darkred}Server IP: {default}%d.%d.%d.%d:%d", pieces[0], pieces[1], pieces[2], pieces[3], port)
    
    decl String:AdminNames[MAXPLAYERS+1][MAX_NAME_LENGTH+1];
    new count = 0;
    for(new i = 1 ; i <= MaxClients;i++)
    {
        if(IsClientInGame(i))
        {
            new AdminId:AdminID = GetUserAdmin(i);
            if(AdminID != INVALID_ADMIN_ID)
            {
                GetClientName(i, AdminNames[count], sizeof(AdminNames[]));
                count++;
            }
        } 
    }
    decl String:buffer[1024];
    ImplodeStrings(AdminNames, count, ",", buffer, sizeof(buffer));
    CPrintToChat(client, "{darkred}Online admins:{default} %s", buffer);

    GetNextMap(sBuffer, sizeof(sBuffer));
    CPrintToChat(client, "{darkred}Next map:{default} %s", sBuffer)

    GetCurrentMap(sBuffer, sizeof(sBuffer));
    CPrintToChat(client, "{darkred}Current map:{default} %s", sBuffer)

    int i_Minutes;
    int i_Seconds;
    int i_Time;
    if(GetMapTimeLeft(i_Time) && i_Time > 0)
    {
        i_Minutes = i_Time / 60;
        i_Seconds = i_Time % 60;
    }
    Format(sBuffer, sizeof(sBuffer), "%d:%02d", i_Minutes, i_Seconds);
    CPrintToChat(client, "{DarkRed}Timeleft:{default} %s", sBuffer)
}

stock bool IsValidPlayer(int client, bool alive = false)
{
    if(client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)))
    {
        return true;
    }
    return false;
}
stock bool IsPlayerAdmin(client)
{
    if (GetAdminFlag(GetUserAdmin(client), Admin_Generic))
    {
        return true;
    }
    return false;
}
__________________
Marttt 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 06:09.


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