-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate-votes
More file actions
executable file
·41 lines (34 loc) · 1.68 KB
/
generate-votes
File metadata and controls
executable file
·41 lines (34 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
map_votes() {
# --- Mark current map type with an X
for type in Short Middle Long Fastcap; do
if [[ "$type" == "$1" ]]; then
echo "add_vote \"[X] $type maps\" \"clear_votes; exec votes_${type,,}.cfg\""
else
echo "add_vote \"[ ] $type maps\" \"clear_votes; exec votes_${type,,}.cfg\""
fi
done
echo 'add_vote " " "say I am a placeholder, why do you vote me?"'
# --- Options
echo 'add_vote "-=-=-=-=-=-=-=-> Options <-=-=-=-=-=-=-=-" "info"'
echo "add_vote \"Random $1\" \"sv_server_type $1; random_map\""
echo "add_vote \"Unfinished $1\" \"sv_server_type $1; random_unfinished_map\""
echo 'add_vote " " "say Your main objective: Be faster than Tezcan"'
# --- Most Recent
echo 'add_vote "-=-=-=-=-=-=-=-> Most Recent <-=-=-=-=-=-=-=-" "say Hooked on you since version 0.5"'
mariadb -D urace -N -e "SELECT Map, Mapper FROM record_maps WHERE Server LIKE '$1%' ORDER BY Timestamp DESC LIMIT 5" |
while IFS=$'\t' read -r map mapper; do
printf 'add_vote "[NEW] %s by %s" "change_map \\"%s\\""\n' "$map" "$mapper" "$map"
done
echo 'add_vote " " "say Thank you for testing our voting system!"'
# --- All maps
echo 'add_vote "-=-=-=-=-=-=-=-> All Maps <-=-=-=-=-=-=-=- " "say Hooked on you since version 0.5"'
mariadb -D urace -N -e "SELECT Map, Mapper FROM record_maps WHERE Server LIKE '$1%' ORDER BY Map ASC" |
while IFS=$'\t' read -r map mapper; do
printf 'add_vote "%s by %s" "change_map \\"%s\\""\n' "$map" "$mapper" "$map"
done
}
map_votes Short > ~/unique-maps/votes_short.cfg
map_votes Middle > ~/unique-maps/votes_middle.cfg
map_votes Long > ~/unique-maps/votes_long.cfg
map_votes Fastcap > ~/unique-maps/votes_fastcap.cfg