Voting problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Voting problem (
/showthread.php?tid=180337)
Voting problem -
Hijolion - 01.10.2010
It's very radical in my mind, why isn't this working like it supposed to ?
pawn Код:
forward votedmode(playerid);
public votedmode(playerid)
{
new map;
for(new i; i < sizeof maps; i++)
if(maps[map] < maps[i])
map = i;
print("Voted Mode Was Successfully Executed.");
switch (map)
{
case 0: SendRconCommand("changemode wwx");
case 1: SendRconCommand("changemode jailbreak");
case 2: SendRconCommand("changemode mallmilitia");
case 3: SendRconCommand("changemode holywarfare");
case 4: SendRconCommand("changemode cstyles");
case 5: SendRconCommand("changemode killemall");
case 6: SendRconCommand("changemode factory");
case 7: SendRconCommand("changemode elitefighter");
case 8: SendRconCommand("changemode lssubway");
case 9: SendRconCommand("changemode dspeeders");
case 10: SendRconCommand("changemode mafiawar");
case 11: SendRconCommand("changemode pirateisland");
case 12: SendRconCommand("changemode boattheft");
}
return 1;
}
Re: Voting problem -
Kitten - 01.10.2010
try adding
above switch (map)
Re: Voting problem -
Hijolion - 01.10.2010
Quote:
Originally Posted by Kitten
try adding
above switch (map)
|
it's not random, it should execute by the number of votes which it doesn't seems to be. It worksbut like
it executes the first case and then it continues to do the same for all time. Remember I'm trying to find the biggest number out of all votes.
Re: Voting problem -
Kitten - 01.10.2010
so what ur saying like /map 1 /map 2 ?
Re: Voting problem -
Toni - 01.10.2010
I don't think he is asking for commands, but for a + 1 / - 1 system.
You can easily create this by adding a global variable for a vote. i.e
Then when someone does /vote 1 (vote for map 1), you can do Map1++; which will add a vote to the array.
Then set a timer maybe 25 seconds going down, and when the timer is done, check for the highest value in an array, and change the mode to that.
Re: Voting problem -
Hijolion - 02.10.2010
Ok, it's in dialog process, like when player commands /vote then a dialog box pops up with all the maps, I've one global variable storing 27 maps and i've set timer to that function to find the highest number of votes for the server to execute the next map, instead it executes the first case instead of the largest amount of vote. Also I don't want +1 -1 system, I just want to find the biggest number in efficient way. so help?
Re: Voting problem -
samgreen - 02.10.2010
Quote:
Originally Posted by Hijolion
It's very radical in my mind, why isn't this working like it supposed to ?
|
Try this:
pawn Код:
forward votedmode(playerid);
public votedmode(playerid)
{
new mapWinner, mostVotes = -1;
for(new i; i < sizeof maps; i++) {
if(maps[i] > mostVotes) {
mapWinner = i;
mostVotes = maps[i];
}
}
switch (mapWinner) {
case 0: {
SendRconCommand("changemode wwx");
}
case 1: {
SendRconCommand("changemode jailbreak");
}
case 2: {
SendRconCommand("changemode mallmilitia");
}
case 3: {
SendRconCommand("changemode holywarfare");
}
case 4: {
SendRconCommand("changemode cstyles");
}
case 5: {
SendRconCommand("changemode killemall");
}
case 6: {
SendRconCommand("changemode factory");
}
case 7: {
SendRconCommand("changemode elitefighter");
}
case 8: {
SendRconCommand("changemode lssubway");
}
case 9: {
SendRconCommand("changemode dspeeders");
}
case 10: {
SendRconCommand("changemode mafiawar");
}
case 11: {
SendRconCommand("changemode pirateisland");
}
case 12: {
SendRconCommand("changemode boattheft");
}
}
print("Voted Mode Was Successfully Executed.");
return 1;
}
Also we probably need to see more code that involves the maps array.
Re: Voting problem -
Hijolion - 02.10.2010
Quote:
Originally Posted by samgreen
Try this:
pawn Код:
forward votedmode(playerid); public votedmode(playerid) { new mapWinner, mostVotes = -1; for(new i; i < sizeof maps; i++) { if(maps[i] > mostVotes) { mapWinner = i; mostVotes = maps[i]; } }
switch (mapWinner) { case 0: { SendRconCommand("changemode wwx"); } case 1: { SendRconCommand("changemode jailbreak"); } case 2: { SendRconCommand("changemode mallmilitia"); } case 3: { SendRconCommand("changemode holywarfare"); } case 4: { SendRconCommand("changemode cstyles"); } case 5: { SendRconCommand("changemode killemall"); } case 6: { SendRconCommand("changemode factory"); } case 7: { SendRconCommand("changemode elitefighter"); } case 8: { SendRconCommand("changemode lssubway"); } case 9: { SendRconCommand("changemode dspeeders"); } case 10: { SendRconCommand("changemode mafiawar"); } case 11: { SendRconCommand("changemode pirateisland"); } case 12: { SendRconCommand("changemode boattheft"); } } print("Voted Mode Was Successfully Executed."); return 1; }
Also we probably need to see more code that involves the maps array.
|
That works, but when my timer calls the function, the mode changes to the first map. Is there way to ignore it?
Re: Voting problem -
Hijolion - 03.10.2010
bump* help?
Re: Voting problem -
Conroy - 03.10.2010
Paste your 'maps' variable.