OSP Code MP Poll and admin enhancements for mod creators (updated for 1.126)

Users who are viewing this thread

DanyEle said:
Very useful code! You'll be given sure credits in my mod  :smile: Thank you very much.
You're welcome. Be sure to read and use the small code fixes and enhancements from a few posts back in this thread. I haven't updated or tested this code for years, so hopefully it all still works properly with the latest warband module system and executables.
 
Vornne said:
DanyEle said:
Very useful code! You'll be given sure credits in my mod  :smile: Thank you very much.
You're welcome. Be sure to read and use the small code fixes and enhancements from a few posts back in this thread. I haven't updated or tested this code for years, so hopefully it all still works properly with the latest warband module system and executables.

Oh, that could be the reason for i was having a couple of problems in dedicated servers. Are these the "Fixes" you're talking abot?

Vornne said:
I'm guessing "give gold" is a custom presentation you added? In that case, typing in a text box doesn't block other triggers using key_pressed from running - I forget whether it is a new problem in warband or it's always been that way, and I couldn't find the report on the tracker that I vaguely remember - so in PW I've added checks to every custom control trigger to make sure no text input presentations are active, like this:
Code:
  ("cf_no_input_presentation_active",
   [(neg|is_presentation_active, "prsnt_multiplayer_get_poll_question"),
    (neg|is_presentation_active, "prsnt_multiplayer_get_admin_message"),
    ]),
