Connect Message in chat
Posted: Sat Apr 30, 2022 11:50 am
Plugin pentru a afisa un mesaj de conectare in chat, cati playeri sunt conectati, numele la server, un mic salut pentru tine si mai se poate adauga.
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <clientprefs>
#pragma newdecls required
public Plugin myinfo =
{
name = "Connect message",
author = "ZONEK.RO"
};
public void OnPluginStart()
{
HookEvent("player_connect_full", Event_PlayerConnect);
}
public void Event_PlayerConnect(Handle pEvent, const char[] szName, bool dontBroadcast)
{
int Client = GetClientOfUserId(GetEventInt(pEvent, "userid"));
PrintToChat(Client, " \x08\x10★\x08 ------------------------------------------ \x10★\x08");
PrintToChat(Client, " \x07[ \x04✮ \x07]\x01 Bime ai venit \x10%N\x01.", Client);
PrintToChat(Client, " \x07[ \x04✮ \x07]\x01 Te afli pe serverul \x06GO.ZONEK.RO\x01!");
PrintToChat(Client, " \x07[ \x04✮ \x07]\x01 Sunt \x06%d \x01/ \x06 24 \x01jucători conectați.", GetConnectedPlayers());
PrintToChat(Client, " \x07[ \x04✮ \x07]\x01 Pentru a comanda serverul tau intra pe \x06www.zonek.ro\x01.");
PrintToChat(Client, " \x08\x10★\x08 ------------------------------------------ \x10★\x08");
}
stock int GetConnectedPlayers()
{
int Players = 0;
for (int ConnectPlayer = 0; ConnectPlayer <= MaxClients; ConnectPlayer++)
{
if(IsValidClient(ConnectPlayer) && !IsFakeClient(ConnectPlayer))
Players++;
}
return Players;
}
stock bool IsValidClient(int client)
{
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || client < 0)
{
return false;
}
return IsClientInGame(client);
}