Home   Help Search Login Register  

Author Topic: add an action to a specific player  (Read 4403 times)

0 Members and 2 Guests are viewing this topic.

Offline Loyalguard

  • Former Staff
  • ****
Re: add an action to a specific player
« Reply #15 on: 21 Oct 2011, 14:56:07 »
Quote
How do you test multi scripts? How can you create a server and join to it as a client?

I test my scripts by starting a "server process" and client (or multiple clients) on my PC.  It is not hard, but there are a few tricks.  There is a great guide you can find here:

http://www.kellys-heroes.eu/files/tutorials/dedicated/

The guide is meant for an actual server seperate from your own PC but it still works for a single-PC setup.  You don't need to worry about some of these steps such as downloading the latest server executable, battle eye, game spy, etc. but it gives you an idea of what you need to do. 

Once I have the server running I open one more clients (by just double-clicking and opening multiple windows) in windowed mode so I can reduce their size and see them all at the same time.

When I get home I can look at my files and give you exact set up requirements.  Note you only want to do this if your computer can handle it and you may want to turn down video settings when you do it to improve performance.  Having a server and multiple clients open at the same time can really increase CPU-load even on good multi-core machines.

You can also test by starting your own MP host and then open a new window and connecting as a client, but results may not be reliable if you want to make sure a script(s) work on a dedicated server as both processes will still be "local".

Quote
Can I create multi mission without a special-player?

I think by default the first unit with a side places is the player (red circle), but I am pretty sure you can open it in the editor and make it just "playable" (purple circle) and it will still work without a dedicated default player.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: add an action to a specific player
« Reply #16 on: 24 Oct 2011, 19:26:44 »
We test again, but if not the pilota activate the action (download), he didn't received the specific message to him.

I attach the whole mission.

There are two init file (one sqs and one sqf). The sqf is the init of the patrol script (UPSMON) what I used.

1. If you have any idea why the counter-attack (generated in clearkras.sqs) are friendly to us (west side). But they are enemy, because our AI shoot them, but they didn't shoot back. If I run this generate script in the begining, they attak us, but if script run, when the village is clear, they act odd.

2. How to end a multi-mission? Can I activate a trigger with END #1 and it will end the mission, like in the single-player? Ot there is some special way?
Fix bayonet!

Offline Loyalguard

  • Former Staff
  • ****
Re: add an action to a specific player
« Reply #17 on: 25 Oct 2011, 18:36:42 »
I have downloaded it and will check it out and see if I can solve.

***UPDATE***

Ok, I think I know what was wrong.  In the code below I have removed the parts that are not relevant in order to shorten the post.

Your init.sqs starts like this:

Code: [Select]
? !isServer:goto "kliensresz"

#csakszerver

? (!isNil "download"): download = false
"download" addPublicVariableEventHandler {dummy = [_this select 1] execVM "apacs.sqf";}

;OTHER CODE HERE

#kliensresz

;OTHER CODE HERE

The problem is that ? !isServer:goto "kliensresz" means that the download public variable event handler (PVEH) will only be present on the server. So, if the player that is pilota is not the host, then pilota will not see the chats.  The server and all clients need the PVEH. So, change your code to this so that the PVEH is on all clients and the server:


Code: [Select]
? (!isNil "download"): download = false
"download" addPublicVariableEventHandler {dummy = [_this select 1] execVM "apacs.sqf";}

? !isServer:goto "kliensresz"

#csakszerver

;OTHER CODE HERE

#kliensresz

;OTHER CODE HERE

I have tested this and it should work.  Just realize that with the 16 second delay only on the server to have copilota join pilota sometimes things are slow and sometimes they are fast depending on who pilota is.

Now, I did notice that you did have other PVs under
Code: [Select]
#csakszerver that did not have PVEHs.  Do you need them?  Are they in other scripts.  I did not explore every file so I am not sure.  Just remember, you if you need them on the servers and clients you will have to make sure the code is outside of a !isServer condition.

Regarding MP mission endings, yes you can use a END #1 trigger (as long as the condition is met on the server and clients).

I hope this is helping...make that code change and see if it works,
« Last Edit: 26 Oct 2011, 01:53:16 by Loyalguard »

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: add an action to a specific player
« Reply #18 on: 26 Oct 2011, 07:52:56 »
Thank you!!! I'll try it soon.

=========== E D I T ============

Ok. There is my questions:

1. So if I understand well, addPublicVariableEventHandler is not some broadcast command and only add the EH on that machine where we run it: if only run on the server, it will be activated by the variable only in the server?

2. But publicVariable is a broadcast command, isn't it? If I set value of a variable only in the server and then call (in the server only) publicVariable, it will broadcast to the all clients, will it?
I ask this, because you suggested to remove this
Code: [Select]
? (!isNil "lehetobj1"): lehetobj1=false
publicVariable "lehetobj1"
lines from the onlyserver ("csakszerver" means onlyserver) part to the all clienst(and server) part. But I thought if this lines run on the server only, the publicVariable will broadcast the value of the variable to every client.
« Last Edit: 27 Oct 2011, 19:14:34 by bardosy »
Fix bayonet!

Offline Loyalguard

  • Former Staff
  • ****
Re: add an action to a specific player
« Reply #19 on: 30 Oct 2011, 01:15:50 »
1. Correct, addPublicVariableEventHandler does not broadcast anything...it does just the opposite, it creates an event handler that waits for something to be broadcast to it.  If you add a PVEH only on the server, if the PV is later broadcasted, the PVEH will only fire on the server.

2. Also correct, when you use the publicVariable command, it will broadcast that variable (and its value) to every other machine. If broadcasted from the server, it will send it to all clients.  If broadcast from a client, it will be sent to the server and all other clients.

Regarding the code you posted, I do not remember that one exactly, but in general, if the server and clients will all need to be able to access the value of lehetobj1, then you should initialize it on all of them.  Don't just rely on sending it from the server.  Also, if you are initializing it on all machines and at the beginning of the mission (in an init.sqs or init.sqf) you probably do not need to use publicVariable to broadcast the most current value because all the machines already have it AND if you might have JIP players, you may accidentally overwrite the value and break your mission (or part of it).
« Last Edit: 30 Oct 2011, 03:18:23 by Loyalguard »

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: add an action to a specific player
« Reply #20 on: 04 Nov 2011, 10:15:12 »
Thank you!

These parts (the download and apacs scripts) works fine!

But the all mission is ruined those strange bugs (I thing they are connected and they have one reason):
1. After a few minutes gameplay, players start to get negative points. (In the begining, we got positive points for killing enemy, but once our all points turn into negative and then we got more negative points for killing enemy).
2. After a few minutes gameplay, players cannot heal each other. (The wounded teammate are dying in the ground and we got the Heal menu, but it's ineffective: nothing happened if we press the Heal action).
3. After a few minutes gameplay, enemy became friendly to us (never shoot us).

Did you ever experienced this? Someone in the BIS forum told me, this is because the First Aid module. Is it possible? But many mission use the BIS's First Aid Module...
Fix bayonet!

Offline Loyalguard

  • Former Staff
  • ****
Re: add an action to a specific player
« Reply #21 on: 04 Nov 2011, 15:33:11 »
Unfortunately I do not have much eperience with the First Aid Module.  I took a quik look at the code in some of the module's scripts and I did not see anything that would clearly cause your issues with negative points and enemies becoming friendly.  There could be a connection to the heal issues of course, not sure without experiencing it.