Code:
multiplayer_admin_message_stored_player = (
  0, 0, 0, [(key_clicked, key_f11),(call_script, "script_cf_no_input_presentation_active")], [
Also, make sure to use the overlay_obtain_focus operation for text boxes (added in a later warband version than 1.126) so players don't have to click the text box before typing, like this:
Code:
(overlay_obtain_focus, "$g_presentation_obj_get_poll_question_1"),
...
(overlay_obtain_focus, "$g_presentation_obj_get_admin_message_1"),
I should really update the code some time; but the latest stuff is in PW 4, which is an almost total rewrite of the module system, with a general chat message system for many types, so it would need quite a bit of work to make it native compatible again.

or

Vornne said:
Blabil: sure. The height is almost half the size of the original, and the text size is 85%, but I could make it smaller if you want (and have got good eyesight); also, would you want the changed poll keys and the "escape doesn't vote no" bit? Do you think the colours and text outline make the poll more readable, or less? I tried various colours for background and font, but white text seemed the best; the idea behind the red background was that people could get used to seeing it out of the corner of their eye and ignoring it, when busy with an intense fight.

Here it is mostly unmodified, anyway. Apply it according to the instructions at the end of the first post, except edit the files in your Native module rather than the module system (make backups first). Note that you must add the "str_poll_keys" bit on the very last line of strings.txt, or else a lot of strings in game will be wrong. Still give me feedback on how you would like it changed though; I'm fairly good at lining things up and fixing glitches, but no professional UI designer :wink:.
@@ -140,8 +140,8 @@


prsnt_multiplayer_poll 3 0 2
-60.000000  65 2124 1 1000 911 2 72057594037927936 1441151880758558776 921 2 72057594037927936 0 922 2 72057594037927936 68 729 2 1 50 730 2 1 50 926 2 72057594037927936 1 729 2 1 37500 730 2 1 4500 925 2 72057594037927936 1 4 0 31 2 144115188075856804 0 2121 3 1224979098644774912 144115188075856805 720575940379279851 2105 2 1224979098644774912 216172782113785456 2320 2 0 1224979098644774912 910 3 72057594037927936 216172782113785490 16 5 0 31 2 144115188075856804 1 2350 2 0 144115188075856805 910 3 72057594037927936 216172782113785488 16 5 0 31 2 144115188075856804 2 2350 2 0 144115188075856805 910 3 72057594037927936 216172782113785489 16 5 0 31 2 144115188075856804 3 2121 3 1224979098644774912 144115188075856805 720575940379279851 2105 2 1224979098644774912 216172782113785456 2320 2 0 1224979098644774912 2335 2 1 144115188075856806 2335 2 2 144115188075856807 910 3 72057594037927936 216172782113785491 131088 5 0 2133 2 72057594037927936 144115188075856805 2133 2 72057594037927937 144115188075856806 2335 2 0 144115188075856768 2335 2 1 144115188075856769 910 3 72057594037927936 216172782113785492 131088 3 0 921 2 72057594037927936 16777215 4 0 2147483679 2 144115188075856804 3 2147483679 2 144115188075856804 4 729 2 1 400 730 2 1 100 926 2 72057594037927936 1 5 0 729 2 1 50 730 2 1 70 926 2 72057594037927936 1 729 2 1 750 730 2 1 60 929 2 72057594037927936 1 3 0 2370 1 1224979098644774913 2121 3 144115188075856572 144115188075856809 1224979098644774913 2133 2 72057594037927936 144115188075856572 910 3 144115188075856573 216172782113785493 32776 921 2 144115188075856573 16777215 729 2 1 790 730 2 1 60 926 2 144115188075856573 1 77 1 2 77 1 3 902 1 999999
-61.000000  29 2071 1 1224979098644774912 4 0 1073741895 1 1 71 1 3 32 2 1224979098644774912 500 389 2 22 0 78 0 902 1 0 5 0 71 1 2 32 2 1224979098644774912 500 389 2 22 1 78 0 902 1 0 3 0 2370 1 1224979098644774913 2121 3 1224979098644774914 144115188075856809 1224979098644774913 4 0 2147483679 2 1224979098644774914 144115188075856572 4 0 2147483678 2 1224979098644774914 0 78 0 902 1 0 5 0 2133 2 144115188075856572 1224979098644774914 2133 2 72057594037927936 144115188075856572 920 2 144115188075856573 216172782113785493 3 0 3 0
-60.000000  69 2124 1 1000 911 2 72057594037927936 1441151880758558776 921 2 72057594037927936 1114112 922 2 72057594037927936 68 729 2 1 10 730 2 1 10 926 2 72057594037927936 1 729 2 1 40500 730 2 1 2500 925 2 72057594037927936 1 910 3 72057594037927936 216172782113786969 65552 921 2 72057594037927936 16777215 729 2 1 415 730 2 1 15 926 2 72057594037927936 1 729 2 1 850 730 2 1 850 925 2 72057594037927936 1 4 0 31 2 144115188075856804 0 2121 3 1224979098644774912 144115188075856805 720575940379279851 2105 2 1224979098644774912 216172782113785456 2320 2 0 1224979098644774912 910 3 72057594037927936 216172782113785490 65552 5 0 31 2 144115188075856804 1 2350 2 0 144115188075856805 910 3 72057594037927936 216172782113785488 65552 5 0 31 2 144115188075856804 2 2350 2 0 144115188075856805 910 3 72057594037927936 216172782113785489 65552 5 0 31 2 144115188075856804 3 2121 3 1224979098644774912 144115188075856805 720575940379279851 2105 2 1224979098644774912 216172782113785456 2320 2 0 1224979098644774912 2335 2 1 144115188075856806 2335 2 2 144115188075856807 910 3 72057594037927936 216172782113785491 65552 5 0 2133 2 72057594037927936 144115188075856805 2133 2 72057594037927937 144115188075856806 2335 2 0 144115188075856768 2335 2 1 144115188075856769 910 3 72057594037927936 216172782113785492 65552 3 0 921 2 72057594037927936 16777215 729 2 1 415 730 2 1 35 926 2 72057594037927936 1 729 2 1 850 730 2 1 850 925 2 72057594037927936 1 2370 1 1224979098644774913 2121 3 144115188075856572 144115188075856809 1224979098644774913 2133 2 72057594037927936 144115188075856572 910 3 144115188075856573 216172782113785493 98312 921 2 144115188075856573 16777215 729 2 1 860 730 2 1 15 926 2 144115188075856573 1 729 2 1 850 730 2 1 850 925 2 144115188075856573 1 77 1 66 77 1 67 77 1 68 902 1 999999
-61.000000  33 2071 1 1224979098644774912 4 0 71 1 67 32 2 1224979098644774912 500 389 2 22 0 78 0 902 1 0 5 0 71 1 66 32 2 1224979098644774912 500 389 2 22 1 78 0 902 1 0 5 0 71 1 68 32 2 1224979098644774912 500 78 0 902 1 0 3 0 2370 1 1224979098644774913 2121 3 1224979098644774914 144115188075856809 1224979098644774913 4 0 2147483679 2 1224979098644774914 144115188075856572 4 0 2147483678 2 1224979098644774914 0 78 0 902 1 0 5 0 2133 2 144115188075856572 1224979098644774914 2133 2 72057594037927936 144115188075856572 920 2 144115188075856573 216172782113785493 3 0 3 0


prsnt_tutorial_show_mouse_movement 3 0 2
@@ -1,5 +1,5 @@
stringsfile version 1
3161
3162
str_no_string NO_STRING!
str_empty_string _
str_yes Yes.
@@ -1680,11 +1680,11 @@
str_poll_change_map_to_s1_by_s0 {s0}_started_a_poll_to_change_map_to_{s1}.
str_poll_change_map_to_s1_and_factions_to_s2_and_s3_by_s0 {s0}_started_a_poll_to_change_map_to_{s1}_and_factions_to_{s2}_and_{s3}.
str_poll_change_number_of_bots_to_reg0_and_reg1_by_s0 {s0}_started_a_poll_to_change_bot_counts_to_{reg0}_and_{reg1}.
str_poll_kick_player Poll_to_kick_player_{s0}:_1_=_Accept,_2_=_Decline
str_poll_ban_player Poll_to_ban_player_{s0}:_1_=_Accept,_2_=_Decline
str_poll_change_map Poll_to_change_map_to_{s0}:_1_=_Accept,_2_=_Decline
str_poll_change_map_with_faction Poll_to_change_map_to_{s0}_and_factions_to_{s1}_versus_{s2}:_1_=_Accept,_2_=_Decline
str_poll_change_number_of_bots Poll_to_change_number_of_bots_to_{reg0}_for_{s0}_and_{reg1}_for_{s1}:_1_=_Accept,_2_=_Decline
str_poll_kick_player Poll_to_kick_player_{s0}
str_poll_ban_player Poll_to_ban_player_{s0}
str_poll_change_map Poll_to_change_map_to_{s0}
str_poll_change_map_with_faction Poll_to_change_map_to_{s0}_and_factions_to_{s1}_versus_{s2}
str_poll_change_number_of_bots Poll_to_change_number_of_bots_to_{reg0}_for_{s0}_and_{reg1}_for_{s1}
str_poll_time_left ({reg0}_seconds_left)
str_poll_result_yes The_poll_is_accepted_by_the_majority.
str_poll_result_no The_poll_is_rejected_by_the_majority.
@@ -3161,3 +3161,4 @@
str_offer_gift_description _improve_my_standing_by_offering_a_gift.
str_resolve_dispute_description _improve_my_standing_by_resolving_a_dispute.
str_feast_wedding_opportunity _If_your_betrothed_and_her_family_are_present,_then_this_may_be_an_opportunity_for_you_to_celebrate_the_wedding.
str_poll_keys F8_=_Accept,_F9_=_Decline,_F10_=_Abstain
On a side note: does anyone know what the variable_uses.txt file is for? It often has conflicts when merging or patching with git; so I've not bothered to change it at times, which didn't seem to affect anything.

NaglFaar: well, the developers haven't rejected the admin message feature as far as I am aware; only ignored or  haven't seen the requests on the forums. They might not be against implementing it; though probably not using my code, as it isn't ideal due to limitations of the module system.

Arch3r: I don't understand how that would work, as on the server the poll requester is known, but the messages sent to all the other clients don't contain it. Also, the problematic poll is the singular "change map and factions" which uses all values of multiplayer_send_4_int_to_player: poll id, map id, faction 1 id, faction 2 id; I got around this by storing the poll requester id in the unused upper bits of faction 1 - which makes it unrecognisable to unpatched clients. I would love to be proven wrong about the possibility of patching the server to show name and reason without breaking compatibility...

EDIT: Fixed the dedicated servers bugs. I just checked the code once more and found a couple of errors , then changed some constants. Thank you very much again for sharing this  :roll:  :grin:
 
DanyEle said:
Oh, that could be the reason for i was having a couple of problems in dedicated servers. Are these the "Fixes" you're talking abot?
Hmm, I don't know: what are the problems, more specifically? The code being written for an old version of the module system, there are a few bits that won't work properly if just copied directly - conflicting constants like slot and network event numbers need to be changed to something unique.
DanyEle said:
or
Vornne said:
Blabil: sure. The height is almost half the size of the original, and the text size is 85%

...
That was in the context of a request for only the poll presentation appearance applied to the Native version at the time: nothing relevant for another mod, now.
 
Can this work for another mod? These days that is I remember with EI as an example we had the polling system and IMO it would be great to have admins in more control of poll spamming and less obstructive as you intended but yes some scripting needs to be for at least the nearly current module system. I cannot get it to work right now.
 
usnavy30 said:
Can this work for another mod? These days that is I remember with EI as an example we had the polling system and IMO it would be great to have admins in more control of poll spamming and less obstructive as you intended but yes some scripting needs to be for at least the nearly current module system. I cannot get it to work right now.
It could work for any mod developer who takes the time to update and integrate it with their module system; but for players, the .txt files are very outdated and would only apply to a clean Native module of the correct version. This is an example or resource for coders, not a standalone mod targeted at players (any more).
 
Back
Top Bottom