#include <amxmodx>
#define MAX_NAME_LEN 32
#define PLUGIN "Steam ~ Non Steam listázása"
#define VERSION "1.0"
#define AUTHOR "Csabika20034"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /stns", "ShowSTNSMenu");
}
public ShowSTNSMenu(id)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED;
new menu = menu_create("Steam / Non-Steam Players", "MenuHandler");
menu_additem(menu, "Steames játékosok", "0");
menu_additem(menu, "Non-Steames játékosok", "1");
menu_display(id, menu, 0);
return PLUGIN_HANDLED;
}
public MenuHandler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new info[3];
menu_item_getinfo(menu, item, _, info, charsmax(info));
new choice = str_to_num(info);
menu_destroy(menu);
new subMenu;
if (choice == 0)
{
subMenu = menu_create("Steam Játékosok", "SubMenuHandler");
new count = 0;
for (new i = 1; i <= get_maxplayers(); i++)
{
if (is_user_connected(i) && is_user_steam(i))
{
new name[MAX_NAME_LEN];
new authid[32];
get_user_name(i, name, charsmax(name));
get_user_authid(i, authid, charsmax(authid));
new friendCode = SteamIDToFriendCode(authid);
new text[64];
formatex(text, charsmax(text), "%s ~ Barátkód: %d", name, friendCode);
new data[6];
num_to_str(i, data, charsmax(data));
menu_additem(subMenu, text, data);
count++;
}
}
if (count == 0)
{
client_print(id, print_chat, "[ST/NS] Nincs egyetlen Steam játékos sem a szerveren.");
menu_destroy(subMenu);
return PLUGIN_HANDLED;
}
menu_display(id, subMenu, 0);
}
else
{
subMenu = menu_create("Non-Steam Játékosok", "SubMenuHandler");
new count = 0;
for (new i = 1; i <= get_maxplayers(); i++)
{
if (is_user_connected(i) && !is_user_steam(i))
{
new name[MAX_NAME_LEN];
get_user_name(i, name, charsmax(name));
new data[6];
num_to_str(i, data, charsmax(data));
menu_additem(subMenu, name, data);
count++;
}
}
if (count == 0)
{
client_print(id, print_chat, "[ST/NS] Nincs egyetlen Non-Steam játékos sem a szerveren.");
menu_destroy(subMenu);
return PLUGIN_HANDLED;
}
menu_display(id, subMenu, 0);
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public SubMenuHandler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new info[6];
menu_item_getinfo(menu, item, _, info, charsmax(info));
new target = str_to_num(info);
if (is_user_connected(target))
{
new name[MAX_NAME_LEN];
new authid[32];
get_user_name(target, name, charsmax(name));
get_user_authid(target, authid, charsmax(authid));
new friendCode = SteamIDToFriendCode(authid);
client_print(id, print_chat, "[ST/NS] %s barátkódja: %d", name, friendCode);
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
stock is_user_steam(id)
{
new authid[32];
get_user_authid(id, authid, charsmax(authid));
return (strncmp(authid, "STEAM_", 6) == 0);
}
stock SteamIDToFriendCode(const authid[])
{
new len = strlen(authid);
new parts[3];
new idx = 0;
new num = 0;
for (new i = 0; i < len; i++)
{
new c = authid[i];
if (c >= '0' && c <= '9')
{
num = num * 10 + (c - '0');
}
else if (c == ':')
{
parts[idx++] = num;
num = 0;
if (idx > 2) break;
}
}
if (idx == 2)
parts[2] = num;
return parts[2] * 2 + parts[1];
}