Complete Voting System
by Gonzo T. Clown · 10/28/2004 (12:10 pm) · 15 comments
Download Code File
These same instructions are included in the Zip file, but i wanted everyone to see that this is an easy install.
//===========================================================
//
// You are free to use and modify this resource provided you give credit
// where credit is due and provided you leave the original documentation
// intact where applicable. Please comment any changes you make to
// differentiate authors.
//
//
// This Voting system install was based on the HEAD(Release_1_3_0)
// versions starter.fps example. Although it should be compatible with
// all of them, the only install instructions I'm giving are for starter.fps.
//
//
// Place ClientVote.cs in the starter.fps\client\ui folder
//
//
// Place ServerVote.cs in the starter.fps\server\scripts folder
//
//
// Open starter.fps\Clent\init.cs in your editor and add
//
// exec("./ui/ClientVote.cs");
//
// at the bottom of the section that starts with "// Load up the shell GUIs"
//
//
// Open starter.fps\Server\scripts\game.cs in your editor and add
//
// exec("./ServerVote.cs");
//
// to the onServerCreated() function. Add it just below the line
//
// exec("./aiPlayer.cs");
//
//
// Open starter.fps\Client\scripts\default.bind.cs and add the
// following lines to the bottom of the file.
//
// // Bind the key to push the VoteGUI
// moveMap.bind(keyboard, "ctrl v", pushVoteGui);
//
//
// Finally, open starter.fps\Client\config.cs and add this line to your
// config at any point you please.
//
// moveMap.bind(keyboard, "ctrl v", pushVoteGui);
//
//
//
// Save all your changes and close your editor.
//
//
// That's it. Next time you run your game, you will be able to cast votes
// to change to the available missions.
//
//
//===========================================================
EDITED: Files have been adjusted as noted in the thread and re-uploaded.
These same instructions are included in the Zip file, but i wanted everyone to see that this is an easy install.
//===========================================================
//
// You are free to use and modify this resource provided you give credit
// where credit is due and provided you leave the original documentation
// intact where applicable. Please comment any changes you make to
// differentiate authors.
//
//
// This Voting system install was based on the HEAD(Release_1_3_0)
// versions starter.fps example. Although it should be compatible with
// all of them, the only install instructions I'm giving are for starter.fps.
//
//
// Place ClientVote.cs in the starter.fps\client\ui folder
//
//
// Place ServerVote.cs in the starter.fps\server\scripts folder
//
//
// Open starter.fps\Clent\init.cs in your editor and add
//
// exec("./ui/ClientVote.cs");
//
// at the bottom of the section that starts with "// Load up the shell GUIs"
//
//
// Open starter.fps\Server\scripts\game.cs in your editor and add
//
// exec("./ServerVote.cs");
//
// to the onServerCreated() function. Add it just below the line
//
// exec("./aiPlayer.cs");
//
//
// Open starter.fps\Client\scripts\default.bind.cs and add the
// following lines to the bottom of the file.
//
// // Bind the key to push the VoteGUI
// moveMap.bind(keyboard, "ctrl v", pushVoteGui);
//
//
// Finally, open starter.fps\Client\config.cs and add this line to your
// config at any point you please.
//
// moveMap.bind(keyboard, "ctrl v", pushVoteGui);
//
//
//
// Save all your changes and close your editor.
//
//
// That's it. Next time you run your game, you will be able to cast votes
// to change to the available missions.
//
//
//===========================================================
EDITED: Files have been adjusted as noted in the thread and re-uploaded.
About the author
#2
As it says:
"...you will be able to cast votes to change to the available missions."
10/29/2004 (2:44 am)
Yes, i would guess it is for map voting.As it says:
"...you will be able to cast votes to change to the available missions."
#3
"These same instructions are included in the Zip file" Nope
10/29/2004 (4:47 am)
oh, sorry... missed that my....My bad"These same instructions are included in the Zip file" Nope
#4
They are in "ServerVoteText.cs"
Just to give a more in depth answer to your first question, this is a completely self contained vote system. As long as it gets loaded, it works. It was designed to be compatible with the head, but should work on any game that has not radically altered most of the code. Even then, it might still work. When a client opens his voting GUI, the server sends him a list of missions he can vote on. The client chooses one and the server prepares the vote and notifies all the players. After the vote, the results are displayed and processed. This is as easy as I could make it with just a short period of time to get it together. I'm thinking of offering a second version in the future with some expanded capabilities and several cool new features.
10/29/2004 (9:20 am)
"These same instructions are included in the Zip file"They are in "ServerVoteText.cs"
Just to give a more in depth answer to your first question, this is a completely self contained vote system. As long as it gets loaded, it works. It was designed to be compatible with the head, but should work on any game that has not radically altered most of the code. Even then, it might still work. When a client opens his voting GUI, the server sends him a list of missions he can vote on. The client chooses one and the server prepares the vote and notifies all the players. After the vote, the results are displayed and processed. This is as easy as I could make it with just a short period of time to get it together. I'm thinking of offering a second version in the future with some expanded capabilities and several cool new features.
#7
Feel free to give this resource a rating you feel appropriate(Shameless hint)
:-)
10/31/2004 (8:37 pm)
Thank you. Much appreciated.Feel free to give this resource a rating you feel appropriate(Shameless hint)
:-)
#9
11/01/2004 (1:22 pm)
Andrea, did you ever get that fix I posted for you for wheeled vehicles?
#10
Say I have a mission file called hereToStay.mis but I have set the MissionInfo->name to "Here to stay" it will try to load Here to stay.mis which does not exist.
Edit: Removed my fix so Gonzo could address the issue,
Fix by Gonzo located below..
11/06/2004 (11:36 pm)
Problem with this is it uses the name of the mission within the .mis file under the MissionInfo object. If the name here is not the same as the mission name it wont load.Say I have a mission file called hereToStay.mis but I have set the MissionInfo->name to "Here to stay" it will try to load Here to stay.mis which does not exist.
Edit: Removed my fix so Gonzo could address the issue,
Fix by Gonzo located below..
#11
11/07/2004 (3:28 am)
Great resource, cheers mate.
#12
If anybody is using Sam's changes, it also appears that there is another change needed in ServerVote.cs in the function voteMapIsValid. The second if check also needs the call to getMissionDisplayName() removed and changed to
if( %file $= %choice )
11/07/2004 (2:03 pm)
I was half-way through making my own voting system when this appeared. Your system is INFINITELY better than what I was making... in fact I scrapped mine and replaced it with yours.If anybody is using Sam's changes, it also appears that there is another change needed in ServerVote.cs in the function voteMapIsValid. The second if check also needs the call to getMissionDisplayName() removed and changed to
if( %file $= %choice )
#13
@ Sam - I originally did it that way untill I started thinking about how TGE is great for SERVER-SIDE mapping. If you use your system, and the server has custom maps that the server owner created, no one will be able to select or vote on them unless they download those maps first. Plus, I was doing this on the HEAD example as a request and the only maps I was using were "StrongHold" and a copy of it called "WeakHold", lol. So I didn't at that time consider the display name being different from the file name. Thanks for bringing this inadaquacy to my attention.
Here's how I should have done it in the first place.....
In the ServerVote.cs replace "function voteMapIsValid()" with this one....
Next move down to line 293 and replace the load mission schedule with this one....
That's it. Nothing else need be done. This will properly address the problem with server side mapping AND names that are different from their display name. Also this change completely negates the need for the variable...
$GTC::Vote::MissionPath
on line 70 of ServerVote.cs so you can take it out completely.
11/07/2004 (4:30 pm)
@ William. Thanks, I appreciate the kind words. After I get some projects out of the way I'll be submittting a lot of different things for people to consider. @ Sam - I originally did it that way untill I started thinking about how TGE is great for SERVER-SIDE mapping. If you use your system, and the server has custom maps that the server owner created, no one will be able to select or vote on them unless they download those maps first. Plus, I was doing this on the HEAD example as a request and the only maps I was using were "StrongHold" and a copy of it called "WeakHold", lol. So I didn't at that time consider the display name being different from the file name. Thanks for bringing this inadaquacy to my attention.
Here's how I should have done it in the first place.....
In the ServerVote.cs replace "function voteMapIsValid()" with this one....
// This will be a helper function for serverCmdStartVote to assist it
// in verifying that it is recieving valid data or to return the proper
// path name to any function that knows the display name.
function voteMapIsValid(%choice, %needPath)
{
// Loop through the missions to see if the proper mission exists.
for(%file = findFirstFile($Server::MissionFileSpec); %file !$= ""; %file = findNextFile($Server::MissionFileSpec))
{
if(strStr(%file, "/CVS/") == -1)
{
if(getMissionDisplayName(%file) $= %choice)
{
// We have a match so we can load the mission
%found = "True";
// Since we have a match, there is no need to
// check the rest of the missions
break;
}
}
}
if(%needPath $= "True") { return %file; }
// Notify serverCmdStartVote of the result
return %found;
} Next move down to line 293 and replace the load mission schedule with this one....
schedule(5000, 0, "loadMission", voteMapIsValid($GTC_Vote_Choice, "True"));
That's it. Nothing else need be done. This will properly address the problem with server side mapping AND names that are different from their display name. Also this change completely negates the need for the variable...
$GTC::Vote::MissionPath
on line 70 of ServerVote.cs so you can take it out completely.
#14
Thanks,
Niko
01/29/2008 (2:27 pm)
Thanks a lot, Gonzo. This has helped me a lot with map voting, admin changing, and player kicking. Actually, it pretty much did all the work for me.Thanks,
Niko

Associate Joseph Euan