Socrate 10 Posted November 14, 2009 So what happen to the variable assigned in the editor to the player when he die? I mean : suppose i've named the player "p1", and my init.sqf i write variable = player; is p1 == variable true or false? Furthermore i don't understand if the p1 (so the name of the player object) is a variable or not... Another doubt is: suppose i've added a killed event handler to the player. In the killed.sqf i've the two variable _killed and _killer. What does contain the _killed variable? is it a reference to the respawned player or a reference to the dead body of the player? Share this post Link to post Share on other sites
Heatseeker 0 Posted November 15, 2009 Killed EH returns the Killed and the Killer, who was killed and who killed him. I never thought about it but i dont know if the player retains his variable name after respawn or if it works like objects and empty vehicles.. should be easy to test though. Share this post Link to post Share on other sites
dissaifer 10 Posted November 15, 2009 Socrate, it looks like you are confusing some things. I am assuming that you named the player 'p1' in the editor, correct? p1 then becomes the variable (the name referencing that character), not the thing you wrote in your init.sqf, but an actual variable that you can access. 'player' is a function that allows you to determine if the character that you are referencing is a human player and a few other things you don't need to worry about just yet. Now, in your init.sqf you are assigning the word 'variable' as a variable to the player. You would have the words 'p1' and 'variable' set to the same character, assuming the human player is playing the named 'p1' character. So, when you write p1 == variable you are basically saying is the player equal to the player, which would always be true. Share this post Link to post Share on other sites
Socrate 10 Posted November 15, 2009 wait wait : 1) This is the sintax of the player command from the scripting command reference: Object = player So using a variable (suppose we call it variable), like this: variable = player; variable contains the player object (so actually a reference to the player). Right? If we named in the editor the player p1 also p1 is a variable containing a reference to the player object. right? So actually: p1 == variable will return TRUE. Right? 2) Ok my problem is this: i'm working a revive script similar to norrin one. Suppose that EACH player add to himself a KILLED EVENT HANDLER. So when the player die in the killed.sqf i've the two variables: _killed = _this select 0 _killer = _this select 1 My question is: what does contain the _killed variable? The player in a MP mission obviusly after been killed respawn at the Respawn_West( East etc). So when the event handler fires up the _killed variable contains a reference to: 1) the previus player object ( so actually to the dead body) 2) to the respawned player object? Related to this 2 question is the name assigned to a player in the editor because if the _killed refence the dead body object how can i reference the new respawned player object ? ( probably with the variable used in the editor like p1,p2 etc right? ps: sorry for my bad english Share this post Link to post Share on other sites
dissaifer 10 Posted November 15, 2009 Okay... there are a few things going on here. You have two variables assigned to the same 'object' player in the case of a single player. That would be variable and p1 are both references to player. If there is only one player this, p1 == variable == player, is always true. Now, you've assigned 'variable' as a global variable to player in the init.sqf. In MP the init.sqf is executed for each player. so if you don't have code to control that 'variable' assignment, 'variable' will be equal to the last player that executed the init.sqf. So, the code looks like this: player addEventHandler ["killed", "hint format['Killed by %1',_this select 1]"]; It's hard to tell if _killed or _killer are actually referencing in that code block. We'll pretend it is referencing the addEventHandler, for the sake of it, _killed would be the name of the unit that was killed, _killer would be the name of the unit that did the killing (like in the code reference above). If you wanted to respawn the unit, you would use the name from _killed, because that would be the reference to the unit that just died. I suspect that something isn't quite right with your code. Here is a debugging tip for you. Add a hint or hintsilent to your code like in the code sample above to see what the variable _killed has written to it. If it produces an 'any' or something odd to a unit that has a name, then something isn't right. Share this post Link to post Share on other sites
Socrate 10 Posted November 15, 2009 'variable' will be equal to the last player that executed the init.sqf. Nope, In my opinion EACH player has a variable called 'variable' that reference the player. 'variable' will be different for each player. the variable 'variable' it's global but in a multiplayer game the value of a variable isn't automatically broadcasted at every player .Interesting is what you say here _killed would be the name of the unit that was killed So you say that _killed contain the name of the unit, so a STRING variable! :bounce3: I'll check it out!! thank you man! Share this post Link to post Share on other sites