Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- POLL SYSTEM BY BRITAS / DEIVIDAS
- SKYPE: WIKIS666
- */
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- //
- #define RED 0xFF0000FF
- #define YELLOW 0xFFFF00FF
- #define WHITE 0xFFFFFFFF
- #define MAX_QUESTION_SIZE 24
- #define MAX_VARIANT_SIZE 15
- #define GUI_DIALOG_ID 10
- new Text:Textdraw0 [MAX_PLAYERS],
- bool:Balsavo [MAX_PLAYERS];
- enum PollVariables
- {
- yVariant[MAX_VARIANT_SIZE],
- nVariant[MAX_VARIANT_SIZE],
- Question[MAX_QUESTION_SIZE],
- bool:Start,
- yCount,
- nCount,
- GeneralCount,
- Organizator
- }
- new Poll[PollVariables];
- public OnFilterScriptInit()
- {
- NullVariables();
- for(new i; i < MAX_PLAYERS; i++)
- {
- Textdraw0[i] = TextDrawCreate(434.000000, 110.000000, " ~y~:: ~w~APKLAUSA ~y~::~n~~n~~r~(?):~w~ Ka jus?~n~~n~~p~(Y)~w~ Nieko.~n~~p~(N)~w~ Eik nx!~n~~n~Spausk ~y~Y~w~ arba ~y~N");
- TextDrawBackgroundColor(Textdraw0[i], 255);
- TextDrawFont(Textdraw0[i], 2);
- TextDrawLetterSize(Textdraw0[i], 0.320000, 0.899999);
- TextDrawColor(Textdraw0[i], -1);
- TextDrawSetOutline(Textdraw0[i], 0);
- TextDrawSetProportional(Textdraw0[i], 1);
- TextDrawSetShadow(Textdraw0[i], 0);
- TextDrawUseBox(Textdraw0[i], 1);
- TextDrawBoxColor(Textdraw0[i], 572661640);
- TextDrawTextSize(Textdraw0[i], 647.000000, 0.000000);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- COMMAND:start(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "[]: {ffffff}This command only RCON administration.");
- new Masyvas[((265 + MAX_VARIANT_SIZE) + MAX_VARIANT_SIZE) + MAX_QUESTION_SIZE];
- format(Masyvas,sizeof Masyvas,"{ffff00}1.{ffffff} Set poll question. ({ff0000}%s{ffffff})\n{ffff00}2.{ffffff} Set Y variant. ({ff0000}%s{ffffff})\n{ffff00}3.{ffffff} Set N variant. ({ff0000}%s{ffffff})\n{ffff00}4.{ffffff} %s.\n{ffff00}5.{ffffff} Null parameters.",Poll[Question],Poll[yVariant],Poll[nVariant],(Poll[Start]) ? ("Stop poll") : ("Start poll"));
- ShowPlayerDialog(playerid, GUI_DIALOG_ID, DIALOG_STYLE_LIST, "{ffffff}Poll settings", Masyvas, "Set", "Close");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case GUI_DIALOG_ID:
- {
- switch(listitem)
- {
- case 0: if(response) return ShowPlayerDialog(playerid, (GUI_DIALOG_ID + 1), DIALOG_STYLE_INPUT, "{ffffff}Set poll question", "{ffffff}Enter a poll question text.\n{ff0000}[!] - There must be no longer than 24 characters.", "Set", "Close");
- case 1: if(response) return ShowPlayerDialog(playerid, (GUI_DIALOG_ID + 2), DIALOG_STYLE_INPUT, "{ffffff}Set Y variant", "{ffffff}Enter a Y variant text.\n{ff0000}[!] - There must be no longer than 15 characters.", "Set", "Close");
- case 2: if(response) return ShowPlayerDialog(playerid, (GUI_DIALOG_ID + 3), DIALOG_STYLE_INPUT, "{ffffff}Set N variant", "{ffffff}Enter a N variant text.\n{ff0000}[!] - There must be no longer than 15 characters.", "Set", "Close");
- case 3:
- {
- if(response)
- {
- new Masyvas[169];
- if(Poll[Start])
- {
- Poll[Start] = false;
- format(Masyvas,135,"{ffff00}Y variant votes: {ff0000}%d {ffff00}people(-s).\n{ffff00}N variant votes: {ff0000}%d {ffff00}people(-s).",Poll[yCount],Poll[nCount]);
- ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "{ffffff}Results", Masyvas, " ", "");
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i)) TextDrawHideForPlayer(i, Textdraw0[i]);
- }
- NullVariables();
- return 1;
- }
- else
- {
- if(!strcmp(Poll[Question],"None",true)) return SendClientMessage(playerid, RED, "[]: {ffffff}The question is not entered.");
- else if(!strcmp(Poll[yVariant],"None",true)) return SendClientMessage(playerid, RED, "[]: {ffffff}The Y variant is not entered.");
- else if(!strcmp(Poll[nVariant],"None",true)) return SendClientMessage(playerid, RED, "[]: {ffffff}The N variant is not entered.");
- Poll[Start] = true;
- SendClientMessageToAll(WHITE, "[ . ]: {ffff00}Poll start! Everybody can vote.");
- Poll[Organizator] = playerid;
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- TextDrawShowForPlayer(playerid, Textdraw0[i]);
- format(Masyvas,169," ~y~:: ~w~POLL ~y~::~n~~n~~r~(?):~w~ %s~n~~n~~p~(Y)~w~ %s~n~~p~(N)~w~ %s~n~~n~PRESS ~y~Y~w~ OR ~y~N",Poll[Question],Poll[yVariant],Poll[nVariant]);
- TextDrawSetString(Textdraw0[i], Masyvas);
- Poll[GeneralCount]++;
- }
- }
- }
- }
- }
- case 4:
- {
- if(response)
- {
- NullVariables();
- SendClientMessage(playerid, YELLOW, "[ * ]: {ffffff} Parameters clear.");
- }
- }
- }
- }
- case (GUI_DIALOG_ID + 1):
- {
- if(response)
- {
- if(isnull(inputtext)) return ShowPlayerDialog(playerid, (GUI_DIALOG_ID + 1), DIALOG_STYLE_INPUT, "{ffffff}Set poll question", "{ffffff}Enter a poll question text.\n{ff0000}[!] - There must be no longer than 24 characters.", "Set", "Close");
- else if(strlen(inputtext) > MAX_QUESTION_SIZE) return SendClientMessage(playerid, RED, "[]: {ffffff}The question is too long.");
- format(Poll[Question], strlen(inputtext) + 1, "%s", inputtext);
- SendClientMessage(playerid, YELLOW, "[ * ]: {ffffff} Poll question set.");
- }
- }
- case (GUI_DIALOG_ID + 2):
- {
- if(response)
- {
- if(isnull(inputtext)) return ShowPlayerDialog(playerid, (GUI_DIALOG_ID + 2), DIALOG_STYLE_INPUT, "{ffffff}Set Y variant", "{ffffff}Enter a Y variant text.\n{ff0000}[!] - There must be no longer than 15 characters.", "Set", "Close");
- else if(strlen(inputtext) > MAX_VARIANT_SIZE) return SendClientMessage(playerid, RED, "[]: {ffffff}Per ilgas tekstas.");
- format(Poll[yVariant], strlen(inputtext) + 1, "%s", inputtext);
- SendClientMessage(playerid, YELLOW, "[ * ]: {ffffff} Y variant set.");
- }
- }
- case (GUI_DIALOG_ID + 3):
- {
- if(response)
- {
- if(isnull(inputtext)) return ShowPlayerDialog(playerid, (GUI_DIALOG_ID + 3), DIALOG_STYLE_INPUT, "{ffffff}Set N variant", "{ffffff}Enter a N variant text.\n{ff0000}[!] - There must be no longer than 15 characters.", "Set", "Close");
- else if(strlen(inputtext) > MAX_VARIANT_SIZE) return SendClientMessage(playerid, RED, "[]: {ffffff}Per ilgas tekstas.");
- format(Poll[nVariant], strlen(inputtext) + 1, "%s", inputtext);
- SendClientMessage(playerid, YELLOW, "[ * ]: {ffffff} N variant set.");
- }
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(Poll[Start])
- {
- if(!Balsavo[playerid])
- {
- if(newkeys == KEY_YES)
- {
- Poll[yCount]++;
- Balsavo[playerid] = false;
- if((Poll[yCount] + Poll[nCount]) == Poll[GeneralCount])
- {
- new Masyvas[135];
- Poll[Start] = false;
- format(Masyvas,135,"{ffff00}Y variant votes: {ff0000}%d {ffff00}people(-s).\n{ffff00}N variant votes: {ff0000}%d {ffff00}people(-s).",Poll[yCount],Poll[nCount]);
- ShowPlayerDialog(Poll[Organizator], 0, DIALOG_STYLE_MSGBOX, "{ffffff}Results", Masyvas, " ", "");
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i)) TextDrawHideForPlayer(i, Textdraw0[i]);
- }
- NullVariables();
- }
- }
- else if(newkeys == KEY_NO)
- {
- Poll[nCount]++;
- Balsavo[playerid] = false;
- if((Poll[yCount] + Poll[nCount]) == Poll[GeneralCount])
- {
- new Masyvas[135];
- Poll[Start] = false;
- format(Masyvas,135,"{ffff00}Y variant votes: {ff0000}%d {ffff00}people(-s).\n{ffff00}N variant votes: {ff0000}%d {ffff00}people(-s).",Poll[yCount],Poll[nCount]);
- ShowPlayerDialog(Poll[Organizator], 0, DIALOG_STYLE_MSGBOX, "{ffffff}Rezultatai", Masyvas, " ", "");
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i)) TextDrawHideForPlayer(i, Textdraw0[i]);
- }
- NullVariables();
- }
- }
- }
- }
- return 1;
- }
- stock NullVariables()
- {
- format(Poll[yVariant], 5, "None");
- format(Poll[nVariant], 5, "None");
- format(Poll[Question], 5, "None");
- Poll[Start] = false;
- Poll[yCount] = 0;
- Poll[nCount] = 0;
- Poll[GeneralCount] = 0;
- Poll[Organizator] = INVALID_PLAYER_ID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement