Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include zcmd
- #include <sscanf2>
- ////////////////
- #define BELA "{FFFFFF}"
- #define CRVENA "{F81414}"
- #define SPLAVA "{00C0FF}"
- ////////////////
- #define SCM SendClientMessage
- ////////////////
- enum voteData
- {
- Option[12],
- OptionTwo[12],
- VoteCount[2]
- };
- //////
- new Votes[voteData];
- new
- VoteOn,
- VotedFor[MAX_PLAYERS],
- Voted[MAX_PLAYERS];
- //////
- /////////////////////////////////////////////
- public OnPlayerConnect(playerid)
- {
- Voted[playerid] = 0;
- VotedFor[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(Voted[playerid])
- {
- Voted[playerid] = 0;
- if(VotedFor[playerid] == 1)
- Votes[VoteCount][0]--;
- else
- Votes[VoteCount][1]--;
- VotedFor[playerid] = 0;
- }
- return 1;
- }
- /////////////////////////////////////SADA SU KOMANDE///////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////
- YCMD:votehelp(playerid, params[], help)
- {
- #pragma unused help
- SendClientMessage(playerid, -1, "POMOC: /vote /cancelvote /votes");
- if(PlayerInfo[playerid][pAdmin] >= 4)
- {
- SendClientMessage(playerid, -1, "Admin pomoc: /startvote /endvote");
- }
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////
- YCMD:votes(playerid, params[], help)
- {
- #pragma unused help
- if(!VoteOn)
- return SendClientMessage(playerid, -1, ""CRVENA"Nema pokrenutog glasanja!");
- new string[144];
- SendClientMessage(playerid, -1, "|__________Broj glasova_________|");
- format(string, sizeof(string), "Opcija: "SPLAVA" %s (Glasova:"SPLAVA" %d)", Votes[Option], Votes[VoteCount][0]);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "Opcija:"SPLAVA" %s (Glasova:"SPLAVA" %d)", Votes[OptionTwo], Votes[VoteCount][1]);
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////
- YCMD:cancelvote(playerid, params[] ,help)
- {
- #pragma unused help
- if(!VoteOn)
- return SendClientMessage(playerid, -1, ""CRVENA"Glasanje nije zapoceto");
- if(!Voted[playerid])
- return SendClientMessage(playerid, -1, ""CRVENA"Nijesi glasao uopste,pa ne mozes povuci glas");
- if(VotedFor[playerid] == 1)
- {
- Votes[VoteCount][0]--;
- }
- else if(VotedFor[playerid] == 2)
- {
- Votes[VoteCount][1]--;
- }
- Voted[playerid] = 0;
- VotedFor[playerid] = 0;
- SendClientMessage(playerid, -1, ""CRVENA"Povukao si glas");
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////
- YCMD:endvote(playerid, params[], help)
- {
- #pragma unused help
- if(!VoteOn)
- return SendClientMessage(playerid, -1, ""CRVENA"Glasanje nije zapoceto");
- if(PlayerInfo[playerid][pAdmin] < 4)
- return SendClientMessage(playerid, -1, ""CRVENA"Samo A4+");
- new string[144];
- if(Votes[VoteCount][0] > Votes[VoteCount][1])
- {
- format(string, sizeof(string), ""SPLAVA"%s "BELA"je nadjacao protivnika.", Votes[Option]);
- SendClientMessageToAll(-1, string);
- }
- else if(Votes[VoteCount][0] < Votes[VoteCount][1])
- {
- format(string, sizeof(string), ""SPLAVA" %s "BELA"je nadjacao protivnika.", Votes[OptionTwo]);
- SendClientMessageToAll(-1, string);
- }
- else if(Votes[VoteCount][0] == Votes[VoteCount][1])
- {
- format(string, sizeof(string), "Niko nije pobijedio!!Izjednacen broj glasova ("SPLAVA"%s "BELA"| "SPLAVA"%s)", Votes[Option], Votes[OptionTwo]);
- SendClientMessageToAll(-1, string);
- }
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(Voted[i])
- {
- Voted[i] = 0;
- VotedFor[i] = 0;
- }
- }
- Votes[Option] = EOS;
- Votes[OptionTwo] = EOS;
- Votes[VoteCount][0] = 0;
- Votes[VoteCount][1] = 0;
- VoteOn = 0;
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////
- YCMD:startvote(playerid, params[], help)
- {
- #pragma unused help
- if(VoteOn)
- return SendClientMessage(playerid, -1,""CRVENA"Glasanje je u toku");
- if(PlayerInfo[playerid][pAdmin] < 4)
- return SendClientMessage(playerid, -1, ""CRVENA"Samo A4+");
- new opt1[12], opt2[12], text[256];
- if(sscanf(params, "s[12]s[12]s[1024]", opt1, opt2, text))
- return SendClientMessage(playerid, -1, ""CRVENA"KORISTI: "BELA" /startvote [OPCIJA 1] [OPCIJA 2] [PREDMET GLASANJA]");
- if(isnull(opt1) || isnull(opt2))
- return SendClientMessage(playerid, -1, ""CRVENA"Moras unijeti ime opcije");
- if(isnull(text))
- return SendClientMessage(playerid, -1, ""CRVENA"Moras unijeti predmet glasanja!!");
- if(strcmp(opt1, opt2, true) == 0)
- return SendClientMessage(playerid, -1, ""CRVENA"Opcija 1 i opcija 2 ne mogu biti iste!");
- format(Votes[Option], 12, opt1);
- format(Votes[OptionTwo], 12, opt2);
- VoteOn = 1;
- new string[144];
- format(string, sizeof(string), ""SPLAVA"|"BELA"__________"SPLAVA"GLASANJE JE POCELO"BELA"_________"SPLAVA"|");
- SendClientMessageToAll(-1, string);
- format(string, sizeof(string), ""CRVENA"|"BELA"~~"CRVENA"PREDMET GLASANJA"BELA"~~"CRVENA"|");
- SendClientMessageToAll(-1, string);
- format(string, sizeof(string), ""BELA"%s", text);
- SendClientMessageToAll(-1, string);
- format(string, sizeof(string), ""BELA"Opcije: "SPLAVA"%s "BELA"ili"SPLAVA"%s", Votes[Option], Votes[OptionTwo]);
- SendClientMessageToAll(-1, string);
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////
- YCMD:vote(playerid, params[], help)
- {
- #pragma unused help
- if(!VoteOn)
- return SendClientMessage(playerid, -1,""CRVENA"Nije pokrenuto glasanje");
- new string[144];
- if(Voted[playerid])
- {
- if(VotedFor[playerid] == 1)
- format(string, sizeof(string), ""BELA"Vec si glasao za "SPLAVA"%s"BELA",ako hoces da promijenis glas - /cancelvote i glasaj opet.", Votes[Option]);
- else if(VotedFor[playerid] == 2)
- format(string, sizeof(string), "Vec si glasao za %s,ako hoces da promijenis glas - /cancelvote i glasaj opet.", Votes[OptionTwo]);
- SendClientMessage(playerid, -1, string);
- return 0;
- }
- if(isnull(params))
- {
- SendClientMessage(playerid, -1, "KORISTI: /vote [OPCIJA]");
- format(string, sizeof(string), "OPCIJE:"SPLAVA" %s "BELA"|"SPLAVA" %s", Votes[Option], Votes[OptionTwo]);
- SendClientMessage(playerid, -1, string);
- }
- if(!strcmp(params, Votes[Option], true))
- {
- if(isnull(params))
- return 0;
- format(string, sizeof(string), "Glasao si za "SPLAVA" %s.", Votes[Option]);
- SendClientMessage(playerid, -1, string);
- Votes[VoteCount][0]++;
- Voted[playerid] = 1;
- VotedFor[playerid] = 1;
- }
- else if(!strcmp(params, Votes[OptionTwo], true))
- {
- if(isnull(params))
- return 0;
- format(string, sizeof(string), "Glasao si za "SPLAVA" %s.", Votes[OptionTwo]);
- SendClientMessage(playerid, -1, string);
- Votes[VoteCount][1]++;
- Voted[playerid] = 1;
- VotedFor[playerid] = 2;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement