· 7 years ago · Oct 21, 2018, 06:42 AM
1que_qsch01,281,306,5 script Rank [MVP] 404,{
2 function inicializar_db;
3 function considerado_mvp;
4 function anunciar_jogador;
5 function mostrar_ranking;
6 function rankear_jogador;
7
8 if (getgmlevel() > .gm_minimo) {
9 mes "[^0000FFTop MvP " + .ranking_maximo + "^000000]";
10 mes "O que deseja fazer?";
11 .@toggleAnuncio$ = (.anunciar) ? "Desligar anúncio" : "Ligar anúncio";
12 switch(select(
13 "Ver Top",
14 .@toggleAnuncio$,
15 "Resetar Top MvP",
16 "Número de posições"
17 )) {
18 case 1:
19 break;
20 case 2:
21 .anunciar = !.anunciar;
22 close;
23 case 3:
24 query_sql "TRUNCATE mvprank";
25 close;
26 case 4:
27 mes "Digite o número de posições do top mvp.";
28 input .ranking_maximo;
29 break;
30 }
31 }
32 next;
33 mostrar_ranking();
34 close;
35
36 OnInit:
37 //======================================================
38 // Cria a tabela no banco de dados se ela não existir
39 //======================================================
40 inicializar_db();
41
42 //=====================================================
43 // Número de jogadores que serão mostrados no ranking
44 //=====================================================
45 .ranking_maximo = 10;
46
47 //=====================================================
48 // NÃvel de GM necessário para configurar o NPC
49 //=====================================================
50 .gm_minimo = 90;
51
52 //=====================================================
53 // Anunciar o jogador que derrotar um dos MVPs?
54 //=====================================================
55 .anunciar = 1;
56
57 //=====================================================
58 // Lista de IDs dos MVPs que serão considerados
59 //=====================================================
60 setarray .mvps[0], 1511, 1647, 1785, 1630, 1399, 1039, 1874, 2068, 1272, 1719, 1046, 1389, 1112, 1115, 1957, 1418, 1871, 1252, 1768, 1086, 1688, 1646, 1373, 1147, 1059, 1150, 1956, 2022, 1087, 1190, 1038, 1157, 1159, 1502, 1623, 1650, 1583, 1708, 1312, 1751, 1685, 1648, 1917, 1658, 1832, 1916;
61
62 waitingroom "Rank [MVP]", 0;
63 end;
64
65 OnNPCKillEvent:
66 if (!considerado_mvp(killedrid))
67 end;
68 if (.anunciar)
69 anunciar_jogador(killedrid);
70 rankear_jogador();
71 end;
72
73 function inicializar_db {
74 query_sql "CREATE TABLE IF NOT EXISTS mvprank (id INT(11) UNSIGNED NOT NULL DEFAULT 0, name VARCHAR(23) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, mvpkills BIGINT UNSIGNED NOT NULL, UNIQUE (id)) ENGINE = MYISAM";
75 }
76
77 function considerado_mvp {
78 // ID do monstro derrotado
79 .@id = getarg(0);
80
81 for (.@mvp_id = 0; .@mvp_id < getarraysize(.mvps); .@mvp_id = .@mvp_id + 1) {
82 if (.@id == .mvps[.@mvp_id])
83 return true;
84 }
85 return false;
86 }
87
88 function anunciar_jogador {
89 .@mvp_name$ = getmonsterinfo(getarg(0), 0);
90 announce "O player [ " + strcharinfo(0) + " ] matou o MvP [ " + getmonsterinfo(killedrid, 0) + " ] no mapa [ " + strcharinfo(3) + " ]", bc_blue|bc_all;
91 }
92
93 function rankear_jogador {
94 query_sql "INSERT INTO mvprank (id, name, mvpkills) values(" + getcharid(0) + ", '" + strcharinfo(0) + "', 1) ON DUPLICATE KEY UPDATE mvpkills = mvpkills + 1";
95 }
96
97 function mostrar_ranking {
98 query_sql "SELECT name, mvpkills FROM mvprank ORDER BY mvpkills DESC LIMIT " + .ranking_maximo, .@nome$, .@quantidade;
99 mes "[^0000FFTop MvP " + .ranking_maximo + "^000000]";
100 if (!getarraysize(.@nome$))
101 mes "Ninguém matou um MVP ainda.";
102 for (.@rank = 0; .@rank < getarraysize(.@nome$); .@rank++) {
103 mes "^FF0000" + (.@rank + 1) + ".^000000 ^0000FF" + .@nome$[.@rank] + "^000000 matou ^FF0000" + .@quantidade[.@rank] + "^000000 MVPs.";
104 }
105 }
106}