SA-MP Forums Archive
[FilterScript] Voting system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Voting system (/showthread.php?tid=286403)



Voting system - Leeo_Perez - 28.09.2011

Description

You have to be connected to rcon administrator to start or end a vote.



COMMANDS:

/ask
/vote ( opens a dialog and you vote )
/result


SOURCE:


pawn Code:
#include    a_samp
#include    zcmd
#include    sscanf2

       
new bool:voting,
    bool:voted[MAX_PLAYERS],
    yes,no,
    name[24]
;

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 9999)
    {
        if(response == 1)
        {
            if(listitem == 0)
            {
                if(voted[playerid] == true)
                                return SendClientMessage(playerid,0xFF0000FF,"you already voted");

                if(voting == true)
                {
                    SendClientMessage(playerid,0xFF0000FF,"===========================================================");
                    SendClientMessage(playerid,0xFF0000FF,"VOTO COMPUTADO COM SUCESSO");
                    SendClientMessage(playerid,0xFF0000FF,"===========================================================");
                }
                else return SendClientMessage(playerid,0xFF0000FF,"you already voted");
                return yes++,voted[playerid] = true;
            }
            if(listitem == 1)
            {
                if(voted[playerid] == true ) return SendClientMessage(playerid,0xFF0000FF,"you already voted");
                if(voting == true)
                {
                    SendClientMessage(playerid,0xFF0000FF,"===========================================================");
                    SendClientMessage(playerid,0xFF0000FF,"VOTO COMPUTADO COM SUCESSO");
                    SendClientMessage(playerid,0xFF0000FF,"===========================================================");
                }
                else return SendClientMessage(playerid,0xFF0000FF,"you already voted");
                return no++,voted[playerid] = true;
            }
        }
    }
    return 1;
}

public OnFilterScriptInit()
                return print("Voting system by Leo_Perez loaded");
               
public OnFilterScriptExit()
                return print("Voting system by Leo_Perez unloaded");
               
CMD:ask(playerid,params[])
{
    new string[46],str2[128];
    if(sscanf(params,"s",str2))
                     return SendClientMessage(playerid,0xFF0000FF,"use /ask [text]");
    if(IsPlayerAdmin(playerid))
    {
        if(voting == true)
                     return SendClientMessage(playerid,0xFF0000FF,"There is no vote in progress..");
                     
        SendClientMessageToAll(0xFF0000FF,"===========================================================");
        format(string,sizeof(string),"Admin %s question: %s",name,str2);
        SendClientMessageToAll(0xFF0000FF,"Use : /yes ou /no");
        SendClientMessageToAll(0xFFFF00FF,string);
        SendClientMessageToAll(0xFF0000FF,"===========================================================");
    }
    else return SendClientMessage(playerid,0xFF0000FF,"Vocк nгo й administrador");
    return voting = true;
}

CMD:vote(playerid,params[])
                return ShowPlayerDialog(playerid,9999,DIALOG_STYLE_LIST,"Votar","Yes\nNo","Ok","");
               
CMD:result(playerid,params[])
{
    new string[25];
    GetPlayerName(playerid,name,sizeof(name));
    if(voting == false) return SendClientMessage(playerid,0xFF0000FF,"There is no vote in progress..");
    if(IsPlayerAdmin(playerid))
    {
        voting = false;
        SendClientMessageToAll(0xFF0000FF,"===========================================================");
        SendClientMessageToAll(0xFF0000FF,"A VOTAЗГO ACABOU!");
        format(string,sizeof(string),"Yes: %d No: %d",yes,no);
        SendClientMessageToAll(0xFFFF00FF,string);
        SendClientMessageToAll(0xFF0000FF,"===========================================================");
        for(new i; i < MAX_PLAYERS; i++)
        {
            voted[i] = false;
        }
    }
    else return SendClientMessage(playerid,0xFF0000FF,"You are not administrator");
    return yes = 0,no = 0;
}
CREDITS:

Zeex: zcmd
sa-mp dev team: all
****** : sscanf
i: filterscript ._.


sorry my bad english


Re: Voting system - [MWR]Blood - 28.09.2011

pawn Code:
if(voting == true)
                     return SendClientMessage(playerid,0xFF0000FF,"There is no vote in progress..");
Epic!


Re: Voting system - Vai_Besta - 28.09.2011

nice


Re: Voting system - Leeo_Perez - 28.09.2011

Quote:
Originally Posted by Vai_Besta
View Post
nice
thx ^^


Re: Voting system - Yamoo - 29.09.2011

Not bad mate.