Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////////// VOTE SYSTEM
- local Vote = 0;
- local VoteTime = 10000; // (10 seconds currently)
- local IfVote = array(MAX_PLAYERS, 0);
- local YES = 0; //not working
- local NO = 0; //not working
- //////////////////////////////////////////////////////////////////////////////// /vote
- addCommandHandler( "vote",
- function( playerid, ... )
- {
- if(vargv.len() > 1)
- {
- local msg = "";
- for (local i = 0; i < vargv.len(); i++)
- {
- msg = msg + " " + vargv[i];
- }
- {
- if( Vote == 0 )
- { //IF VOTE NOT RUNNING
- sendPlayerMessageToAll( "[Server]: " + getPlayerName( playerid ) + " started a Vote!", 255, 255, 0 );
- sendPlayerMessageToAll( "[Server]: Question: " + msg, 51,204,153 );
- sendPlayerMessageToAll( "[Server]: Answer /y for YES or /n for NO.", 255, 255, 0 );
- Vote = 1;
- timer( function() {
- Vote = 0;
- sendPlayerMessageToAll( "[Server]: Voting is closed", 255, 255, 0 );
- sendPlayerMessageToAll( "[Server]: Results: " + "YES: " +YES + " NO: " +NO, 51,204,153 );
- YES = 0;
- NO = 0;
- IfVote = 0;
- }, VoteTime, 1
- );
- }
- else
- if( Vote == 1 ) {
- sendPlayerMessage( playerid, "[Server]: Any Vote already running", 255, 0, 0 );
- }
- }
- }
- }
- );
- //////////////////////////////////////////////////////////////////////////////// YES
- addCommandHandler( "y",
- function( playerid )
- if( Vote == 1 ) {
- sendPlayerMessage( playerid, "[Server]: Thanks for your vote", 255, 255, 0 );
- YES = 1; // I changing only to 1. :/
- IfVote[playerid] = 1;
- }
- else
- if( Vote == 0 ) {
- sendPlayerMessage( playerid, "[Server]: There's no Vote active!", 255, 0, 0 );
- if( IfVote == 1 ) {
- sendPlayerMessage( playerid, "[Server]: You already voted!", 255, 0, 0 ); //not working.... nah.. :(
- }
- }
- );
- //////////////////////////////////////////////////////////////////////////////// NO
- addCommandHandler( "n",
- function( playerid )
- if( Vote == 1 ) {
- sendPlayerMessage( playerid, "[Server]: Thanks for your vote", 255, 255, 0 );
- NO = 1; //Same here :/
- IfVote[playerid] = 1;
- }
- else
- if( Vote == 0 ) {
- sendPlayerMessage( playerid, "[Server]: There's no Vote active!", 255, 0, 0 );
- if( IfVote == 1 ) {
- sendPlayerMessage( playerid, "[Server]: You already voted!", 255, 0, 0 ); //same not working... grrr
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement