PDA

View Full Version : Menu Player



lspublic
31-10-2022, 01:02 AM
Hello can you make with menu when you write /scan or /clean to open menu with players name ?

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define PLUGIN "Wargods"
#define VERSION "1.1.3"
#define AUTHOR "Dann"

#define TAG "WarGods"

#define MOTD_LOCATION "addons/amxmodx/configs/wargod.html"

new const REASON_BAN[] = "Deshtoj Verifikimi WG";

new bool:hascan[33], cvars[3]
new store_team

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")

cvars[0] = register_cvar("wcd_disconnect_ban", "1")
cvars[1] = register_cvar("wcd_minim_acces_flag", "d") // kick acces
cvars[2] = register_cvar("wcd_time_for_ban", "2")

register_dictionary("wargods.txt")
}

public client_connect(id)
{
hascan[id] = false
}

public client_disconnect(id)
{
if(hascan[id] && get_pcvar_num(cvars[0]) == 1)
{
new sName[32];
get_user_name(id, sName, charsmax(sName));

hascan[id] = false
client_cmd(0, "spk ^"vox/bizwarn eliminated")
server_cmd("amx_ban %i %s %s", get_pcvar_num(cvars[2]), sName, REASON_BAN)
}
}


public cmd_say(id)
{
new szSaid[192]
read_args(szSaid, charsmax(szSaid))
remove_quotes(szSaid)

if(contain(szSaid, "/skano") != -1)
{
if(get_user_flags(id) & get_pcvar_flags(cvars[1]))
{
new target[32]
copy(target, sizeof(target) -1, szSaid[6])
new player = cmd_target(id, target, 2)

if(player)
{
new pname[32], admin[32]
get_user_name(player, pname, charsmax(pname))
get_user_name(id, admin, charsmax(admin))

if(hascan[player])
{
ColorChat(id, "%L", LANG_SERVER, "ALREADY_HAVE", TAG)
return PLUGIN_HANDLED
}
else
{
new timer[64]
get_time("%d/%m/%Y - %H:%M:%S", timer, charsmax(timer))
hascan[player] = true
store_team = get_user_team(player)
user_silentkill(player)
cs_set_user_team(player, CS_TEAM_SPECTATOR)

ColorChat(0, "%L", LANG_SERVER, "MAKE_WCD", TAG, admin, pname, timer)
ColorChat(0, "%L", LANG_SERVER, "DOWNLOAD_LINK", TAG)
ColorChat(0, "%L", LANG_SERVER, "INFO_WCD", TAG)
client_cmd(id, "snapshot")
return PLUGIN_CONTINUE
}
}
else
{
ColorChat(id, "%L", LANG_SERVER, "INVALID_PLAYER", TAG)
return PLUGIN_HANDLED
}
}
}
else if(contain(szSaid, "/paster") != -1)
{
if(get_user_flags(id) & get_pcvar_flags(cvars[1]))
{
new target[32]
copy(target, charsmax(target), szSaid[7])
new player = cmd_target(id, target, 2)

if(player)
{
new pname[32]
get_user_name(player, pname, charsmax(pname))
cs_set_user_team(player, store_team)
hascan[player] = false

ColorChat(0, "%L", LANG_SERVER, "PLAYER_CLEAN", TAG, pname)
return PLUGIN_CONTINUE
}
else
{
ColorChat(id, "%L", LANG_SERVER, "INVALID_PLAYER", TAG)
return PLUGIN_HANDLED
}
}
}
else if(equal(szSaid, "/wg") || equal(szSaid, "/wargod"))
{
show_motd(id, MOTD_LOCATION)
}

return PLUGIN_CONTINUE
}

stock ColorChat(const id, const input[], any:...)
{
new Count = 1, Players[32];
static Msg[191];
vformat(Msg, 190, input, 3);

replace_all(Msg, 190, "!g", "^4");
replace_all(Msg, 190, "!y", "^1");
replace_all(Msg, 190, "!t", "^3");

if(id) Players[0] = id; else get_players(Players, Count, "ch");
{
for (new i = 0; i < Count; i++)
{
if (is_user_connected(Players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, Players[i]);
write_byte(Players[i]);
write_string(Msg);
message_end();
}
}
}
return PLUGIN_HANDLED
}

Tiger
31-10-2022, 09:07 PM
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define PLUGIN "Wargods"
#define VERSION "1.1.3"
#define AUTHOR "Dann"

#define TAG "WarGods"

#define MOTD_LOCATION "addons/amxmodx/configs/wargod.html"

new const REASON_BAN[] = "Deshtoj Verifikimi WG";

new bool:hascan[33], cvars[3]
new store_team

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")

cvars[0] = register_cvar("wcd_disconnect_ban", "1")
cvars[1] = register_cvar("wcd_minim_acces_flag", "d") // kick acces
cvars[2] = register_cvar("wcd_time_for_ban", "2")

register_dictionary("wargods.txt")
}

