HollowAddiction Posted June 2, 2014 Report Share Posted June 2, 2014 Players can right-click on a specified item(We used a briefcase) and vote for day or night, and it consumes the item. If enough players vote it will broadcast a warning that the vote has been cast and it will become day/night with a countdown of 5 mins. We have done some of the coding but have run into issues with the script. below is a download of what we have, anyone who helps will be credited. Thanks Download: http://craftdoge.com/downloads/wip.html Link to comment Share on other sites More sharing options...
DeanReid Posted June 2, 2014 Report Share Posted June 2, 2014 This sounds great, but I see a problem of where, from what I know of is that the mission file cant manually set the time of the server with out it reverting back to the time it was at previously, This would have to be somehow implemented through either a dll file or dare I say it.. The Server.pbo Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 2, 2014 Author Report Share Posted June 2, 2014 we already have a solution for that, same way infistar does it, the issue is in the actual script. rightclick and click vote has no effects and we see no errors in the code Link to comment Share on other sites More sharing options...
MGT Posted June 2, 2014 Report Share Posted June 2, 2014 You would need a script running server side to count the votes and implement the change _votenight= 0; _voteday= 0; if (_txt in ['!votenight']) then _votenight = _votenight+ 1; if (_txt in ['!voteday']) then _voteday = _voteday+ 1; if (_votenight> 10) then if (_voteday> 10) then Problems I can see is it can't differentiate between different players voting, so 1 player could spam the votes to get night/day Link to comment Share on other sites More sharing options...
DeanReid Posted June 2, 2014 Report Share Posted June 2, 2014 You could possibly set it to check the player UID Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 2, 2014 Author Report Share Posted June 2, 2014 You would need a script running server side to count the votes and implement the change _votenight= 0; _voteday= 0; if (_txt in ['!votenight']) then _votenight = _votenight+ 1; if (_txt in ['!voteday']) then _voteday = _voteday+ 1; if (_votenight> 10) then if (_voteday> 10) then Problems I can see is it can't differentiate between different players voting, so 1 player could spam the votes to get night/day we've done the above, also its set to not differentiate so we can test. the issue we have is the actual function of voting and it initiating the script Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 2, 2014 Author Report Share Posted June 2, 2014 You could possibly set it to check the player UID yes, we have all the side functions set, we need to get it actually working, as in you vote, and it initializes the script Link to comment Share on other sites More sharing options...
Panadur Posted June 3, 2014 Report Share Posted June 3, 2014 hmm i think i found an error.. private ["_day_votes","_night_votes","_time","_vote","_day","_night"]; _vote = _this select 1; _day_votes = 0; _night_votes = 0; _time = 30; if (_vote == 1) then { _day_votes = _day_votes + 1; }; if (_vote == 2) then{ _night_votes = _night_votes + 1; }; while {true} do { _day = _day_votes; _night = _night_votes; [] spawn { waitUntil {_day > 5}; set_day = [player,date,11]; publicVariableServer "set_day"; //Send needed values to server. set_day = []; }; [] spawn { waitUntil {_night > 5}; set_night = [player,date,21]; publicVariableServer "set_day"; //Send needed values to server. set_night = []; }; sleep _time; }; i think it should send the variable set_night to server instead of set_day . Link to comment Share on other sites More sharing options...
crazzeddemonn Posted June 3, 2014 Report Share Posted June 3, 2014 Is this working yet? Link to comment Share on other sites More sharing options...
Cash Posted June 3, 2014 Report Share Posted June 3, 2014 Why worry about the UID? Just make the item a full briefcase :) If someone wants to blow 5 briefcases so he can take a stroll in the moonlight, who are we to stop him? lol /cash Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 3, 2014 Author Report Share Posted June 3, 2014 Why worry about the UID? Just make the item a full briefcase :) If someone wants to blow 5 briefcases so he can take a stroll in the moonlight, who are we to stop him? lol /cash well because different servers run different currencies, for instance on my server a briefcase is the equivalence of a gold bar Link to comment Share on other sites More sharing options...
lmapper Posted June 3, 2014 Report Share Posted June 3, 2014 Right Click on brief-cases ? Wow, why so ? I think addAction better ? You can add brief removing. ZamboniBambino 1 Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 3, 2014 Author Report Share Posted June 3, 2014 Is this working yet? still a WIP Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 3, 2014 Author Report Share Posted June 3, 2014 Right Click on brief-cases ? Wow, why so ? I think addAction better ? You can add brief removing. because we want to stray away from scroll wheel, we feel its cleaner xSkilledElitex 1 Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 thevisad made a good point, this would take from realism. curious on anyone's thoughts Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 Still Looking for help, Bump Link to comment Share on other sites More sharing options...
lmapper Posted June 4, 2014 Report Share Posted June 4, 2014 Keep calm, dude. You can bump your topic every 24h only. Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 Keep calm, dude. You can bump your topic every 24h only. I am calm thanks, i forgot i bumped last night as i was very tired when i did it. Link to comment Share on other sites More sharing options...
ZamboniBambino Posted June 4, 2014 Report Share Posted June 4, 2014 It's a bad idea to use something that is intended as an item-context action as a global-context action. That's what addAction is used for -- if it's your preference, that's fair enough, but this is easier to perform by having a custom dialogue or an addAction. I would recommend that the easiest thing to do to debug it is to check your RPT, consult with the BIstudio community wiki, and ARMAholic to query any errors you encounter. If you're unsure, the wiki and google is your friend. :lol: Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 It's a bad idea to use something that is intended as an item-context action as a global-context action. That's what addAction is used for -- if it's your preference, that's fair enough, but this is easier to perform by having a custom dialogue or an addAction. I would recommend that the easiest thing to do to debug it is to check your RPT, consult with the BIstudio community wiki, and ARMAholic to query any errors you encounter. If you're unsure, the wiki and google is your friend. :lol: Thats a good point, We just wanted to not clutter up the scrollwheel options anymore then we already have but i agree. thanks We have been checking for errors, but it's not showing any. We have pretty much hit a brick wall. xSkilledElitex 1 Link to comment Share on other sites More sharing options...
ZamboniBambino Posted June 4, 2014 Report Share Posted June 4, 2014 Thats a good point, We just wanted to not clutter up the scrollwheel options anymore then we already have but i agree. thanks We have been checking for errors, but it's not showing any. We have pretty much hit a brick wall. Some quick information you may find useful to know: //voteloop.sqf private ["_day_votes","_night_votes","_time","_vote","_day","_night"]; The variables you use to track how many votes are temporary variables (which are prefixed with _). You need to replace these with permanent variables without the _. Here's an example of how you could accomplish what you're looking for. // My Handler "_my_var" addPublicVariableEventHandler { // Call a function to check the value of the permanent variable on the server _voteResult = _this select 0; [] call MyFunctionForCheckingPermanentVariable // And so on and so on.. }; // HowManyDayNight.sqf //When the server loads this, it will set this to 0 MY_PROGRAM_DAY_VOTES = 0; MY_PROGRAM_NIGHT_VOTES = 0; My_Function_Add_Day_Votes ={ private["_voteType"]; _voteType = _this select 0; // Suppose some cheeky other program has the same name as our permanent variable, we always set it to a value we want if it's not how we expect it. if(typeName MY_PROGRAM_DAY_VOTES != "SCALAR") then { MY_PROGRAM_DAY_VOTES = 0; }; // Same as above if(typeName MY_PROGRAM_NIGHT_VOTES != "SCALAR") then { MY_PROGRAM_NIGHT_VOTES = 0; }; if(_voteType == "DAY") then { MY_PROGRAM_DAY_VOTES = MY_PROGRAM_DAY_VOTES + 1; } else { MY_PROGRAM_NIGHT_VOTES = MY_PROGRAM_NIGHT_VOTES +1; }; }; You need to have the folllowing things to make it work: On the client side, have the user submit their client UID and their vote. You need the Client UID because you want to prevent them from voting twice. On the server side, you need to have an array which stores the person's UID in a permanent variable along with their vote. I.e. [123456789,"DAY"] -- this allows you to have persistence of who is voting, and write functions to find out who has voted. On the server side you need to have the array counted and then when it hits a threshold, execute another function or code which changes to day/night. So for instance: // My Server script MY_VOTES = []; My_Program_Add_Vote ={ private ["_voteType","_personsUID"]; _voteType = _this select 0; _personsUID = _this select 1; // What if they're cheeky and change the vote type to "BAH" ? Or there is an error? etc. if (!_voteType in ["DAY","NIGHT"]) then { // Do some more checking.. (i.e. Are they already in this list?) // Now add the person to the list.. MY_VOTES set[(count MY_VOTES),[_personsUID,_voteType]]; /* * MY_VOTES now looks like: MY_VOTES [ [1234567,"DAY"] ] */ }; }; Keep going, you'll get there. AG.Ndogg97 1 Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 Some quick information you may find useful to know: //voteloop.sqf private ["_day_votes","_night_votes","_time","_vote","_day","_night"]; The variables you use to track how many votes are temporary variables (which are prefixed with _). You need to replace these with permanent variables without the _. Here's an example of how you could accomplish what you're looking for. // My Handler "_my_var" addPublicVariableEventHandler { // Call a function to check the value of the permanent variable on the server _voteResult = _this select 0; [] call MyFunctionForCheckingPermanentVariable // And so on and so on.. }; // HowManyDayNight.sqf //When the server loads this, it will set this to 0 MY_PROGRAM_DAY_VOTES = 0; MY_PROGRAM_NIGHT_VOTES = 0; My_Function_Add_Day_Votes ={ private["_voteType"]; _voteType = _this select 0; // Suppose some cheeky other program has the same name as our permanent variable, we always set it to a value we want if it's not how we expect it. if(typeName MY_PROGRAM_DAY_VOTES != "SCALAR") then { MY_PROGRAM_DAY_VOTES = 0; }; // Same as above if(typeName MY_PROGRAM_NIGHT_VOTES != "SCALAR") then { MY_PROGRAM_NIGHT_VOTES = 0; }; if(_voteType == "DAY") then { MY_PROGRAM_DAY_VOTES = MY_PROGRAM_DAY_VOTES + 1; } else { MY_PROGRAM_NIGHT_VOTES = MY_PROGRAM_NIGHT_VOTES +1; }; }; You need to have the folllowing things to make it work: On the client side, have the user submit their client UID and their vote. You need the Client UID because you want to prevent them from voting twice. On the server side, you need to have an array which stores the person's UID in a permanent variable along with their vote. I.e. [123456789,"DAY"] -- this allows you to have persistence of who is voting, and write functions to find out who has voted. On the server side you need to have the array counted and then when it hits a threshold, execute another function or code which changes to day/night. So for instance: // My Server script MY_VOTES = []; My_Program_Add_Vote ={ private ["_voteType","_personsUID"]; _voteType = _this select 0; _personsUID = _this select 1; // What if they're cheeky and change the vote type to "BAH" ? Or there is an error? etc. if (!_voteType in ["DAY","NIGHT"]) then { // Do some more checking.. (i.e. Are they already in this list?) // Now add the person to the list.. MY_VOTES set[(count MY_VOTES),[_personsUID,_voteType]]; /* * MY_VOTES now looks like: MY_VOTES [ [1234567,"DAY"] ] */ }; }; Keep going, you'll get there. Finally some help! Cheers mate AG.Ndogg97 1 Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 Well unfortunately My knowledge on writing scripts is horribly limited and the other person working on it has decided to stop. So sad to say we are abandoning the project. If anyone wants to pick it up feel free. Link to comment Share on other sites More sharing options...
ZamboniBambino Posted June 4, 2014 Report Share Posted June 4, 2014 Well unfortunately My knowledge on writing scripts is horribly limited and the other person working on it has decided to stop. So sad to say we are abandoning the project. If anyone wants to pick it up feel free. Don't give up! :) Your knowledge doesn't get less limited by stopping. :D I was planning on including voting in general in FairServer, anyway, so if you want to help on that, you're more than welcome, but either way, keep going ^_^ Link to comment Share on other sites More sharing options...
HollowAddiction Posted June 4, 2014 Author Report Share Posted June 4, 2014 What exactly is fairserver? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now