MP Info Module System Warband Modding: Server and Client Events

Users who are viewing this thread

Yoshiboy said:
Oh right. Well AI troops should be fine - they work the same as singleplayer. What you're getting wrong is something in module_skins.
Have you actually tried it? because I know my way around module_skins, and all I did was change the male_body mesh to something different (didn't matter what) and the game crashed when the ai tried to spawn with it...
 
WookieWarlord said:
Yoshiboy said:
Oh right. Well AI troops should be fine - they work the same as singleplayer. What you're getting wrong is something in module_skins.
Have you actually tried it? because I know my way around module_skins, and all I did was change the male_body mesh to something different (didn't matter what) and the game crashed when the ai tried to spawn with it...

Yeah, I did it in hunt fine.
 
Did anyone actually get this tutorial to work. Not just for clients, but for the host too? I'm having a lot of problems with this.
 
First problem is that the host player doesn't get the client event, so the sound won't play for them. I could solve this problem by playing the sound locally for each client from the item trigger itself (or rather a script called from the trigger). But when I do that, clients hear 2 shots (one from the trigger and one from the MP event).

So the next problem I have is how to check if the player receiving the client event was the same player that sent it to the server (the player that fired the shot) so I can only player the sound if they are not the same player, but I can't get it to work.

Then there's also AI. I'm not sure it even works for AI, haven't really tested it too much and when I did the code was so modified (in my attempt to solve my problems) that I don't know if it was my fault.

Finally, another strange issue (this one really confuses me) occurs for the host: for some reason it breaks chat/message display. What I mean is, the host can't see any messages; chat, kill messages, nothing. The behavour for this seems to be strange too, as sometimes it works up until another client joins the host's game, and once it breaks the only way to fix it (even for offline) is to restart M&B. I'm not sure, but my guess is it has something to do with sending/receiving events.

Do you have any ideas?
 
For the first one try this:

Change this code:
Code:
     # NEW EVENTS ADDED
    
     (eq,":event_type", multiplayer_event_sound_made_by_player),
     (neq,":player_no",0),
     (store_script_param, ":sound", 3),
    
          (get_max_players, ":num_players"),
          (try_for_range, ":cur_player", 1, ":num_players"), # Now starting from 0
            (multiplayer_send_2_int_to_player, ":cur_player", multiplayer_event_sound_at_player, ":sound",":player_no"),
          (try_end),
    
     (else_try),
    
     # END NEW EVENTS ADDED

To this:

Code:
     # NEW EVENTS ADDED
    
     (eq,":event_type", multiplayer_event_sound_made_by_player),
     (neq,":player_no",0),
     (store_script_param, ":sound", 3),
    
          (get_max_players, ":num_players"),
          (try_for_range, ":cur_player", 0, ":num_players"), # start from 1, 0 is server
            (multiplayer_send_2_int_to_player, ":cur_player", multiplayer_event_sound_at_player, ":sound",":player_no"),
          (try_end),
    
     (else_try),
    
     # END NEW EVENTS ADDED

So now perhaps starting from 0 (when the hosting player is also the server) maybe it will work.

So the next problem I have is how to check if the player receiving the client event was the same player that sent it to the server (the player that fired the shot) so I can only player the sound if they are not the same player, but I can't get it to work.

Here you might want to compare the player which send the event ":player_no", to the variable for the player number which we are looping over ":cur_player", if they are equal you know you are dealing with the player who send the event in the first place.

Then there's also AI. I'm not sure it even works for AI, haven't really tested it too much and when I did the code was so modified (in my attempt to solve my problems) that I don't know if it was my fault.

All the bot AI is handled by the server and should sync automatically. It sort of depends what you want to do but just running these commands server side should work out.

Finally, another strange issue (this one really confuses me) occurs for the host: for some reason it breaks chat/message display. What I mean is, the host can't see any messages; chat, kill messages, nothing. The behavour for this seems to be strange too, as sometimes it works up until another client joins the host's game, and once it breaks the only way to fix it (even for offline) is to restart M&B. I'm not sure, but my guess is it has something to do with sending/receiving events.

This sounds very weird, maybe a bug in warband. I don't know. I don't have much experience with simply hosting games.

Hope that helps a bit.
 
Well, I was testing your recommended changes and my computer crashed, and now my primary (win 7) hard drive keeps crashing so I'm stuck on my old XP drive. And it still didn't solve the problem.  :sad:

Right now my priority is to fix whatever's wrong with my hard drive.
 
Well, turns out it was my video card. I've replaced it for now and everything's back up and running, but I still can't get this to work. I've tried adding a (neq,":player_no",":cur_player") to the try_for_range, but the shooting client still gets the client event and thus hears the sound again. The whole broken message thing is really hindering my debugging process. Is there another way to print debug messages or variables to the screen?
 
Had to post about how awesome this tutorial is, it greatly simplifies adding multiplayer sounds, and now I don't have to read through 40k lines of code :grin:
 
mr.master said:
Jezze said:
mr.master said:
Jezze said:
I cannot hear the shots from bots somehow, I should hear them too, right?
Nope actually. Needs another script for it.

Do you know where I can find that script needed for the bots?
Well, the hunt mode has it. I could post it here also. Note that it's not made by me. It was made by the hunt team.

Ok, thanks. I'll look for it :wink:.
 
Jezze said:
mr.master said:
Jezze said:
mr.master said:
Jezze said:
I cannot hear the shots from bots somehow, I should hear them too, right?
Nope actually. Needs another script for it.

Do you know where I can find that script needed for the bots?
Well, the hunt mode has it. I could post it here also. Note that it's not made by me. It was made by the hunt team.

Ok, thanks. I'll look for it :wink:.
Look in module scripts. It's at the bottom.
 
Back
Top Bottom