public client_connect(id)
{
hascan[id] = false
}

public client_disconnect(id)
{
if(hascan[id] && get_pcvar_num(cvars[0]) == 1)
{
new sName[32];
get_user_name(id, sName, charsmax(sName));

hascan[id] = false
client_cmd(0, "spk ^"vox/bizwarn eliminated")
server_cmd("amx_ban %i %s %s", get_pcvar_num(cvars[2]), sName, REASON_BAN)
}
}


public cmd_say(id)
{
new szSaid[192]
read_args(szSaid, charsmax(szSaid))
remove_quotes(szSaid)

if(contain(szSaid, "/skano") != -1)
{
if(get_user_flags(id) & get_pcvar_flags(cvars[1]))
{
new target[32]
copy(target, sizeof(target) -1, szSaid[6])
new player = cmd_target(id, target, 2)

if(player)
{
new pname[32], admin[32]
get_user_name(player, pname, charsmax(pname))
get_user_name(id, admin, charsmax(admin))

if(hascan[player])
{
ColorChat(id, "%L", LANG_SERVER, "ALREADY_HAVE", TAG)
return PLUGIN_HANDLED
}
else
{
new timer[64]
get_time("%d/%m/%Y - %H:%M:%S", timer, charsmax(timer))
hascan[player] = true
store_team = get_user_team(player)
user_silentkill(player)
cs_set_user_team(player, CS_TEAM_SPECTATOR)

ColorChat(0, "%L", LANG_SERVER, "MAKE_WCD", TAG, admin, pname, timer)
ColorChat(0, "%L", LANG_SERVER, "DOWNLOAD_LINK", TAG)
ColorChat(0, "%L", LANG_SERVER, "INFO_WCD", TAG)
client_cmd(id, "snapshot")
return PLUGIN_CONTINUE
}
}
else
{
ColorChat(id, "%L", LANG_SERVER, "INVALID_PLAYER", TAG)
return PLUGIN_HANDLED
}
}
}
else if(contain(szSaid, "/paster") != -1)
{
if(get_user_flags(id) & get_pcvar_flags(cvars[1]))
{
new target[32]
copy(target, charsmax(target), szSaid[7])
new player = cmd_target(id, target, 2)

if(player)
{
new pname[32]
get_user_name(player, pname, charsmax(pname))
cs_set_user_team(player, store_team)
hascan[player] = false

ColorChat(0, "%L", LANG_SERVER, "PLAYER_CLEAN", TAG, pname)
return PLUGIN_CONTINUE
}
else
{
ColorChat(id, "%L", LANG_SERVER, "INVALID_PLAYER", TAG)
return PLUGIN_HANDLED
}
}
}
else if(equal(szSaid, "/wg") || equal(szSaid, "/wargod"))
{
show_motd(id, MOTD_LOCATION)
}
else if(equal(szSaid, "/scan") || equal(szSaid, "/clean"))
{
show_players_menu(id)
}

return PLUGIN_CONTINUE
}


public show_players_menu(id)
{
//Create a variable to hold the menu
new menu = menu_create("Players:", "players_menu_handler")

//We will need to create some variables so we can loop through all the players
new players[32], pnum, tempid;

//Some variables to hold information about the players
new szName[32], szUserId[32];

//Fill players with available players
get_players( players, pnum, "c" ); // flag "c" because we don't want bots

//Start looping through all players
for ( new i; i<pnum; i++ )
{
//Save a tempid so we do not re-index
tempid = players[i];

//Get the players name and userid as strings
get_user_name( tempid, szName, charsmax( szName ) );

//We will use the data parameter to send the userid, so we can identify which player was selected in the handler
formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );

//Add the item for this player
menu_additem( menu, szName, szUserId, 0 );
}

//We now have all players in the menu, lets display the menu
menu_display(id, menu, 0);

return PLUGIN_HANDLED;
}


public players_menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}

//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
new szData[6], szName[64];
new _access, item_callback;

//heres the function that will give us that information ( since it doesnt magicaly appear )
menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );

//Get the userid of the player that was selected
new userid = str_to_num( szData );

//Try to retrieve player index from its userid
new player = find_player( "k", userid ); // flag "k" : find player from userid

//If player == 0, this means that the player's userid cannot be found
//If the player is still alive ( we had retrieved alive players when formatting the menu but some players may have died before id could select an item from the menu )
if ( player && is_user_alive( player ) )
{
// TODO: do whatever you want with player
}

menu_destroy( menu );
return PLUGIN_HANDLED;
}


stock ColorChat(const id, const input[], any:...)
{
new Count = 1, Players[32];
static Msg[191];
vformat(Msg, 190, input, 3);

replace_all(Msg, 190, "!g", "^4");
replace_all(Msg, 190, "!y", "^1");
replace_all(Msg, 190, "!t", "^3");

if(id) Players[0] = id; else get_players(Players, Count, "ch");
{
for (new i = 0; i < Count; i++)
{
if (is_user_connected(Players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, Players[i]);
write_byte(Players[i]);
write_string(Msg);
message_end();
}
}
}
return PLUGIN_HANDLED
}

It's been a while since I coded in amxx, I took the menu code from here (<b>You have to register to ba able to see this link</b>). Didn't tested it but it should work, you just need to implement what you want to do with the selected player as you didn't told me what you wanted.

~TraNda~
02-11-2022, 07:57 AM
Hi!
Try this, please. I can't test

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define PLUGIN "Wargods"
#define VERSION "1.1.3"
#define AUTHOR "Dann"

#define TAG "WarGods"

#define MOTD_LOCATION "addons/amxmodx/configs/wargod.html"

new const REASON_BAN[] = "Deshtoj Verifikimi WG";

new bool:hascan[33], cvars[3]
new store_team

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")

cvars[0] = register_cvar("wcd_disconnect_ban", "1")
cvars[1] = register_cvar("wcd_minim_acces_flag", "d") // kick acces
cvars[2] = register_cvar("wcd_time_for_ban", "2")

register_dictionary("wargods.txt")
}

public client_connect(id)
{
hascan[id] = false
}

