Vote System +Rep - 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: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vote System +Rep (
/showthread.php?tid=628215)
Vote System +Rep -
Ramin - 07.02.2017
PHP код:
new PlayerMapVote[MAX_PLAYERS];
static MapNumber;
static MapNumberP[MAX_PLAYERS];
static 1Vote;
static 2Vote;
static 3Vote;
static 4Vote;
CMD:VoteMaps(playerid, params[])
{
ShowPlayerDialog(playerid, DerbyDialogs, DIALOG_STYLE_LIST, "VoteSystem By {FF0000}Ramin[Avenger]{FFFFFF}","1\n2\n3\n4", "Vote", "Close");
SetTimerEx("FinishVote", 20000, false, "i", playerid);
return 1;
}
forward FinishVote(playerid, time);
public FinishVote(playerid, time)
{
ShowPlayerDialog( playerid, -1, 0, "", "", "", "" );
if (1 >= 2 && 1 >= 3 && 1 >= 4)
{
SendClientMessageToAll(COLOR_GREEN, "Vote:Map 1 Has Won!");
PlayerMapVote[playerid] = 0;
return 1;
}
else if(2 > 1 && 2 >= 3 && 2 >= 4)
{
SendClientMessageToAll(COLOR_GREEN, "Vote:Map 2 Has Won!");
PlayerMapVote[playerid] = 0;
return 1;
}
else if(3 > 1 && 3 > 2 && 3 >= 4)
{
SendClientMessageToAll(COLOR_GREEN, "Vote:Map 3 Has Won");
PlayerMapVote[playerid] = 0;
}
else if(4 > 1 && 4 > 2 && 4 > 3)
{
SendClientMessageToAll(COLOR_GREEN, "Vote:Map 4 Has Won");
PlayerMapVote[playerid] = 0;
}
PlayerDerbyVote[playerid] = 0;
1Vote = 0;
2Vote = 0;
3Vote = 0;
4Vote = 0;
MapNumber = 0;
MapNumberP[playerid] = 0;
}
if(dialogid == DerbyDialogs)
{
if(response)
{
if(listitem == 0)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Voted 1.",pName);
SendClientMessageToAll(0xFF9900AA,string);
1Vote += 1;
PlayerMapVote[playerid] = 1;
MapNumber += 1;
MapNumberP[playerid] = MapNumber;
}
if(listitem == 1)
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Voted 2.",pName);
SendClientMessageToAll(0xFF9900AA,string);
2Vote += 1;
PlayerMapVote[playerid] = 1;
MapNumber += 1;
MapNumberP[playerid] = MapNumber;
}
if(listitem == 2)
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Voted 3.",pName);
SendClientMessageToAll(0xFF9900AA,string);
3Vote += 1;
PlayerMapVote[playerid] = 1;
MapNumber += 1;
MapNumberP[playerid] = MapNumber;
}
if(listitem == 3)
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Voted 4.",pName);
SendClientMessageToAll(0xFF9900AA,string);
4Vote += 1;
PlayerMapVote[playerid] = 1;
MapNumber += 1;
MapNumberP[playerid] = MapNumber;
}
}
return 1;
}
i Maked This Algoritm For Vote Map by players But i don't know how i can Use SetTimerEx For All Player Equal
in this Code When Player Choose 1 20 Second Begin for him And When Next Player Choose 2 new Timer Begin for him . In Result Two Message come to all Vote:Map 1 Has Won - Vote:Map 2 Has Won
i want One timer for all Equal
Please Compelete my Codes <3 Thank you
Re: Vote System +Rep -
jlalt - 07.02.2017
PHP код:
#define VOTENUMBERS 4
static
PlayerMapVote[MAX_PLAYERS],
Votes[VOTENUMBERS],
LastTimeVoted
;
CMD:votemaps(playerid, params[])
{
if(PlayerMapVote[playerid])
{
SendClientMessage(playerid, -1,"You've already voted!");
}
else
{
new string[128];
for(new i = 0; i < VOTENUMBERS; i++)
{
new str[10];
format(str, sizeof str,"%d\n",( i + 1 ));
strcat(string, str);
}
ShowPlayerDialog(playerid, DerbyDialogs, DIALOG_STYLE_LIST, "VoteSystem By {FF0000}Ramin[Avenger]{FFFFFF}", string, "Vote", "Close");
}
return 1;
}
forward FinishVote();
public FinishVote()
{
if((gettime() - LastTimeVoted) > 19)
{
new whichmap = -1, lastmapscore = -255;
for(new i = 0; i < VOTENUMBERS; i++)
{
if(i == 0)
{
whichmap = i;
lastmapscore = Votes[i];
}
else
{
if(Votes[i] > lastmapscore)
{
whichmap = i;
lastmapscore = Votes[i];
}
}
}
new string[128];
format(string, sizeof string,"Vote: Map %d Has Won!",( whichmap + 1 ));
SendClientMessageToAll(COLOR_GREEN, string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerMapVote[i] = 0;
}
for(new i = 0; i < VOTENUMBERS; i++)
{
Votes[i] = 0;
}
LastTimeVoted = 0;
}
}
if(dialogid == DerbyDialogs)
{
if(response)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Voted %d.",pName, ( listitem + 1 ));
SendClientMessageToAll(0xFF9900AA,string);
Votes[listitem] += 1;
PlayerMapVote[playerid] = 1;
LastTimeVoted = gettime();
SetTimer("FinishVote", 20000, false);
}
return 1;
}
Explain's on telegram...
Re: Vote System +Rep -
Ramin - 07.02.2017
thank you <3