|
|
Linia 1: |
Linia 1: |
− | {{Box Code|Local Mail|
| + | <categorytree>HLDS</categorytree> |
− | <pre> | + | |
− | emerge postfix && rc-update add postfix default
| + | |
− | nano -w /etc/postfix/main.cf
| + | |
− | postfix upgrade-configuration
| + | |
− | postfix check
| + | |
− | nano -w /etc/mail/aliases
| + | |
− | newaliases
| + | |
− | </pre>
| + | |
− | }}
| + | |
− | | + | |
− | | + | |
− | = do not read below, testing area=
| + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | <poll>
| + | |
− | Question
| + | |
− | Answer 1
| + | |
− | Asnwer 2
| + | |
− | ...
| + | |
− | Answer n
| + | |
− | </poll>
| + | |
− | | + | |
− | | + | |
− | <poll>
| + | |
− | STATS
| + | |
− | </poll>
| + | |
− | | + | |
− | | + | |
− | <randomimage size="100">HA!</randomimage>
| + | |
− | | + | |
− | | + | |
− | {{extension
| + | |
− | |name = RandomText
| + | |
− | |image =
| + | |
− | |type = Parser extension
| + | |
− | |maturity = Beta
| + | |
− | |mediawiki = 1.6.5 and higher
| + | |
− | |version = 0.1
| + | |
− | |update = 2006-05-13
| + | |
− | |description = Inserting random text in a page
| + | |
− | }}
| + | |
− | | + | |
− | | + | |
− | dupa!
| + | |
− | | + | |
− | | + | |
− | | + | |
− | ==Baaa==
| + | |
− | | + | |
− | Each task must be on its own line and start with [ ]. All the tasks must be grouped with a
| + | |
− | | + | |
− | <task>
| + | |
− | [ ] Regular task (Owner User)
| + | |
− | [1] High priority task
| + | |
− | [2] Medium priority task
| + | |
− | [3] Low priority task (Owner User)
| + | |
− | [!] Urgent task
| + | |
− | [x] Closed task
| + | |
− | </task>
| + | |
− | | + | |
− | According to the regular expression, owner parsing doesn't work when there is a dot after ')'. e.g. [ ] Regular task (Owner User) works fine, but [ ] Regular task (Owner User). works not right.
| + | |
− | | + | |
− | The tasks tag may have an optional parameter, called hidden, which hides the tasks from being viewed. To use it you would write the beginning tasks tag like < tasks hidden >.
| + | |
− | | + | |
− | | + | |
− | [[#jakis]]
| + | |
− | | + | |
− | #jakis
| + | |
− | | + | |
− | =SMA=
| + | |
− | | + | |
− | <sma>
| + | |
− | new const PLUGINNAME[] = "Vote Access"
| + | |
− | new const VERSION[] = "0.4m"
| + | |
− | new const AUTHOR[] = "JGHG"
| + | |
− | /*
| + | |
− | Copyleft 2003 by Johnny got his gun
| + | |
− | http://amxmod.net/forums/viewtopic.php?t=16984
| + | |
− | | + | |
− | Requires AMX Mod X Mod 1.71 or newer.
| + | |
− | | + | |
− | VOTE ACCESS
| + | |
− | ===========
| + | |
− | This plugin lets you add ability for your users to start votes on activation/deactivation of
| + | |
− | otherwise vote-systemless plugins (like my Weapon Arena plugin, example below).
| + | |
− | Actually, it doesn't have to be an AMX Mod plugin command, it can be any command/cvar
| + | |
− | accessible through server console. So you can makes votes to start/stop/change
| + | |
− | plugins/commands/cvars/whatever with this baby.
| + | |
− | | + | |
− | This leads to two things:
| + | |
− | - Server admins can add voting ability to any cvar/plugin/server command like stated above,
| + | |
− | without crying to the plugin author for an update with a vote feature.
| + | |
− | - Plugin authors don't need to do a voting system for their plugins ever more.
| + | |
− | They can just tell admins to use this plugin for their voting needs.
| + | |
− | | + | |
− | | + | |
− | USAGE
| + | |
− | =====
| + | |
− | | + | |
− | * amx_voteaccess <trigger [@s]> <question> <Option 1> <Command 1> <Option 2> <Command 2>
| + | |
− | - note: if you add " @s" in trigger, a parameter is expected. That parameter will replace all @s:s you specify in question, options and commands.
| + | |
− | * amx_voteaccessbreak
| + | |
− | * amx_voteaccessmenu
| + | |
− | - note: votes where parameters are expected will NOT show in this menu, you have to activate them the normal way through chat.
| + | |
− | | + | |
− | Put the command amx_voteaccess in a file that is executed every map start like this (example):
| + | |
− | | + | |
− | amx_voteaccess "weaponarena" "Weapon Arena?" "Yes please" "amx_weaponarena random" "No thank you" "amx_weaponarena off"
| + | |
− | This will add the ability for your users of saying "vote weaponarena", and a vote menu will show to all
| + | |
− | players (not bots), like this in this case:
| + | |
− | | + | |
− | Time to choose!
| + | |
− | | + | |
− | Weapon Arena?
| + | |
− | | + | |
− | 1. Yes please
| + | |
− | 2. No thank you
| + | |
− | | + | |
− | And after VOTETIME (normally 15 seconds) the results of the voting will be summed up, and
| + | |
− | if either side won, that command will get executed on server console. If 1. wins, it will execute
| + | |
− | in this case "amx_weaponarena random". If 2 wins, "amx_weaponarena off" will get executed.
| + | |
− | If no one votes within time, no command will be executed, this is also true if the results are exactly equal.
| + | |
− | | + | |
− | The command amx_voteaccessbreak breaks an ongoing voting. It can be used by server console, or by a client
| + | |
− | with ADMIN_VOTE access.
| + | |
− | | + | |
− | This plugin uses the following cvars that are by default already set with AMX:
| + | |
− | amx_vote_time - time in seconds until votes are counted and winning command executed.
| + | |
− | amx_vote_answers - set this to 1 to display who votes for what.
| + | |
− | amx_vote_delay - time in seconds that must pass between two votings. Note that admin
| + | |
− | can use the amx_voteaccessmenu to call new votes as often has he want. :-)
| + | |
− | | + | |
− | More examples:
| + | |
− | | + | |
− | amx_voteaccess "slap @s" "Slap @s?" "Yes! Slap @s sooo hard! :-)" "amx_slap @s" "No please don't slap @s!" ""
| + | |
− | | + | |
− | User should type in game: "vote slap campinglamer", and then there will be a vote: "Slap campinglamer?"....
| + | |
− | By using @s (_exactly_ as written above, with a space between the trigger and @s) this means that this trigger must take a variable.
| + | |
− | Then you can insert @s in any question, option command or option description, and it will be replaced with the parameter the user typed.
| + | |
− | | + | |
− | amx_voteaccess "ff" "Enable friendly fire?" "Yeah >:-)" "mp_friendlyfire 1" "Hell no!" "mp_friendlyfire 0"
| + | |
− | If you don't specify @s, there will be an error in this case if you try "vote ff on" cause there shouldn't be a parameter here.
| + | |
− | Same if you forget to type a parameter where one is needed, an error will be displayed.
| + | |
− | | + | |
− | Releases:
| + | |
− | 2003-06-23 version 0.1:
| + | |
− | First version
| + | |
− | | + | |
− | 2003-06-24 version 0.2:
| + | |
− | New command is amx_voteaccessmenu - any client with ADMIN_VOTE
| + | |
− | access can access the menu, which contains all the votings stored
| + | |
− | with amx_voteaccess command.
| + | |
− | | + | |
− | amx_voteaccessbreak
| + | |
− | Changed this command's access level to ADMIN_VOTE.
| + | |
− | | + | |
− | 2003-06-27 version 0.3:
| + | |
− | If you have one of my other plugins, Chat Responder,
| + | |
− | the trigger will automatically be added to Chat Responder's
| + | |
− | list of words it will hear. If someone type that trigger
| + | |
− | without using the "vote" part before it, Chat Responder will
| + | |
− | respond with that you can initiate a vote on that by typing
| + | |
− | "vote <trigger>".
| + | |
− | | + | |
− | Now uses the following cvars for controlling different things:
| + | |
− | amx_vote_time - The time in seconds until votes are counted and command
| + | |
− | executed.
| + | |
− | amx_vote_answers - Set this to 1 to display what each client
| + | |
− | votes for.
| + | |
− | amx_vote_delay - Time in seconds that must pass between votes.
| + | |
− | Admin can still call up new votes whenever he wants with
| + | |
− | amx_voteaccessmenu.
| + | |
− | Note that these cvars are default with AMX, so you have them
| + | |
− | probably already set.
| + | |
− | | + | |
− | 2003-07-29 version 0.3.1:
| + | |
− | Minor tweak. Will now count votes as soon as everyone voted.
| + | |
− | You will also get a message of voting to late if you do.
| + | |
− | | + | |
− | 2003-07-29 version 0.3.2:
| + | |
− | "Time to choose" sound of gman is added.
| + | |
− | | + | |
− | 2004-03-12 version 0.4:
| + | |
− | Added variables.
| + | |
− | | + | |
− | 2005-04-25 version 0.4k: (by _KaszpiR_)
| + | |
− | Removed option for strict number of parameter when using @s
| + | |
− | what it does?
| + | |
− | let take the example from top about slapping
| + | |
− | normally there could be only taken one parameter that was a user name
| + | |
− | now if you add any text after a name it will be passed further
| + | |
− | | + | |
− | Added server side command
| + | |
− | amx_voterun word
| + | |
− | to initiate the voting, useful in scripts to run on hlds.
| + | |
− | That means the general usage of plugin is exackly as before, but it is extended
| + | |
− | to also accept hlds console command amx_voterun.
| + | |
− | You can use the @s variables as before!
| + | |
− | | + | |
− | let say you have such a script in amx.cfg
| + | |
− |
| + | |
− | alias restart_yes "amx_tsay Restart;sv_restart 4"
| + | |
− | alias restart_no "amx_tsay Keep Playing"
| + | |
− | amx_voteaccess "rr" "Restart?" "Yes" "restart_yes" "No" "restart_no"
| + | |
− | | + | |
− | players then can say
| + | |
− | vote rr
| + | |
− | and initiate votingfor restart
| + | |
− |
| + | |
− | from now on in server in amx.cfg you can use
| + | |
− | amx_voterun rr
| + | |
− | to initiate the same voting!
| + | |
− | | + | |
− | in more advanced scripts using in examle amx_task you can use it like this
| + | |
− | amx_task 2 "amx_voterun rr" m
| + | |
− | and this will initiate the voting on 2 minutes after map start
| + | |
− | | + | |
− | so now you can use the aliases in scripts and you probably gonna end with less
| + | |
− | amx plugins than before if you use amx_task and amx_loop :D
| + | |
− | | + | |
− | | + | |
− | some other examples
| + | |
− | for amx roundshedule (amx_roundtask)
| + | |
− | amx_voteaccess "swapteams" "Swap Teams?" "Yes" "amx_swapteams" "No" "say Vote Failed."
| + | |
− | amx_roundtask 13 "amx_voterun swapteams" a
| + | |
− | | + | |
− | for amx_match_deluxe (or most of match systems
| + | |
− | amx_voteaccess "match @s" "Start Match @s ?" "Yes" "amx_match @s" "No, keep FFA mode" "say Vote Failed. Keep Playing FFA"
| + | |
− | amx_voteaccess "notagmatch @s" "Start Match @s ?" "Yes" "amx_match2 @s" "No, keep FFA mode" "say Vote Failed. Keep Playing FFA"
| + | |
− | | + | |
− | and now you can use as client
| + | |
− | say vote match CTTag TerrTag mr12 configname [recdemo|recboth|rechltv]
| + | |
− | say vote notagmatch mr12 configname [recdemo|recboth|rechltv]
| + | |
− | and on server you can use
| + | |
− | amx_voterun match CTTag TerrTag mr12 configname [recdemo|recboth|rechltv]
| + | |
− | amx_voterun notagmatch mr12 configname [recdemo|recboth|rechltv]
| + | |
− | | + | |
− | 2005-04-25 version 0.4l: (by _KaszpiR_)
| + | |
− | changed ADMIN_VOTE to ADMIN_USER
| + | |
− | in default amxmod configuration user has ability to use amx_votemenu - and there are soem things that are too strong for him
| + | |
− | so i modded it that normal user has 'z' flag (ADMIN_USER) so i can preciselycontrol his abilites
| + | |
− | 2006-03-03 version 0.4m: (by _KaszpiR_)
| + | |
− | workaround for different amx get plugins under AMx Mod X
| + | |
− | | + | |
− | TO DO
| + | |
− | =====
| + | |
− | Translation support
| + | |
− | Vote Menu fix - the parametered votes are skipped but they take out the menu positions
| + | |
− | Make it possible to have more than two options.
| + | |
− | | + | |
− | */
| + | |
− | | + | |
− | #include <amxmod>
| + | |
− | #include <amxmisc>
| + | |
− | | + | |
− | // Globals below
| + | |
− | #define MAXVOTES 128
| + | |
− | #define TRIGGERLENGTH 64
| + | |
− | #define QUESTIONLENGTH 64
| + | |
− | #define OPTIONTEXTLENGTH 64
| + | |
− | #define VARIABLELENGTH 64
| + | |
− | #define OPTIONLENGTH 64
| + | |
− | #define VOTETASKID 135
| + | |
− | | + | |
− | new g_votesCount
| + | |
− | new triggers[MAXVOTES][TRIGGERLENGTH]
| + | |
− | new questions[MAXVOTES][QUESTIONLENGTH]
| + | |
− | new optiontext1[MAXVOTES][OPTIONTEXTLENGTH]
| + | |
− | new option1[MAXVOTES][OPTIONLENGTH]
| + | |
− | new optiontext2[MAXVOTES][OPTIONTEXTLENGTH]
| + | |
− | new option2[MAXVOTES][OPTIONLENGTH]
| + | |
− | new option1result, option2result
| + | |
− | new bool:voteInProgress = false
| + | |
− | new idpage[33]
| + | |
− | new bool:delay = false
| + | |
− | new g_votingPlayers
| + | |
− | new g_currentVote
| + | |
− | new g_variable[VARIABLELENGTH] = "ERROR_INITIALVARIABLE"
| + | |
− | new bool:g_hasVariable
| + | |
− | new const VARIABLE[] = "@s"
| + | |
− | new const VARIABLEWITHSPACE[] = " @s"
| + | |
− | // Globals above
| + | |
− | | + | |
− | public addvoteaccess() {
| + | |
− | if (read_argc() != 7) {
| + | |
− | server_print("Error, usage: amx_voteaccess ^"Trigger^" ^"Question^" ^"Option text 1^" ^"Option command 1^" ^"Option text 2^" ^"Option command 2^"")
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | new argLine[256]
| + | |
− | read_args(argLine,255)
| + | |
− | | + | |
− | if (g_votesCount >= MAXVOTES) {
| + | |
− | server_print("[Vote Access] Error: You have too many votes already stored. Will not add another. (%s)",argLine)
| + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | | + | |
− | // Trigger must be unique.
| + | |
− | new trigger[TRIGGERLENGTH]
| + | |
− | parse(argLine,trigger,TRIGGERLENGTH - 1)
| + | |
− | for (new i = 0;i < g_votesCount;i++) {
| + | |
− | if (equali(triggers[i],trigger)) {
| + | |
− | server_print("[Vote Access] Error: Trigger ^"%s^" already exists.",triggers[i])
| + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | parse(argLine,triggers[g_votesCount],TRIGGERLENGTH - 1,questions[g_votesCount],QUESTIONLENGTH - 1,optiontext1[g_votesCount],OPTIONTEXTLENGTH - 1,option1[g_votesCount],OPTIONLENGTH,optiontext2[g_votesCount],OPTIONTEXTLENGTH - 2,option2[g_votesCount],OPTIONLENGTH)
| + | |
− | for (new i = 0, pluginName[30], pluginsCount = get_pluginsnum(), bool:foundCR = false;i < pluginsCount && !foundCR;++i) {
| + | |
− | get_plugin(i,"",0,pluginName,29,"",0,"",0,"",0)
| + | |
− | | + | |
− | //server_print("Plugin: %s",pluginName)
| + | |
− | if (equal("Chat Responder",pluginName)) {
| + | |
− | foundCR = true
| + | |
− | //server_print("Found Chat Responder on i = %d! Adding trigger to responder...",i)
| + | |
− | server_cmd("amx_chatrespond ^"%s^" ^"Did you know you can say 'vote %s' to init a vote for: %s^"",triggers[g_votesCount],triggers[g_votesCount],questions[g_votesCount])
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | //server_print("Successfully added this to Vote Access: Trigger: %s Question: %s Option text 1: %s Option command 1: %s Option text 2: %s Option command 2: %s",triggers[g_votesCount],questions[g_votesCount],optiontext1[g_votesCount],option1[g_votesCount],optiontext2[g_votesCount],option2[g_votesCount])
| + | |
− | | + | |
− | g_votesCount++
| + | |
− | | + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | | + | |
− | public check_say(id) {
| + | |
− | const SAYLINELEN = 100
| + | |
− | new sayline[SAYLINELEN]
| + | |
− | read_argv(1,sayline,SAYLINELEN - 1)
| + | |
− | | + | |
− | new saylineLen = strlen(sayline)
| + | |
− | | + | |
− | if (contain(sayline,";")!=-1) {
| + | |
− | // small fix to avoid abusing say "vote slap john;rcon_password cheat"
| + | |
− | debugprint("Forbidden char found. Aborting.",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | // Too short? Quit.
| + | |
− | if (saylineLen < 6) {
| + | |
− | //debugprint("Too short",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | new firstFive[6]
| + | |
− | copy(firstFive,5,sayline)
| + | |
− | | + | |
− | // Quit if not starting with "vote "
| + | |
− | if (!equali(firstFive,"vote ")) {
| + | |
− | //debugprint("Doesn't begin with ^"vote ^"",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | if (voteInProgress) {
| + | |
− | debugprint("A vote is already in progress.",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | if (delay) {
| + | |
− | debugprint("Voting not allowed yet. Too close to previous voting.",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | // Get 2nd parameter
| + | |
− | new zndParam[32], thirdParam[VARIABLELENGTH], triggerCopy[TRIGGERLENGTH]
| + | |
− | new fourParam[VARIABLELENGTH], fiveParam[VARIABLELENGTH], sixParam[VARIABLELENGTH], sevenParam[VARIABLELENGTH], eightParam[VARIABLELENGTH]
| + | |
− | // one two three four five six seven eight
| + | |
− | // vote match cT Ter mr12 cb recboth
| + | |
− |
| + | |
− | new parsedParams = parse(sayline, firstFive, 4, zndParam, 31, thirdParam, VARIABLELENGTH - 1,fourParam, VARIABLELENGTH - 1,fiveParam, VARIABLELENGTH - 1,sixParam, VARIABLELENGTH - 1,sevenParam, VARIABLELENGTH - 1,eightParam, VARIABLELENGTH - 1 )
| + | |
− | // Match 2nd parameter against triggers, case ignoring. 2nd paramter should also match against triggers containing VARIABLEWITHSPACE, so remove that as long as it exists.
| + | |
− | for (new i = 0; i < g_votesCount; i++) {
| + | |
− | copy(triggerCopy, TRIGGERLENGTH - 1, triggers[i])
| + | |
− | g_hasVariable = false
| + | |
− | while (contain(triggerCopy, VARIABLEWITHSPACE) != -1) {
| + | |
− | replace(triggerCopy, TRIGGERLENGTH - 1, VARIABLEWITHSPACE, "")
| + | |
− | if (!g_hasVariable)
| + | |
− | g_hasVariable = true
| + | |
− | }
| + | |
− | | + | |
− | if (equal(triggerCopy, zndParam)) {
| + | |
− | //debugprint("%d matches!",i)
| + | |
− | | + | |
− | if (g_hasVariable && parsedParams < 3) {
| + | |
− | client_print(id, print_chat, "Error in syntax. Specify parameters after ^"%s^".", triggerCopy)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | else if (!g_hasVariable && parsedParams > 2) {
| + | |
− | client_print(id, print_chat, "Error in syntax. Don't specify any parameters after ^"%s^".", triggerCopy)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− |
| + | |
− | copy(g_variable, VARIABLELENGTH - 1, thirdParam)
| + | |
− | // i know below is nasty but at least quite easyand working
| + | |
− | if(strlen(fourParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,fourParam)
| + | |
− | if(strlen(fiveParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,fiveParam)
| + | |
− | if(strlen(sixParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,sixParam)
| + | |
− | if(strlen(sevenParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,sevenParam)
| + | |
− | if(strlen(eightParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,eightParam)
| + | |
− |
| + | |
− | g_currentVote = i
| + | |
− | voteInProgress = true
| + | |
− | startVote()
| + | |
− | | + | |
− | break
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | startVote() {
| + | |
− | client_cmd(0, "spk Gman/Gman_Choose2")
| + | |
− | new i = g_currentVote
| + | |
− | option1result = 0
| + | |
− | option2result = 0
| + | |
− | new menuBody[512]
| + | |
− | | + | |
− | new questionCopy[QUESTIONLENGTH]
| + | |
− | copy(questionCopy, QUESTIONLENGTH - 1, questions[i])
| + | |
− | | + | |
− | new optiontext1copy[OPTIONTEXTLENGTH]
| + | |
− | copy(optiontext1copy, OPTIONTEXTLENGTH - 1, optiontext1[i])
| + | |
− | | + | |
− | new optiontext2copy[OPTIONTEXTLENGTH]
| + | |
− | copy(optiontext2copy, OPTIONTEXTLENGTH - 1, optiontext2[i])
| + | |
− | | + | |
− | if (g_hasVariable) {
| + | |
− | while(contain(questionCopy, VARIABLE) != -1)
| + | |
− | replace(questionCopy, QUESTIONLENGTH - 1, VARIABLE, g_variable)
| + | |
− | while(contain(optiontext1copy, VARIABLE) != -1)
| + | |
− | replace(optiontext1copy, OPTIONTEXTLENGTH - 1, VARIABLE, g_variable)
| + | |
− | while(contain(optiontext2copy, VARIABLE) != -1)
| + | |
− | replace(optiontext2copy, OPTIONTEXTLENGTH - 1, VARIABLE, g_variable)
| + | |
− | }
| + | |
− | | + | |
− | new len = format(menuBody, 511, "\yTime to choose!\R^n^n%s^n^n\w", questionCopy)
| + | |
− | len += format(menuBody[len], 511 - len, "1. %s^n2. %s", optiontext1copy, optiontext2copy)
| + | |
− | new players[32], playersNum
| + | |
− | // Don't show to bots
| + | |
− | get_players(players,playersNum,"c")
| + | |
− | | + | |
− | for (new j = 0;j < playersNum;j++)
| + | |
− | show_menu(players[j],((1<<0)|(1<<1)),menuBody)
| + | |
− | | + | |
− | g_votingPlayers = playersNum
| + | |
− | new bool:param[1]
| + | |
− | param[0] = true
| + | |
− | set_task(get_cvar_float("amx_vote_time"),"checkvotes",VOTETASKID,param,1)
| + | |
− | }
| + | |
− | | + | |
− | public checkvotes(bool:timesUp[]) {
| + | |
− | if (timesUp[0]) {
| + | |
− | client_print(0,print_chat,"Time is up! Not everyone voted, but here is the result:")
| + | |
− | server_print("Time is up! Not everyone voted, but here is the result:")
| + | |
− | }
| + | |
− | | + | |
− | voteInProgress = false
| + | |
− | delay = true
| + | |
− | set_task(get_cvar_float("amx_vote_delay"),"delayOff")
| + | |
− | | + | |
− | new totalVotes = option1result + option2result
| + | |
− | if (totalVotes == 0) {
| + | |
− | debugprint("No one voted, will not do anything.",0)
| + | |
− | return
| + | |
− | }
| + | |
− | | + | |
− | new i = g_currentVote
| + | |
− | | + | |
− | new questionCopy[QUESTIONLENGTH], optiontext1copy[OPTIONTEXTLENGTH], optiontext2copy[OPTIONTEXTLENGTH], optioncopy[OPTIONLENGTH]
| + | |
− | copy(questionCopy, QUESTIONLENGTH - 1, questions[i])
| + | |
− | copy(optiontext1copy, OPTIONTEXTLENGTH - 1, optiontext1[i])
| + | |
− | copy(optiontext2copy, OPTIONTEXTLENGTH - 1, optiontext2[i])
| + | |
− | | + | |
− | if (g_hasVariable) {
| + | |
− | while(contain(questionCopy, VARIABLE) != -1)
| + | |
− | replace(questionCopy, QUESTIONLENGTH - 1, VARIABLE, g_variable)
| + | |
− | while(contain(optiontext1copy, VARIABLE) != -1)
| + | |
− | replace(optiontext1copy, OPTIONTEXTLENGTH - 1, VARIABLE, g_variable)
| + | |
− | while(contain(optiontext2copy, VARIABLE) != -1)
| + | |
− | replace(optiontext2copy, OPTIONTEXTLENGTH - 1, VARIABLE, g_variable)
| + | |
− | }
| + | |
− | | + | |
− | client_print(0,print_chat,"Voting result: Option 1 (%s) got %d votes, option 2 (%s) got %d votes.",optiontext1copy,option1result,optiontext2copy,option2result)
| + | |
− | server_print("Voting result: Option 1 (%s) got %d votes, option 2 (%s) got %d votes.",optiontext1copy,option1result,optiontext2copy,option2result)
| + | |
− | | + | |
− | if (option1result == option2result) {
| + | |
− | client_print(0,print_chat,"Even score! Will not touch anything.")
| + | |
− | server_print("Even score! Will not touch anything.")
| + | |
− | }
| + | |
− | else if (option1result > option2result) {
| + | |
− | client_print(0, print_chat, "Executing %s: %s.", questionCopy, optiontext1copy)
| + | |
− | server_print("Executing %s: %s.", questionCopy, optiontext1copy)
| + | |
− | | + | |
− | copy(optioncopy, OPTIONLENGTH - 1, option1[i])
| + | |
− | if (g_hasVariable) {
| + | |
− | while(contain(optioncopy, VARIABLE) != -1)
| + | |
− | replace(optioncopy, OPTIONLENGTH - 1, VARIABLE, g_variable)
| + | |
− | }
| + | |
− | | + | |
− | //server_print("executing ^"%s^" because of Vote Access", optioncopy)
| + | |
− | //client_print(0, print_chat, "executing ^"%s^" because of Vote Access", optioncopy)
| + | |
− | server_cmd("%s", optioncopy)
| + | |
− | }
| + | |
− | else {
| + | |
− | client_print(0, print_chat, "Executing %s: %s.", questionCopy, optiontext2copy)
| + | |
− | | + | |
− | copy(optioncopy, OPTIONLENGTH - 1, option2[i])
| + | |
− | if (g_hasVariable) {
| + | |
− | while(contain(optioncopy, VARIABLE) != -1)
| + | |
− | replace(optioncopy, OPTIONLENGTH - 1, VARIABLE, g_variable)
| + | |
− | }
| + | |
− | | + | |
− | //server_print("executing ^"%s^" because of Vote Access", optioncopy)
| + | |
− | //client_print(0, print_chat, "executing ^"%s^" because of Vote Access", optioncopy)
| + | |
− | server_cmd("%s", optioncopy)
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | public handlemenu(id,key) {
| + | |
− | if (!voteInProgress) {
| + | |
− | client_print(id,print_chat,"Your vote is too late.")
| + | |
− | return
| + | |
− | }
| + | |
− | | + | |
− | switch(key) {
| + | |
− | case 0: {
| + | |
− | option1result++
| + | |
− | }
| + | |
− | case 1: {
| + | |
− | option2result++
| + | |
− | }
| + | |
− | }
| + | |
− | new name[32]
| + | |
− | get_user_name(id,name,31)
| + | |
− | if (get_cvar_num("amx_vote_answers") == 1) {
| + | |
− | client_print(0,print_chat,"%s voted for option %d.",name,key + 1)
| + | |
− | }
| + | |
− | | + | |
− | server_print("%s voted for option %d.",name,key + 1)
| + | |
− | | + | |
− | if (option1result + option2result == g_votingPlayers) {
| + | |
− | if (task_exists(VOTETASKID))
| + | |
− | remove_task(VOTETASKID)
| + | |
− | | + | |
− | client_print(0,print_chat,"Everyone voted. Counting votes...")
| + | |
− | | + | |
− | new bool:param[1]
| + | |
− | param[0] = false
| + | |
− | set_task(3.0,"checkvotes",0,param,1)
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | public breakvote(id,level,cid) {
| + | |
− | if (!cmd_access(id,level,cid,1)) {
| + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | | + | |
− | remove_task(VOTETASKID)
| + | |
− | voteInProgress = false
| + | |
− | debugprint("Admin has cancelled the current vote.",0)
| + | |
− | | + | |
− | delay = true
| + | |
− | set_task(get_cvar_float("amx_vote_delay"),"delayOff")
| + | |
− | | + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | | + | |
− | public delayOff() {
| + | |
− | delay = false
| + | |
− | }
| + | |
− | | + | |
− | public debugprint(message[],value) {
| + | |
− | server_print(message,value)
| + | |
− | client_print(0,print_chat,message,value)
| + | |
− | }
| + | |
− | | + | |
− | public votemenu(id,level,cid) {
| + | |
− | if (!cmd_access(id,level,cid,1)) {
| + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | | + | |
− | showvotemenu(id,0)
| + | |
− | | + | |
− | return PLUGIN_HANDLED
| + | |
− | }
| + | |
− | | + | |
− | showvotemenu(id,page) {
| + | |
− | idpage[id] = page
| + | |
− | | + | |
− | new menuBody[512]
| + | |
− | new len = format(menuBody,511,"\yVote Access votes:\R^n^n\w")
| + | |
− | | + | |
− | // Back/quit flag
| + | |
− | new flags = (1<<9)
| + | |
− | | + | |
− | new i
| + | |
− | for (i = 0;i < 8 && i < g_votesCount - (page * 8);i++) {
| + | |
− | if (contain(triggers[i + page * 8], VARIABLEWITHSPACE) != -1) // don't display votes using variables in menu (has to be typed...)
| + | |
− | continue
| + | |
− | len += format(menuBody[len],511 - len,"%d. %s^n",i + 1,questions[i + page * 8])
| + | |
− | flags += (1<<i)
| + | |
− | }
| + | |
− | if (g_votesCount > (page + 1) * 8) {
| + | |
− | len += format(menuBody[len],511 - len,"^n9. Next page")
| + | |
− | flags += (1<<8)
| + | |
− | }
| + | |
− | if (page == 0)
| + | |
− | len += format(menuBody[len],511 - len,"^n0. Quit^n")
| + | |
− | else
| + | |
− | len += format(menuBody[len],511 - len,"^n0. Previous page^n")
| + | |
− | | + | |
− | show_menu(id,flags,menuBody)
| + | |
− | }
| + | |
− | | + | |
− | public handleadminmenu(id,key) {
| + | |
− | switch (key) {
| + | |
− | case 8: {
| + | |
− | // Next page
| + | |
− | showvotemenu(id,++idpage[id])
| + | |
− | }
| + | |
− | case 9: {
| + | |
− | // Exit/back page
| + | |
− | if (idpage[id] != 0)
| + | |
− | showvotemenu(id,--idpage[id])
| + | |
− | }
| + | |
− | default: {
| + | |
− | if (voteInProgress) {
| + | |
− | debugprint("A vote is already in progress.",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | voteInProgress = true
| + | |
− | g_currentVote = key + (idpage[id] * 8)
| + | |
− | startVote()
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | public plugin_init() {
| + | |
− | register_plugin(PLUGINNAME, VERSION, AUTHOR)
| + | |
− | register_clcmd("say","check_say")
| + | |
− | register_clcmd("say_team","check_say")
| + | |
− | register_srvcmd("amx_voteaccess","addvoteaccess",0,": add ability to vote for stuff :-)")
| + | |
− | register_menucmd(register_menuid("Time to choose!"),1023,"handlemenu")
| + | |
− | register_menucmd(register_menuid("Vote Access votes"),1023,"handleadminmenu")
| + | |
− | register_concmd("amx_voteaccessbreak","breakvote",ADMIN_VOTE,": breaks an ongoing Vote Access vote")
| + | |
− | register_clcmd("amx_voteaccessmenu","votemenu",ADMIN_USER,": displays a menu of possible votes to start")
| + | |
− | register_srvcmd("amx_voterun","vote_run",0,"<parameter> - run the vote without the need of players")
| + | |
− | | + | |
− | if (!cvar_exists("amx_vote_time"))
| + | |
− | register_cvar("amx_vote_time","60")
| + | |
− | if (!cvar_exists("amx_vote_answers"))
| + | |
− | register_cvar("amx_vote_answers","1")
| + | |
− | if (!cvar_exists("amx_vote_delay"))
| + | |
− | register_cvar("amx_vote_delay","60")
| + | |
− | }
| + | |
− | | + | |
− | public vote_run() {
| + | |
− | // the same as check_say but it does not require 'vote ' text at the beginning
| + | |
− | const SAYLINELEN = 100
| + | |
− | new sayline[SAYLINELEN]
| + | |
− | read_argv(1,sayline,SAYLINELEN - 1)
| + | |
− | | + | |
− | if (voteInProgress) {
| + | |
− | debugprint("A vote is already in progress.",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | if (delay) {
| + | |
− | debugprint("Voting not allowed yet. Too close to previous voting.",0)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | // Get 2nd parameter
| + | |
− | new zndParam[32], thirdParam[VARIABLELENGTH], triggerCopy[TRIGGERLENGTH]
| + | |
− | new fourParam[VARIABLELENGTH], fiveParam[VARIABLELENGTH], sixParam[VARIABLELENGTH], sevenParam[VARIABLELENGTH], eightParam[VARIABLELENGTH]
| + | |
− | // one two three four five six seven eight
| + | |
− | // vote match cT Ter mr12 cb recboth
| + | |
− |
| + | |
− | new parsedParams = parse(sayline,zndParam, 31, thirdParam, VARIABLELENGTH - 1,fourParam, VARIABLELENGTH - 1,fiveParam, VARIABLELENGTH - 1,sixParam, VARIABLELENGTH - 1,sevenParam, VARIABLELENGTH - 1,eightParam, VARIABLELENGTH - 1 )
| + | |
− | // Match 2nd parameter against triggers, case ignoring. 2nd paramter should also match against triggers containing VARIABLEWITHSPACE, so remove that as long as it exists.
| + | |
− | for (new i = 0; i < g_votesCount; i++) {
| + | |
− | copy(triggerCopy, TRIGGERLENGTH - 1, triggers[i])
| + | |
− | g_hasVariable = false
| + | |
− | while (contain(triggerCopy, VARIABLEWITHSPACE) != -1) {
| + | |
− | replace(triggerCopy, TRIGGERLENGTH - 1, VARIABLEWITHSPACE, "")
| + | |
− | if (!g_hasVariable)
| + | |
− | g_hasVariable = true
| + | |
− | }
| + | |
− | | + | |
− | if (equal(triggerCopy, zndParam)) {
| + | |
− | //debugprint("%d matches!",i)
| + | |
− | | + | |
− | if (g_hasVariable && parsedParams < 2) {
| + | |
− | server_print("Error in syntax. Specify parameters after ^"%s^".", triggerCopy)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | else if (!g_hasVariable && parsedParams > 1) {
| + | |
− | server_print("Error in syntax. Don't specify any parameters after ^"%s^".", triggerCopy)
| + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | | + | |
− | copy(g_variable, VARIABLELENGTH - 1, thirdParam)
| + | |
− | // i know below is nasty but at least quite easyand working
| + | |
− | if(strlen(fourParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,fourParam)
| + | |
− | if(strlen(fiveParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,fiveParam)
| + | |
− | if(strlen(sixParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,sixParam)
| + | |
− | if(strlen(sevenParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,sevenParam)
| + | |
− | if(strlen(eightParam))
| + | |
− | format(g_variable, VARIABLELENGTH - 1,"%s %s",g_variable,eightParam)
| + | |
− |
| + | |
− | g_currentVote = i
| + | |
− | voteInProgress = true
| + | |
− | startVote()
| + | |
− | | + | |
− | break
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | return PLUGIN_CONTINUE
| + | |
− | }
| + | |
− | </sma> | + | |
− | | + | |
− | | + | |
− | [[Kategoria:Testy]]
| + | |