public client_disconnect(id)
{
if(hascan[id] && get_pcvar_num(cvars[0]) == 1)
{
new sName[32];
get_user_name(id, sName, charsmax(sName));

hascan[id] = false
client_cmd(0, "spk ^"vox/bizwarn eliminated")
server_cmd("amx_ban %i %s %s", get_pcvar_num(cvars[2]), sName, REASON_BAN)
}
}

public cmd_say(id)
{
new szSaid[192]
read_args(szSaid, charsmax(szSaid))
remove_quotes(szSaid)

if(contain(szSaid, "/skano") != -1)
{
if(get_user_flags(id) & get_pcvar_flags(cvars[1]))
{
static players[32],num,nick[33],target,tid[32],menu
get_players(players, num, "ch")
menu=menu_create("Skano Players Menu", "_skano_pmh")
for(new i;i<num;i++)
{
target=players[i]
get_user_name(target, nick, charsmax(nick))
formatex(tid, charsmax(tid), "%d", get_user_userid(target))
menu_additem(menu, nick, tid)
}
menu_display(id, menu)
}
}
else if(contain(szSaid, "/paster") != -1)
{
if(get_user_flags(id) & get_pcvar_flags(cvars[1]))
{
new target[32]
copy(target, charsmax(target), szSaid[7])
new player = cmd_target(id, target, 2)

if(player)
{
new pname[32]
get_user_name(player, pname, charsmax(pname))
cs_set_user_team(player, store_team)
hascan[player] = false

ColorChat(0, "%L", LANG_SERVER, "PLAYER_CLEAN", TAG, pname)
return PLUGIN_CONTINUE
}
else
{
ColorChat(id, "%L", LANG_SERVER, "INVALID_PLAYER", TAG)
return PLUGIN_HANDLED
}
}
}
else if(equal(szSaid, "/wg") || equal(szSaid, "/wargod"))
{
show_motd(id, MOTD_LOCATION)
}

return PLUGIN_CONTINUE
}
public _skano_pmh(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

static szData[6], szName[64], _access, item_callback, tid, target
menu_item_getinfo(menu, item, _access, szData, charsmax(szData), szName, charsmax(szName), item_callback)

tid = str_to_num(szData)

target = find_player("k", tid)

if(target)
{
if(hascan[target])
{
ColorChat(id, "%L", LANG_SERVER, "ALREADY_HAVE", TAG)
return PLUGIN_HANDLED
}
else
{
static pname[33], admin[33],timer[25]
get_user_name(target, pname, charsmax(pname))
get_user_name(id, admin, charsmax(admin))
get_time("%d/%m/%Y - %H:%M:%S", timer, charsmax(timer))
hascan[target] = true
store_team = get_user_team(target)
user_silentkill(target)
cs_set_user_team(target, CS_TEAM_SPECTATOR)

ColorChat(0, "%L", LANG_SERVER, "MAKE_WCD", TAG, admin, pname, timer)
ColorChat(0, "%L", LANG_SERVER, "DOWNLOAD_LINK", TAG)
ColorChat(0, "%L", LANG_SERVER, "INFO_WCD", TAG)
client_cmd(id, "snapshot")
}
}
else
{
ColorChat(id, "%L", LANG_SERVER, "INVALID_PLAYER", TAG)
return PLUGIN_HANDLED
}

menu_destroy(menu)
return PLUGIN_HANDLED
}

stock ColorChat(const id, const input[], any:...)
{
new Count = 1, Players[32];
static Msg[191];
vformat(Msg, 190, input, 3);

replace_all(Msg, 190, "!g", "^4");
replace_all(Msg, 190, "!y", "^1");
replace_all(Msg, 190, "!t", "^3");

if(id) Players[0] = id; else get_players(Players, Count, "ch");
{
for (new i = 0; i < Count; i++)
{
if (is_user_connected(Players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, Players[i]);
write_byte(Players[i]);
write_string(Msg);
message_end();
}
}
}
return PLUGIN_HANDLED
}

yaxkkon
06-03-2023, 09:51 PM
Hello, one question, this conversation talks about the integration of an anticheat wargods type plugin incorporated into an sv? I'm very interested in something like this for my server, is there any way to integrate wargods inside?

~TraNda~
08-03-2023, 09:46 AM
Hello. This plugin does not integrate an anti-cheats on the server.

yaxkkon
30-03-2023, 09:10 PM
hello again tradna, it's me again, xD I'm already much more informed about what the plugin does, however I have several problems with it, could you help me?, the code that you just passed does not meet the required functions at least in my sv , and as far as I know the sv has everything so it shouldn't be the problem, you'll see I need the plugin, in addition to presenting the menu, to ban the player if he disconnects after being selected, and after 10 minutes it asks me if I decide to ban him or not, and when he puts no, I also cancel the ban when leaving, and one more option to give the player more time, there was already one that I saw out there that fulfilled most of the required functions but that one never canceled the ban when log off

--------------- Added after 19 minutes ---------------

or, and I also had problems to recreate the html file referred to by the "lang server" code, I found a format there but it didn't work for me, how can I integrate it well? This is what I found:
[en]
ALREADY_HAVE = !g[%s]!y : You already requested a scan for this player !
MAKE_WCD = !g[%s]!y : Admin !g[%s]!y requests an WCD scan for player !g[%s]!y. Date/Time : !g%s
DOWNLOAD_LINK = !g[%s]!y : Download link !g<b>You have to register to ba able to see this link</b>
INFO_WCD = !g[%s]!y : If you don't know how to do an WCD scan, type in chat !g/wcd!y or !g/infowcd!y !
PLAYER_CLEAN = !g[%s]!y : The player !g[%s]!y is clean after WCD scan !
INVALID_PLAYER =!g[%s]!y : The specified player is inexistent !

~TraNda~
31-03-2023, 08:46 AM
Hello,
Read this: <b>You have to register to ba able to see this link</b>(wg-wargods)?p=254354&viewfull=1#post254354

yaxkkon
01-04-2023, 07:30 AM
Or has my comment been deleted? Was it because I put my steam id? How am I supposed to contact you then? It must have been because I left my steam id, it said that I can't add friends, and according to what I read you said to add you if they wanted to get the updated version, if you could add me since I can't add you because my account is limited I would appreciate it. , will this help?: 1158137998 is the friend code.

Tiger
02-04-2023, 04:06 PM
yaxkkon: Nobody deleted your topic, your topic can be found here (<b>You have to register to ba able to see this link</b>). Topic was closed because you didn't reply to it for more than one month.

I added you on Steam.