AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help adminvote (https://forums.alliedmods.net/showthread.php?t=172263)

daNzEt 11-18-2011 02:34

Need help adminvote
 
Hello.
I would like to change adminvote plugin if possible.
I want to show choice of each player.

Player1 chose map de_dust2
Player2 chose map de_aztec
.
.
.
.
Playerx chose map fy_snow

Only at this command: amx_votemap

PHP Code:

#include <amxmodx>
#include <amxmisc>

new g_Answer[128]
new 
g_optionName[4][64]
new 
g_voteCount[4]
new 
g_validMaps
new g_yesNoVote
new g_coloredMenus
new g_voteCaller
new g_Execute[256]
new 
g_execLen

new bool:g_execResult
new Float:g_voteRatio

public plugin_init()
{
    
register_plugin("Admin Votes"AMXX_VERSION_STR"AMXX Dev Team")
    
register_dictionary("adminvote.txt")
    
register_dictionary("common.txt")
    
register_dictionary("mapsmenu.txt")
    
register_menucmd(register_menuid("Change map to "), MENU_KEY_1|MENU_KEY_2"voteCount")
    
register_menucmd(register_menuid("Choose map: "), MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4"voteCount")
    
register_menucmd(register_menuid("Kick "), MENU_KEY_1|MENU_KEY_2"voteCount")
    
register_menucmd(register_menuid("Ban "), MENU_KEY_1|MENU_KEY_2"voteCount")
    
register_menucmd(register_menuid("Vote: "), MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4"voteCount")
    
register_menucmd(register_menuid("The result: "), MENU_KEY_1|MENU_KEY_2"actionResult")
    
register_concmd("amx_votemap""cmdVoteMap"ADMIN_VOTE"<map> [map] [map] [map]")
    
register_concmd("amx_votekick""cmdVoteKickBan"ADMIN_VOTE"<name or #userid>")
    
register_concmd("amx_voteban""cmdVoteKickBan"ADMIN_VOTE"<name or #userid>")
    
register_concmd("amx_vote""cmdVote"ADMIN_VOTE"<question> <answer#1> <answer#2>")
    
register_concmd("amx_cancelvote""cmdCancelVote"ADMIN_VOTE"- cancels last vote")
    
    
g_coloredMenus colored_menus()
}

public 
cmdCancelVote(idlevelcid)
{
    if (!
cmd_access(idlevelcid0))
        return 
PLUGIN_HANDLED

    
if (task_exists(998899881))
    {
        new 
authid[32], name[32]
        
        
get_user_authid(idauthid31)
        
get_user_name(idname31)
        
log_amx("Vote: ^"%s<%d><%s><>^" cancel vote session"nameget_user_userid(id), authid)
    

        new 
maxpl=get_maxplayers();
        new 
msg[256];
        for (new 
1<= maxpli++)
        {
            if (
is_user_connected(i) && !is_user_bot(i))
            {
                
// HACK: ADMIN_CANC_VOTE_{1,2} keys were designed very poorly.  Remove all : and %s in it.
                
LookupLangKey(msgcharsmax(msg), "ADMIN_CANC_VOTE_1"i);
                
replace_all(msgcharsmax(msg), "%s""");
                
replace_all(msgcharsmax(msg), ":""");
                
trim(msg);
                
show_activity_id(iidnamemsg);
            }
        }
        
        
console_print(id"%L"id"VOTING_CANC")
        
client_print(0,print_chat,"%L",LANG_PLAYER,"VOTING_CANC")
        
remove_task(998899881)
        
set_cvar_float("amx_last_voting"get_gametime())
    }
    else
        
console_print(id"%L"id"NO_VOTE_CANC")

    return 
PLUGIN_HANDLED
}

public 
delayedExec(cmd[])
    
server_cmd("%s"cmd)

public 
autoRefuse()
{
    
log_amx("Vote: %L""en""RES_REF")
    
client_print(0print_chat"%L"LANG_PLAYER"RES_REF")
}

public 
actionResult(idkey)
{
    
remove_task(4545454)
    
    switch (
key)
    {
        case 
0:
        {
            
set_task(2.0"delayedExec"0g_Executeg_execLen)
            
log_amx("Vote: %L""en""RES_ACCEPTED")
            
client_print(0print_chat"%L"LANG_PLAYER"RES_ACCEPTED")
        }
        case 
1autoRefuse()
    }
    
    return 
PLUGIN_HANDLED
}

public 
checkVotes()
{
    new 
best 0
    
    
if (!g_yesNoVote)
    {
        for (new 
04; ++a)
            if (
g_voteCount[a] > g_voteCount[best])
        
        
best a
    
}

    new 
votesNum g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3]
    new 
iRatio votesNum floatround(g_voteRatio float(votesNum), floatround_ceil) : 1
    
new iResult g_voteCount[best]
    new 
players[32], pnumi
    
    get_players
(playerspnum"c")
    
    if (
iResult iRatio)
    {
        new 
lVotingFailed[64]
        
        for (
0pnumi++)
        {
            
format(lVotingFailed63"%L"players[i], "VOTING_FAILED")
            if (
g_yesNoVote)
                
client_print(players[i], print_chat"%L"players[i],  "VOTING_RES_1"lVotingFailedg_voteCount[0], g_voteCount[1], iRatio)
            else
                
client_print(players[i], print_chat"%L"players[i], "VOTING_RES_2"lVotingFailediResultiRatio)
        }
        
        
format(lVotingFailed63"%L""en""VOTING_FAILED")
        
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")"lVotingFailediResultiRatio)
        
        return 
PLUGIN_CONTINUE
    
}

    
g_execLen format(g_Execute255g_Answerg_optionName[best]) + 1
    
    
if (g_execResult)
    {
        
g_execResult false
        
        
if (is_user_connected(g_voteCaller))
        {
            new 
menuBody[512], lTheResult[32], lYes[16], lNo[16]
            
            
format(lTheResult31"%L"g_voteCaller"THE_RESULT")
            
format(lYes15"%L"g_voteCaller"YES")
            
format(lNo15"%L"g_voteCaller"NO")
            
            new 
len format(menuBody511g_coloredMenus "\y%s: \w%s^n^n" "%s: %s^n^n"lTheResultg_Execute)
            
            
len += format(menuBody[len], 511 leng_coloredMenus "\y%L^n\w" "%L^n"g_voteCaller"WANT_CONTINUE")
            
format(menuBody[len], 511 len"^n1. %s^n2. %s"lYeslNo)
            
show_menu(g_voteCaller0x03menuBody10"The result: ")
            
set_task(10.0"autoRefuse"4545454)
        }
        else
            
set_task(2.0"delayedExec"0g_Executeg_execLen)
    }
    
    new 
