Jump to content

draoth

Member
  • Content Count

    73
  • Joined

  • Last visited

  • Medals

Everything posted by draoth

  1. Hey man, sorry to bother you but I'm wondering if you could take another look at my trigger problem. I tried so much different things it's giving me a headache.

  2. I'm currently working on a money system for a gamemode I made for my friends and I. Boxes spawn all over the map and when a player gets close to it; he receives some money. The only problem I have with this script is that it only seems to work for the player who interacts with the box for the first time. This code is part of a sqf which is executed from the init.sqf. Does anyone have any idea why it doesn't work for all players in the server but only for the first player who picks up a box? BoxAmount = 0; for "_i" from 1 to 50 do { _Mcolor = "ColorGreen"; _Mtext = "$50"; _MMoney = 0; _quality = [1,2,3] selectRandomWeighted [0.1,0.2,1.3]; if (round _quality == 1) then { _Mcolor = "ColorWhite"; _Mtext = "$500"; _MMoney = 500; }; if (round _quality == 2) then { _Mcolor = "ColorYellow"; _Mtext = "$200"; _MMoney = 200; }; if (round _quality == 3) then { _Mcolor = "ColorGreen"; _Mtext = "$100"; _MMoney = 100; }; //hint format ["%1",_quality]; private _types = [ "BUILDING", "BUNKER", "BUSSTOP", "CHAPEL", "CHURCH", "FORTRESS", "HOSPITAL", "HOUSE", "LIGHTHOUSE", "POWERSTATION", "WATERTOWER" ]; _allBuildings = nearestTerrainObjects [[14000,18000], _types, 50000, false, true]; _allPositions = []; _allBuildings apply {_allPositions append (_x buildingPos -1)}; _rndPos = selectRandom _allPositions; _box = "Land_PaperBox_01_small_closed_brown_f" createVehicle [_rndPos select 0, _rndPos select 1, (_rndPos select 2) + 3]; _Mname = "marker" + str _i; [_Mname, _rndPos, _Mcolor, _Mtext, _box, _MMoney] spawn { _Mname = _this select 0; _rndPos = _this select 1; _Mcolor = _this select 2; _Mtext = _this select 3; _box = _this select 4; _MMoney = _this select 5; _dropoffmarker = createMarker [_Mname, _rndPos]; _dropoffmarker setMarkerShape "ICON"; _dropoffmarker setMarkerType "mil_box"; _dropoffmarker setMarkerColor _Mcolor; _dropoffmarker setMarkerText _Mtext; private _Amoney = player getVariable [format["_Amoney_%1", player],0]; while {true} do { if (player distance _box < 5) exitWith { deleteVehicle _box; deleteMarker _dropoffmarker; _Amoney = _Amoney + _MMoney; hint format ["You picked up $%1", _MMoney]; player setVariable [format["_Amoney_%1", player], _Amoney]; }; sleep 2; }; }; };
  3. I'm still stuck, does anyone have an idea on how to properly do this?
  4. @cidfr Thanks! I didn't think of setting the variables to the trigger. I'm getting closer, but now both players can interact with the box making it disappear, but only the first player (tested it with about 10 boxes for both the client and the host) that interacts with the boxes gets the money from all the boxes that are being picked up. So: player1 picks up a box: hint appears, box disappears, money gets added now player2 picks up a box and: hint appears for the player1, box disappears and the player1 gets the money. It all depends on the player who picks up the box the first time. Also, the marker doesn't get deleted now for some reason. Here is my complete updated script: BoxAmount = 0; for "_i" from 1 to 50 do { _Mcolor = "ColorGreen"; _Mtext = "$50"; _MMoney = 0; _quality = [1,2,3] selectRandomWeighted [0.1,0.2,1.3]; if (round _quality == 1) then { _Mcolor = "ColorWhite"; _Mtext = "$500"; _MMoney = 500; }; if (round _quality == 2) then { _Mcolor = "ColorYellow"; _Mtext = "$200"; _MMoney = 200; }; if (round _quality == 3) then { _Mcolor = "ColorGreen"; _Mtext = "$100"; _MMoney = 100; }; //hint format ["%1",_quality]; private _types = [ "BUILDING", "BUNKER", "BUSSTOP", "CHAPEL", "CHURCH", "FORTRESS", "HOSPITAL", "HOUSE", "LIGHTHOUSE", "POWERSTATION", "WATERTOWER" ]; _allBuildings = nearestTerrainObjects [[14000,18000], _types, 50000, false, true]; _allPositions = []; _allBuildings apply {_allPositions append (_x buildingPos -1)}; _rndPos = selectRandom _allPositions; _box = "Land_PaperBox_01_small_closed_brown_f" createVehicle [_rndPos select 0, _rndPos select 1, (_rndPos select 2) + 3]; _Mname = "marker" + str _i; [_Mname, _rndPos, _Mcolor, _Mtext, _box, _MMoney] spawn { _Mname = _this select 0; _rndPos = _this select 1; _Mcolor = _this select 2; _Mtext = _this select 3; _box = _this select 4; _MMoney = _this select 5; ["Hello"] remoteExec ["hint"]; _dropoffmarker = createMarker [_Mname, _rndPos]; _dropoffmarker setMarkerShape "ICON"; _dropoffmarker setMarkerType "mil_box"; _dropoffmarker setMarkerColor _Mcolor; _dropoffmarker setMarkerText _Mtext; private _Boxtrg = createTrigger ["EmptyDetector", _rndPos, true]; _Boxtrg setTriggerArea [2, 2, 0, false]; _Boxtrg setTriggerActivation ["ANYPLAYER", "PRESENT", true]; _Boxtrg setVariable ["_mMoney", _MMoney]; _Boxtrg setVariable ["_box",_box]; _Boxtrg setVariable ["_dropoffmarker",_dropoffmarker]; _Boxtrg setTriggerStatements ["this", " _firstplayer = thisList select 0; private _Amoney = _firstplayer getVariable [format['_Amoney_%1', _firstplayer],0]; private _MMoney = thisTrigger getVariable [ '_mMoney', 0]; private _box = thisTrigger getVariable '_box'; private _dropoffmarker = thisTrigger getVariable deleteVehicle _box; deleteMarker _dropoffmarker; hint format ['You picked up $%1', _MMoney]; _Amoney = _Amoney + _MMoney; _firstplayer setVariable [format['_Amoney_%1', _firstplayer], _Amoney]; deleteVehicle thisTrigger; ",""]; //private _Amoney = player getVariable [format["_Amoney_%1", player],0]; //while {true} do { //if (player inArea _Boxtrg == true) exitWith { //deleteVehicle _box; //deleteMarker _dropoffmarker; //deleteVehicle _Boxtrg; //_Amoney = _Amoney + _MMoney; //hint format ["You picked up $%1", _MMoney]; //player setVariable [format["_Amoney_%1", player], _Amoney]; //}; //sleep 2; //}; }; };
  5. This was the setTriggerStatements i wrote: _Boxtrg setTriggerActivation ["ANYPLAYER", "PRESENT", true]; _Boxtrg setTriggerStatements ["this", " _firstplayer = thisList select 0; private _Amoney = _firstplayer getVariable [format['_Amoney_%1', _firstplayer],0]; deleteVehicle _box; deleteMarker _dropoffmarker; hint format ['You picked up $%1', _MMoney]; _Amoney = _Amoney + _MMoney; _firstplayer setVariable [format['_Amoney_%1', _firstplayer], _Amoney]; ",""]; But when picking up the box it just says: "you picked up $any%" and the variable wouldn't get updated (edit: It turns out that this also only works for the host and the variable does change but it sets it back at 0)
  6. This was the setTriggerStatements i wrote: _Boxtrg setTriggerActivation ["ANYPLAYER", "PRESENT", true]; _Boxtrg setTriggerStatements ["this", " _firstplayer = thisList select 0; private _Amoney = _firstplayer getVariable [format['_Amoney_%1', _firstplayer],0]; deleteVehicle _box; deleteMarker _dropoffmarker; hint format ['You picked up $%1', _MMoney]; _Amoney = _Amoney + _MMoney; _firstplayer setVariable [format['_Amoney_%1', _firstplayer], _Amoney]; ",""]; But when picking up the box it just says: "you picked up $any%"
  7. I think you're right. So you recommend to use triggers for this, what would your approach be? In my first version I used a trigger with (player inArea _boxtrigger) instead of (player distance _box < 5) which also only worked for one person. I tried to use setTriggerStatements and executing the code that way but that didn't work either unfortunately.
  8. If all players execute that script themselves, then the script would compare the player from the machine it's running on to the _box, correct? So, why when the script run on all clients and someone picks up a box, the script assumes the "player" to be the one that picked it up first? if (player distance _box < 5) exitWith { deleteVehicle _box; deleteMarker _dropoffmarker; _Amoney = _Amoney + _MMoney; hint format ["You picked up $%1", _MMoney]; player setVariable [format["_Amoney_%1", player], _Amoney];
  9. Yeah you are right, I usually do but this time I just wrote the code just so me and my friends could quickly play the new gamemode. The boxes seem to spawn normally and there isn't any errors thrown from that line. almost everything works. Only thing that doesn't is that only the first player that picks up the money can pick up any money during our session.
  10. I've enjoyed playing some custom missions with my friends, but i was always the one that made the missions and hosted them. But since a month or so (Tank DLC) my friends can't see my server anymore and we've tried all possible ways to join: "Join friend", "Direct Connect" "Friends" "Recent" "Filter by host" "Filter by mission". We've even got so far to try to join with the launcher browser. When we tried that they see my server name and can enter the password but they crash when the game starts. My brother is able to join, proberaly since we live in the same house. I didn't touch any router settings and my firewall isn't blocking the network. Any ideas?
  11. Is there a way to disable vehicles from doing damage by driving over units? Thanks.
  12. I'm trying to create a random unit spawn script but when i'm using my script the other player can see the units spawning if he's at the right distance. _Randomlocation = [[selectrandom [player1,player2], 1000, 1500, 3, 0, 20, 0] call BIS_fnc_findSafePos] ; I'd like to know a way i can keep executing this script until the distance with every player is >200. Is there a efficient way to do this?
  13. The problem is, i want it to check if the random location is close to tot the player and if that's the case of should generate a new location until it's out of range of the players.
  14. I'm trying to count everyplayer that's playing as OPFOR. My counting script does not throw any errors, however the hint script doesn't recognizes _AllPrisoner. Obviously i'm doing something wrong and i hope someone can help me. _allplayers = allPlayers; _allPrisoner = {if (side _x == east) then {_allPrisoner = _allPrisoner + _x};} forEach _allplayers; hint format ["Test%1",_allPrisoner ];
  15. Hello everyone, i'm trying to create a simple free for all gamemode and when you get killed you become spectator until there's only one guy left. When that's the case i want everybody to automatically get out of spectator mode and respawn. I tried immediately respawning the unit on death on an island and have force spectator mode but that doesn't seem to work as i hoped. Does anyone have a idea how to do this efficiently? (It's very quick paced so restarting the whole mission would be not an option) Draoth
  16. Thanks, but now only when all players die (tested with two players) the last one will respawn. Everybody should respawn when there is only one left, not when everybody has died. I tried this: But that didn't work.
  17. First of all thanks alot for helping! I've got a couple of questions. I have to choose the spectator mode for respawning but the respawn delay option is greyed out. Do i have to set this in description.ext instead? Also, how can i define what respawning method is used after the infinite loop has ended? When i use the script on my server nothing really happens when i do what you said. So how exactly do i set this up. I'm very grateful that your willing to help me, and others with problems they encounter! Draoth
  18. If you don't think it's possible please say so! I'm still trying to figure it out and the fact that no one is responding is making me worried. Or is this very easy to do and no one is responding because i'm asking a stupid question?
  19. I'm trying to create a deathmatch like mission. But i want the players to stay in spectator mode until a new round starts. After the rounds over all dead players should respawn automatically . Any idea how i could do this?
  20. Hey everyone, I've got a script that is running on server only, but i need to create a action that passes arguments from that script. When i try it online only the server host gets the action. So how can i create an action that passes arguments on a server script that everybody can use? Code: _veh addaction ["Stop here","Stop.sqf",[_veh,_pass,_AI],0,false,false,"",""];
  21. Hey everyone, I've got a script that is running on server only, but i need to create a action that passes arguments from that script. When i try it online only the server host gets the action. So how can i create an action that passes arguments on a server script that everybody can use? Code: _veh addaction ["Stop here","Stop.sqf",[_veh,_pass,_AI],0,false,false,"",""];
×