View difference between Paste ID: XCX9evHA and EgrBdXhW
SHOW: | | - or go back to the newest paste.
1
/*
2
3
    | kEnquetes Powered bY Koman 001 *Kuddy* - KomanZ Team
4
        | Coded by Kuddy M4kc0
5
        | Acesse www.KuddyProject.blogspot.com
6
        | Acesse: www.Youtube.com/KuddyTV
7
        | Visite nosso servidor Brasil Life Simulation RPG
8
            | www.BrasilLifeSimulation.com.br
9
        |
10
    |
11
12
*/
13
#define FILTERSCRIPT
14
15
16
#include <a_samp>
17
#include <zcmd>
18
#include <sscanf>
19
20
#define DIALOG_RESULTADOS       1812
21
#define DIALOG_CRIAR            1813
22
#define DIALOG_ADD_PERGUNTA     1814
23
#define DIALOG_EDIT_PERGUNTA    1815
24
#define DIALOG_EDIT_TITULO      1816
25
#define DIALOG_VOTE             1817
26
27
#define VERMELEO 0xFF0000AA // Cor para analfabetos hexadecimais ._.'
28
29
30
#define INVALID_N -1
31
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
32
33
new bg@pvot[MAX_PLAYERS], ig@sel[MAX_PLAYERS],gs@s1A[546],gs@titulo[48],
34
    gs@dat[10][48],gi@_1,gi@_2 = 2,gi@p_vO[MAX_PLAYERS],bool:gb@p_vO[MAX_PLAYERS],bool:gb@op;
35
36
37
38
public OnFilterScriptInit()
39
{
40
	print("\n\n   Sistema de enquetes feito por Kuddy M4kc0 - Koman 001\n\n   www.KuddyProject.blogspot.com\n\n");
41
    format(gs@dat[0], 48, "Pergunta");
42
    format(gs@dat[1], 48, "Resposta 1");
43
    format(gs@dat[2], 48, "Resposta 2");
44
    for(new i; i != sizeof(gi@p_vO); i++)gi@p_vO[i] = INVALID_N;
45
	return 1;
46
}
47
48
public OnFilterScriptExit()
49
{
50
	return 1;
51
}
52
53
public OnPlayerConnect(playerid)
54
{
55
    bg@pvot[playerid] = false;
56
    ig@sel[playerid] = INVALID_N;
57
    return 1;
58
}
59
60
public OnPlayerDisconnect(playerid, reason)
61
{
62
    bg@pvot[playerid] = false;
63
    ig@sel[playerid] = INVALID_N;
64
    return 1;
65
}
66
67
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
68
{
69
    switch(dialogid)
70
    {
71
        case DIALOG_CRIAR:
72
        {
73
74
            if(!response) return 1;
75
            //bg@is_cr=true;
76
            if(listitem == 0)
77
            {
78
                ShowPlayerDialog(playerid, DIALOG_EDIT_PERGUNTA, DIALOG_STYLE_INPUT, "Enquete - Editar Pergunta", "Digite a nova pergunta:        ", "Ok!", "Voltar");
79
                return 1;
80
            }
81
            else if(listitem == 1)
82
            {
83
                if(gi@_2==9) return SendClientMessage(playerid, VERMELEO, "Erro:{FFFFFF} Já foram criadas 9 respostas."), formatenq1(playerid), 0x1;
84
                ShowPlayerDialog(playerid, DIALOG_ADD_PERGUNTA, DIALOG_STYLE_INPUT, "Enquete - Selecionar Pergunta", "Digite a nova opção de resposta:", "Ok!", "Voltar");
85
            }
86
            else if(listitem > 1)
87
            {
88
                new lb_=listitem-2;
89
                if(lb_>10 || lb_<0) return formatenq1(playerid);
90
                new ls@1[100];//52a48
91
                format(ls@1, 81, "Digite a nova opção de resposta para a pergunta:\n%s", gs@dat[lb_]);
92
                gi@_1=lb_;
93
                ShowPlayerDialog(playerid, DIALOG_EDIT_PERGUNTA, DIALOG_STYLE_INPUT, "Enquete - EDITAR Pergunta", ls@1, "Ok!", "Voltar");
94
                return 1;
95
            }
96
        }
97
        case DIALOG_EDIT_TITULO:
98
        {
99
            if(!response) return 1;
100
            format(gs@titulo,48, inputtext);
101
            formatenq1(playerid);
102
            return 1;
103
        }
104
        case DIALOG_EDIT_PERGUNTA:
105
        {
106
            if(!response) return formatenq1(playerid);
107
            format(gs@dat[gi@_1], 48, inputtext);
108
            formatenq1(playerid);
109
            return 1;
110
        }
111
        case DIALOG_ADD_PERGUNTA:
112
        {
113
            if(!response) return 1;
114
            gi@_2+=1;
115
            format(gs@dat[gi@_2], 48, "%s",inputtext);
116
            formatenq1(playerid);
117
            return 1;
118
        }
119
        case DIALOG_VOTE:
120
        {
121
            if(!response) return 1;
122
            if(gb@p_vO[playerid]) return 1;
123
            gi@p_vO[playerid] = listitem + 1;
124
            gb@p_vO[playerid] = true;
125
            new l@_1[128];
126
            format(l@_1, 128, "Aviso:{FFFFFF} Você votou em: %s.", gs@dat[gi@p_vO[playerid]]);
127
            SendClientMessage(playerid, VERMELEO, l@_1);
128
            return 1;
129
        }
130
    }
131
    return 1;
132
}
133
134
CMD:criarenquete(playerid)
135
{
136
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Erro:{FFFFFF} Você não é um administrador RCON."), 0x1;
137
    //if(!bg@is_cr)return ShowPlayerDialog(playerid, DIALOG_CRIAR, DIALOG_STYLE_LIST, "Enquetes - Criar", "Criar enquete\nVer resultados da última enquete", "Selecionar", "Cancelar");
138
    formatenq1(playerid);
139
    //bg@is_cr=true;
140
    return 1;
141
}
142
143
CMD:abrirenquete(playerid)
144
{
145-
    SetTimer("lkout",120,0);
145+
146
    SendClientMessageToAll(VERMELEO, "Aviso: {FFFFFF}Foi aberta uma nova enquete, /votar para votar!");
147
    return 1;
148
}
149
150
CMD:votar(playerid)
151
{
152
    if(!gb@op) return SendClientMessage(playerid, VERMELEO, "Erro:{FFFFFF} A enquete não está aberta."), 0x1;
153
    formatenq2(playerid);
154
    return 1;
155
}
156
157
CMD:encerrarenquete(playerid)
158
{
159
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, VERMELEO, "Erro:{FFFFFF} Você não é um administrador RCON."), 0x1;
160
    endenq(playerid);