lVotingSuccess[32]
    
    for (
0pnumi++)
    {
        
format(lVotingSuccess31"%L"players[i], "VOTING_SUCCESS")
        
client_print(players[i], print_chat"%L"players[i], "VOTING_RES_3"lVotingSuccessiResultiRatiog_Execute)
    }
    
    
format(lVotingSuccess31"%L""en""VOTING_SUCCESS")
    
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^") (result ^"%s^")"lVotingSuccessiResultiRatiog_Execute)
    
    return 
PLUGIN_CONTINUE
}

public 
voteCount(idkey)
{
    if (
get_cvar_num("amx_vote_answers"))
    {
        new 
name[32]
        
get_user_name(idname31)
        
        if (
g_yesNoVote)
            
client_print(0print_chat"%L"LANG_PLAYERkey "VOTED_AGAINST" "VOTED_FOR"name)
        else
            
client_print(0print_chat"%L"LANG_PLAYER"VOTED_FOR_OPT"namekey 1)
    }
    ++
g_voteCount[key]
    
    return 
PLUGIN_HANDLED
}

public 
cmdVoteMap(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
    
    
new Float:voting get_cvar_float("amx_last_voting")
    if (
voting get_gametime())
    {
        
console_print(id"%L"id"ALREADY_VOTING")
        return 
PLUGIN_HANDLED
    
}
    
    if (
voting && voting get_cvar_float("amx_vote_delay") > get_gametime())
    {
        
console_print(id"%L"id"VOTING_NOT_ALLOW")
        return 
PLUGIN_HANDLED
    
}

    new 
argc read_argc()
    if (
argc 5argc 5
    
    g_validMaps 
0
    g_optionName
[0][0] = 0
    g_optionName
[1][0] = 0
    g_optionName
[2][0] = 0
    g_optionName
[3][0] = 0
    
    
for (new 1argc; ++i)
    {
        
read_argv(ig_optionName[g_validMaps], 31)
        
        if (
is_map_valid(g_optionName[g_validMaps]))
            
g_validMaps++

        new 
name[32]
        
get_user_name(idname31)

        
chat_color(0"!t%s !galege !g%s"nameg_optionName[i])
    }
    
    if (
g_validMaps == 0)
    {
        new 
lMaps[16]
        
        
format(lMaps15"%L"id, (argc == 2) ? "MAP_IS" "MAPS_ARE")
        
console_print(id"%L"id"GIVEN_NOT_VALID"lMaps)
        return 
PLUGIN_HANDLED
    
}

    new 
menu_msg[256], len 0
    
new keys 0
    
    
if (g_validMaps 1)
    {
        
keys MENU_KEY_0
        len 
format(menu_msg255g_coloredMenus "\y%L: \w^n^n" "%L: ^n^n"LANG_SERVER"CHOOSE_MAP")
        new 
temp[128]
        
        for (new 
0g_validMaps; ++a)
        {
            
format(temp127"%d.  %s^n"a+1g_optionName[a])
            
len += copy(menu_msg[len], 255-lentemp)
            
keys |= (1<<a)


        }
        
        
format(menu_msg[len], 255-len"^n0.  %L"LANG_SERVER"NONE")

        
g_yesNoVote 0
    
}

    
    else
    {
        new 
lChangeMap[32], lYes[16], lNo[16]
        
        
format(lChangeMap31"%L"LANG_SERVER"CHANGE_MAP_TO")
        
format(lYes15"%L"LANG_SERVER"YES")
        
format(lNo15"%L"LANG_SERVER"NO")
        
format(menu_msg255g_coloredMenus "\y%s %s?\w^n^n1.  %s^n2.   %s" "%s %s?^n^n1.  %s^n2.  %s"lChangeMapg_optionName[0], lYes,  lNo)
        
keys MENU_KEY_1|MENU_KEY_2
        g_yesNoVote 
1
    
}
    
    new 
authid[32], name[32]
    
    
get_user_authid(idauthid31)
    
get_user_name(idname31)
    
    if (
argc == 2)
        
log_amx("Vote: ^"%s<%d><%s><>^" vote map (map  ^"%s^")"nameget_user_userid(id), authidg_optionName[0])
    else
        
log_amx("Vote: ^"%s<%d><%s><>^" vote maps  (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")"name,  get_user_userid(id), authidg_optionName[0], g_optionName[1],  g_optionName[2], g_optionName[3])

    new 
maxpl=get_maxplayers();
    new 
msg[256];
    for (new 
1<= maxpli++)
    {
        if (
is_user_connected(i) && !is_user_bot(i))
        {
            
// HACK: ADMIN_VOTE_MAP_{1,2} keys were designed very poorly.  Remove all : and %s in it.
            
LookupLangKey(msgcharsmax(msg), "ADMIN_VOTE_MAP_1"i);
            
replace_all(msgcharsmax(msg), "%s""");
            
replace_all(msgcharsmax(msg), ":""");
            
trim(msg);
            
show_activity_id(iidnamemsg);
        }
    }

    
g_execResult true
    
new Float:vote_time get_cvar_float("amx_vote_time") + 2.0
    
    set_cvar_float
("amx_last_voting"get_gametime() + vote_time)
    
g_voteRatio get_cvar_float("amx_votemap_ratio")
    
g_Answer "changelevel %s"
    
show_menu(0keysmenu_msgfloatround(vote_time), (g_validMaps 1) ? "Choose map: " "Change map to ")
    
set_task(vote_time"checkVotes"99889988)
    
g_voteCaller id
    console_print
(id"%L"id"VOTING_STARTED")
    
g_voteCount = {0000}
    
    return 
PLUGIN_HANDLED
}

public 
cmdVote(idlevelcid)
{
    if (!
cmd_access(idlevelcid4))
        return 
PLUGIN_HANDLED
    
    
new Float:voting get_cvar_float("amx_last_voting")
    if (
voting get_gametime())
    {
        
console_print(id"%L"id"ALREADY_VOTING")
        return 
PLUGIN_HANDLED
    
}
    
    if (
voting && voting get_cvar_float("amx_vote_delay") > get_gametime())
    {
        
console_print(id"%L"id"VOTING_NOT_ALLOW")
        return 
PLUGIN_HANDLED
    
}

    new 
quest[48]
    
read_argv(1quest47)
    
    if ((
contain(quest"sv_password") != -1) || (contain(quest"rcon_password") != -1) || (contain(quest"kick") != -1) || 
        (
contain(quest"addip") != -1) || (contain(quest"ban") != -1))
    {
        
console_print(id"%L"id"VOTING_FORBIDDEN")
        return 
PLUGIN_HANDLED
    
}
    
    new 
count=read_argc();

    for (new 
i=0;i<&& (i+2)<count;i++)
    {
        
read_argv(i+2g_optionName[i], sizeof(g_optionName[])-1);
    }

    new 
authid[32], name[32]
    
    
get_user_authid(idauthid31)
    
get_user_name(idname31)
    
log_amx("Vote: ^"%s<%d><%s><>^" vote custom  (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")"name,  get_user_userid(id), authidquestg_optionName[0], g_optionName[1])

    new 
maxpl=get_maxplayers();
    new 
msg[256];
    for (new 
1<= maxpli++)
    {
        if (
is_user_connected(i) && !is_user_bot(i))
        {
            
// HACK: ADMIN_VOTE_CUS_{1,2} keys were designed very poorly.  Remove all : and %s in it.
            
LookupLangKey(msgcharsmax(msg), "ADMIN_VOTE_CUS_1"i);
            
replace_all(msgcharsmax(msg), "%s""");
            
replace_all(msgcharsmax(msg), ":""");
            
trim(msg);
            
show_activity_id(iidnamemsg);
        }
    }

    new 
menu_msg[512], lVote[16]
    
    
format(lVote15"%L"LANG_SERVER"VOTE")
    
    
count-=2;
    if (
count>4)
    {
        
count=4;
    }
    
// count now shows how many options were listed
    
new keys=0;
    for (new 
i=0;i<count;i++)
    {
        
keys |= (1<<i);
    }
    
    new 
len=formatex(menu_msgsizeof(menu_msg)-1g_coloredMenus "\y%s: %s\w^n^n" "%s: %s^n^n"lVotequest);
    
    for (new 
i=0;i<count;i++)
    {
        
len+=formatex(menu_msg[len], sizeof(menu_msg) - len ,"%d.  %s^n",i+1,g_optionName[i]);
    }
    
g_execResult false
    
    
new Float:vote_time get_cvar_float("amx_vote_time") + 2.0
    
    set_cvar_float
("amx_last_voting"get_gametime() + vote_time)
    
g_voteRatio get_cvar_float("amx_vote_ratio")
    
replace_all(quest,sizeof(quest)-1,"%","");
    
format(g_Answer127"%s - %%s"quest)
    
show_menu(0keysmenu_msgfloatround(vote_time), "Vote: ")
    
set_task(vote_time"checkVotes"99889988)
    
g_voteCaller id
    console_print
(id"%L"id"VOTING_STARTED")
    
g_voteCount = {0000}
    
g_yesNoVote 0
    
    
return PLUGIN_HANDLED
}

public 
cmdVoteKickBan(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
    
    
new Float:voting get_cvar_float("amx_last_voting")
    if (
voting get_gametime())
    {
        
console_print(id"%L"id"ALREADY_VOTING")
        return 
PLUGIN_HANDLED
    
}

    if (
voting && voting get_cvar_float("amx_vote_delay") > get_gametime())
    {
        
console_print(id"%L"id"VOTING_NOT_ALLOW")
        return 
PLUGIN_HANDLED
    
}

    new 
cmd[32]
    
    
read_argv(0cmd31)
    
    new 
voteban equal(cmd"amx_voteban")
    new 
arg[32]
    
read_argv(1arg31)
    
    new 
player cmd_target(idargCMDTARGET_OBEY_IMMUNITY CMDTARGET_ALLOW_SELF)
    
    if (!
player)
        return 
PLUGIN_HANDLED
    
    
if (voteban && is_user_bot(player))
    {
        new 
imname[32]
        
        
get_user_name(playerimname31)
        
console_print(id"%L"id"ACTION_PERFORMED"imname)
        return 
PLUGIN_HANDLED
    
}

    new 
keys MENU_KEY_1|MENU_KEY_2
    
new menu_msg[256], lYes[16], lNo[16], lKickBan[16]
    
    
format(lYes15"%L"LANG_SERVER"YES")
    
format(lNo15"%L"LANG_SERVER"NO")
    
format(lKickBan15"%L"LANG_SERVERvoteban "BAN" "KICK")
    
ucfirst(lKickBan)
    
get_user_name(playerarg31)
    
format(menu_msg255g_coloredMenus "\y%s %s?\w^n^n1.  %s^n2.   %s" "%s %s?^n^n1.  %s^n2.  %s"lKickBanarglYeslNo)
    
g_yesNoVote 1
    
    
new bool:ipban=false;
    
    if (
voteban)
    {
        
get_user_authid(playerg_optionName[0], sizeof(g_optionName[])-1);
        
        
// Do the same check that's in plmenu to determine if this should be an IP ban instead
        
if (equal("4294967295"g_optionName[0])
            || 
equal("HLTV"g_optionName[0])
            || 
equal("STEAM_ID_LAN"g_optionName[0])
            || 
equali("VALVE_ID_LAN"g_optionName[0]))
        {
            
get_user_ip(playerg_optionName[0], sizeof(g_optionName[])-11);
            
            
ipban=true;
        }

    }
    else
    {
        
num_to_str(get_user_userid(player), g_optionName[0], 31)
    }
    
    new 
authid[32], name[32]
    
    
get_user_authid(idauthid31)
    
get_user_name(idname31)
    
log_amx("Vote: ^"%s<%d><%s><>^" vote %s (target  ^"%s^")"nameget_user_userid(id), authidvoteban "ban" "kick",  arg)

    new 
maxpl=get_maxplayers();
    new 
msg[256];
    new 
right[256];
    new 
dummy[1];
    for (new 
1<= maxpli++)
    {
        if (
is_user_connected(i) && !is_user_bot(i))
        {
            
formatex(lKickBancharsmax(lKickBan), "%L"ivoteban "BAN" "KICK");
            
            
// HACK: ADMIN_VOTE_FOR{1,2} keys are really weird.  Tokenize and ignore the text before the :
            
LookupLangKey(msgcharsmax(msg), "ADMIN_VOTE_FOR_1"i);
            
strtok(msgdummy0rightcharsmax(right), ':');
            
trim(right);
            
show_activity_id(iidnamerightlKickBanarg);
        }
    }

    
g_execResult true
    
    
new Float:vote_time get_cvar_float("amx_vote_time") + 2.0
    
    set_cvar_float
("amx_last_voting"get_gametime() + vote_time)
    
g_voteRatio get_cvar_float(voteban "amx_voteban_ratio" "amx_votekick_ratio")

    if (
voteban)
    {
        if (
ipban==true)
        {
            
g_Answer "addip 30.0 %s";
        }
        else
        {
            
g_Answer "banid 30.0 %s kick";

        }
    }
    else
    {
        
g_Answer "kick #%s";
    }
    
show_menu(0keysmenu_msgfloatround(vote_time), voteban "Ban " "Kick ")
    
set_task(vote_time"checkVotes"99889988)
    
g_voteCaller id
    console_print
(id"%L"id"VOTING_STARTED")
    
g_voteCount = {0000}
    
    return 
PLUGIN_HANDLED



Napoleon_be 11-18-2011 11:58

Re: Need help adminvote
 
I think it is already showing, try to change your amx_showactivity to "2" and it should work

daNzEt 11-19-2011 03:35

Re: Need help adminvote
 
No. It is not that. It is this side that shows:

PHP Code:

public voteCount(idkey)
{
    if (
get_cvar_num("amx_vote_answers"))
    {
        new 
name[32]
        
get_user_name(idname31)
        
        if (
g_yesNoVote)
            
client_print(0print_chat"%L"LANG_PLAYERkey "VOTED_AGAINST" "VOTED_FOR"name)
        else
            
client_print(0print_chat"%L"LANG_PLAYER"VOTED_FOR_OPT"namekey 1)
    }
    ++
g_voteCount[key]
    
    return 
PLUGIN_HANDLED


Code:

VOTED_FOR_OPT = %s voted for option #%d


Need to show

Code:

VOTED_FOR_OPT = %s voted for map %s (map name)



Evaldas.Grigas 11-19-2011 05:36

Re: Need help adminvote
 
Isn't that in lang folder? So you can edit what message is sent.

daNzEt 11-19-2011 08:41

Re: Need help adminvote
 
Quote:

Originally Posted by Evaldas.Grigas (Post 1598983)
Isn't that in lang folder? So you can edit what message is sent.


Lol dude :))

Do you think if i change the message from the lang text will show me witch map they choose ? I don't think. The worse idea i heard. Can't you see what i want ?!

Evaldas.Grigas 11-19-2011 09:55

Re: Need help adminvote
 
Lol. Change
for option
->
for map

daNzEt 11-20-2011 06:56

Re: Need help adminvote
 
Witch amx_showactivity to "2" you talk ?!
I don't understand what is the relation between amx_showactivity to "2" and what I want. That showactivity it's about showing message with ADMIN evalgas: vote map(s) or without admin ADMIN: vote map(s). Isn't what i want. Can't you understand it's about that message that appears to all with what map they chose from the vote.
Like mapchooser when you chose the map look at all the map you choose.

It's about something like this but i am not sure.

Error compile on line
PHP Code:

ArrayGetString(g_optionNameg_optionName[key], mapcharsof(map)); 

PHP Code:


public voteCount(idkey)
{
        if ( 
get_cvar_num"amx_vote_answers" ) )
        {
        new 
name[32]
        
get_user_nameidname31 )
        
        if ( 
g_yesNoVote )
        {
            
chat_color0"%L"LANG_PLAYERkey "VOTED_AGAINST" "VOTED_FOR"name )
        }

        else
        {
                    new 
map[32];
                    
ArrayGetString(g_optionNameg_optionName[key], mapcharsof(map));
                    
client_print(0print_chat"%s choose map %s"namemap);
        }
        }

        ++
g_voteCount[key]
    
        return 
PLUGIN_HANDLED



daNzEt 11-22-2011 12:46

Re: Need help adminvote
 
CAN SOMEONE HELP ME WITH THIS PLUGIN !???????????


All times are GMT -4. The time now is 08:33.

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