161
    gb@op=false;
162
163
    for(new i; i != MAX_PLAYERS; i++)
164
    {
165
        gi@p_vO[i] = INVALID_N;
166
        gb@p_vO[i] = false;
167
    }
168
    return 1;
169
}
170
171
172
formatenq1(ii)
173
{
174
    new l@s1A[546],l@s2A[510];//1..65a10m48\/¬48a10m2
175
    for(new x; x != 10;x++)
176
    {
177
        if(isnull(gs@dat[x])) break;
178
        format(l@s2A, 500, "%s\n> %s", l@s2A, gs@dat[x]);
179
        //printf(l@s2A);
180
    }
181
    format(l@s1A, 546, "Setar título da enquete\nAdcionar nova opção\n%s",l@s2A);
182
    format(gs@s1A, 546, l@s2A);
183
    ShowPlayerDialog(ii, DIALOG_CRIAR, DIALOG_STYLE_LIST, "Enquetes - Criando", l@s1A, "Selecionar", "Cancelar");
184
    return 1;
185
}
186
187
// kekka
188
formatenq2(ii)
189
{
190
    new l@s2A[510];//¬48a10m2
191
    for(new x=1; x != 10;x++)
192
    {
193
        if(isnull(gs@dat[x])) break;
194
        format(l@s2A, 500, "%s\n> %s", l@s2A, gs@dat[x]);
195
        //printf(l@s2A);
196
    }
197
    ShowPlayerDialog(ii, DIALOG_VOTE, DIALOG_STYLE_LIST, gs@dat[0], l@s2A, "Votar", "Cancelar");
198
    return 1;
199
}
200
201
endenq(ii)
202
{
203
    new l@s2A[600], li@win, l@s1A[58], li@_o[10];
204
    for(new i; i != MAX_PLAYERS; i ++)
205
        if(gb@p_vO[i])
206
            li@_o[gi@p_vO[i]] ++;
207
    for(new x=1; x != 10;x++)
208
    {
209
        if(isnull(gs@dat[x])) break;
210
        format(l@s2A, 500, "%s\n> %s | Votos: %d", l@s2A, gs@dat[x],li@_o[x]);
211
        if(li@_o[x-1] < li@_o[x]) li@win = x;
212
    }
213
    format(l@s2A, 600, "{FFFFFF}A opnião pública é:\n{FF0000}%s | %d votos{FFFFFF}\n\n%s", gs@dat[li@win], li@_o[li@win], l@s2A);
214
    format(l@s1A, 100, "Enquete: %s", gs@dat[0]);
215
    for(new i;i!=MAX_PLAYERS;i++)ShowPlayerDialog(ii, DIALOG_RESULTADOS, DIALOG_STYLE_MSGBOX, gs@dat[0], l@s2A, "Fechar", "");
216
    return 1;
217
}