Jump to content

Nebulazer

Member
  • Content Count

    38
  • Joined

  • Last visited

  • Medals

Community Reputation

1 Neutral

About Nebulazer

  • Rank
    Private First Class
  1. thank you for this, I will study this and learn from it.
  2. I think this is what I am missing. I looked into initPlayerLocal.sqf, and it looks like that runs on the clients only, so is that where I am going to set the variables? and also should I take the set variables out of the normal Init?
  3. I tested this with another player joining my server, and when he kills the AI it still gives me(host) the money and XP even though its with set/getvariable. I thought doing all of this was to make each individual player have their own money gain. Do I need to run a dedicated server for this to work? Is there no way to have a money system when you just host on your computer?
  4. I got it to work on the AI, now i need to see if it works for players who join my game, and I need to make sure the player event handler works as well. this addEventHandler ["Killed", {Null = [_this select 0, _this select 1] execVM "AI_Killed.sqf";}]; AI_Killed.sqf fnc_handleKill_AI = { _killersCash = killer getVariable "cash"; _xp = killer getVariable "p_exp"; _newXP = _xp + 100; _cashForKill = 100; _newCash = _killersCash + _cashForKill; killer setVariable ["cash", _newCash, true]; killer setVariable ["p_exp", _newXP, true]; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_newCash]; execVM "Levels.sqf"; hint "+$100 and +100XP"; }; killedPlayer = _this select 0; killer = _this select 1; killerSide = side killer; killedPlayerSide = playerSide; [] spawn fnc_handleKill_AI; EDIT: If i wanted to spawn these AI with Spunfin's AI script, how would I have to set this up in the custom init? It says I cant use any conditions like the _this select 0, _this select 1. So I thought it would work like this but it does not. nul = [this, 2, true, 2, 50, 1, 0.35, nil, "this addEventHandler ['Killed', {execVM 'AI_Killed.sqf';}];", 1] execVM "LV\fillHouse.sqf";
  5. I think that this part is thinking that the independant side AI that are spawned are friendly and it is running fnc_handleFriendlyKill. does ! && ! mean if neither? _suicide = false; _friendlyKill = false; killedPlayer = _this select 0; killer = _this select 1; killerSide = side killer; killedPlayerSide = playerSide; if (killedPlayer == killer) exitWith {}; if (killedPlayerSide == killerSide) then {_friendlyKill = true}; if (_friendlyKill) then { [] spawn fnc_handleFriendlyKill; }; if (_suicide) then {}; if (!_friendlyKill && !_suicide) then { [] spawn fnc_handleKill;};
  6. I can see if the variables change or not on my UI as its already set to do that, it shows me when i run moneylevels.sqf that i have 500 dollars but if i run it again in Debug it keeps me at 500 dollars, I think that is the problem right there. Is there something I am not understanding about local variables and setvariable? _cash = player getVariable "playerCash"; _cash=_cash+500; ("DollarTitle_layer" call BIS_fnc_rscLayer) cutRsc ["DollarTitle","PLAIN"]; ("LevelTitle_layer" call BIS_fnc_rscLayer) cutRsc ["LevelTitle","PLAIN"]; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_cash]; that keeps at 500 dollars no matter how many times I run it, but why if _cash=_cash+500; every time you run it? I think if that can be explained to me, it might solve my problem. Edit: After messing around a bit with it i found the answer. It needs a new local variable to replace the old amount as so _cash = player getVariable "playerCash"; _newCash=_cash+500; player setVariable ["playerCash", _newCash, true]; I have it so the variable is changing now when i kill AI but it is still not doing it right. The AI are independent but set to be hostile to both red and blue but when i Kill an AI it gives me -50 dollars, if I left the script the way that you gave it to me it would make you have -50 dollars at the end instead of losing -50, but really I want it so you gain +100 when you kill an independent AI and 200 when you kill a player on the opposite team. fnc_handleKill = { _killersCash = killer getVariable "playerCash"; _killersKills = killer getVariable "playerKills"; _newKillersKills = _killersKills + 1; _cashForKill = 100; _newCash = _killersCash + _cashForKill; killer setVariable ["playerCash", _newCash, true]; killer setVariable ["playerKills", _newKillersKills, true]; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_newCash]; }; fnc_handleFriendlyKill = { _killersCash = killer getVariable "playerCash"; _cashForKill = -50; _newCash = _killersCash + _cashForKill; if (_killersCash <= 0) then { _cashForKill = 0; }; killer setVariable ["playerCash", _newCash, true]; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_newCash]; }; _suicide = false; _friendlyKill = false; killedPlayer = _this select 0; killer = _this select 1; killerSide = side killer; killedPlayerSide = playerSide; if (killedPlayer == killer) exitWith {}; if (killedPlayerSide == killerSide) then {_friendlyKill = true}; if (_friendlyKill) then { [] spawn fnc_handleFriendlyKill; }; if (_suicide) then {}; if (!_friendlyKill && !_suicide) then { [] spawn fnc_handleKill;}; I tried running a different script on the AI with the killed event handler and changing it to AI_killed.sqf but it still gives me the same results even though the part about -50 is commented out, so that means it is still using the eventhandler of the player instead of the one on the AI? fnc_handleKill = { _killersCash = killer getVariable "playerCash"; _killersKills = killer getVariable "playerKills"; _newKillersKills = _killersKills + 1; _cashForKill = 100; _newCash = _killersCash + _cashForKill; killer setVariable ["playerCash", _newCash, true]; killer setVariable ["playerKills", _newKillersKills, true]; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_newCash]; }; //fnc_handleFriendlyKill = { // _killersCash = killer getVariable "playerCash"; // _cashForKill = -50; // _newCash = _killersCash + _cashForKill; // if (_killersCash <= 0) then { _cashForKill = 0; }; // killer setVariable ["playerCash", _newCash, true]; // (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_newCash]; //}; _suicide = false; _friendlyKill = false; killedPlayer = _this select 0; killer = _this select 1; killerSide = side killer; killedPlayerSide = playerSide; if (killedPlayer == killer) exitWith {}; if (killedPlayerSide == killerSide) then {_friendlyKill = true}; if (_friendlyKill) then { [] spawn fnc_handleFriendlyKill; }; if (_suicide) then {}; if (!_friendlyKill && !_suicide) then { [] spawn fnc_handleKill;};
  7. There are no script errors now, but my UI in the bottom right just shows Level: any Money : $any no matter how much money i have. It does not seem to be finding the global variables that are being set in the init. Here is the whole mission on Github, it is still very much WIP obviously and there are some old files sitting in the root that are not being used any more, i have to delete some of them, but maybe you will see what is causing me problems in the UI https://github.com/Nebulazer/CWCKunduz EDIT: I think i figured it out, it is just going to take a lot of rewriting scripts, thank you for the help. This is my moneyLevels.sqf now to display the initial UI for the money //cash and level display on GUI _cash = player getVariable "cash"; _cash=_cash+500; ("DollarTitle_layer" call BIS_fnc_rscLayer) cutRsc ["DollarTitle","PLAIN"]; ("LevelTitle_layer" call BIS_fnc_rscLayer) cutRsc ["LevelTitle","PLAIN"]; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",_cash]; //(uiNameSpace getVariable "myUI_LevelTitle") ctrlSetText format ["Level: %1", (p_level) call calcLevel]; EDIT2: its still not quite working, whenever i get a kill with your script, it puts my money back to zero instead of the initial 500. I am going to take away the initial 500 once it saves with iniDB, but it still should not set me to zero. I should also note that I am testing this on AI using the line you provided above for the killed event handler.
  8. I see, does that mean i need to change the playerCash to Cash and do I need to create a new variable in the init for playerKills = 0;? EDIT: I made the changes I thought i would need for my variables instead but its giving me the error "undefined variables in expression: _killerscash" fnc_handleKill = { _killersCash = killer getVariable "cash"; _killersKills = killer getVariable "playerKills"; _newKillersKills = _killersKills + 1; _cashForKill = 100; _newCash = _killersCash + _cashForKill; killer setVariable ["cash", _newCash, true]; killer setVariable ["playerKills", _newKillersKills, true]; }; fnc_handleFriendlyKill = { _killersCash = killer getVariable "cash"; _cashForKill = -50; if (_killersCash <= 0) then { _cashForKill = 0; }; killer setVariable ["cash", _cashForKill, true]; }; _suicide = false; _friendlyKill = false; killedPlayer = _this select 0; killer = _this select 1; killerSide = side killer; killedPlayerSide = playerSide; if (killedPlayer == killer) exitWith {}; if (killedPlayerSide == killerSide) then {_friendlyKill = true}; if (_friendlyKill) then { [] spawn fnc_handleFriendlyKill; }; if (_suicide) then {}; if (!_friendlyKill && !_suicide) then { [] spawn fnc_handleKill;}; This is what my init.sqf looks like, maybe something there is wrong, but it seems to work fine until the point that I kill the AI, then it gives me the script error. cash = 0; p_exp = 0; p_level = 0; playerKills = 0; player addEventHandler ["Killed", {Null = [_this select 0, _this select 1] execVM "playerKilled.sqf";}]; [] spawn SRS_fnc_init; //execVM "cashKillFunc.sqf"; //execVM "killed_killer.sqf"; //execVM "respawnGear.sqf"; execVM "moneyLevels.sqf"; execVM "Levels.sqf"; execVM "fatigue.sqf"; //execVM "cashOnKill.sqf"; //execVM "Grenadestop.sqf"; 0 = [] execVM "group_manager.sqf"; 0 = [] execVM "player_markers.sqf"; nul=[] execVM "repair.sqf"; ETG_Reinforcements = 0;
  9. I see that is giving money but not experience, would I need to make a similar one for the p_exp gain?so the player addEventHandler ["killed".... goes in the init then the rest of the code just goes in playerKilled.sqf, is that correct? or does the playerKilled.sqf have to be run on the AI as well? Also, kevsno, I am running this in the Init for players killing eachother and putting this in the AI init null =[this]execVM "cashOnKill.sqf" call BIS_fnc_MP;
  10. I am trying to make it so players get money and xp when they get kills on AI and enemy players but this is for some reason it i giving me the money and xp when I run the mission on my computer. I don't have it running on a dedicated server yet but the description of !ifDedicated made it seem like it would work anyway. //Get Cash and xp when you kill if (!isDedicated)then{ _unit=(_this select 0); _unit addEventHandler ["killed", { _unit= (_this select 0); _killer= (_this select 1); if (isPlayer _killer)then{ p_exp=p_exp+100; cash=cash+100; execVM "Levels.sqf"; hint "$+100 and +100XP"; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",cash]; _unit removeAllEventHandlers "killed"; }; }]; };
  11. Thank you very much, works like a charm!
  12. I am trying to add a level restriction to my shop scripts that are all activated through action menu on an object. here is an example of one. //Navid Hex _cost=5000; if (cash >= _cost) then { cash=cash-_cost; hint "You Bought A Navid Hex For $5,000"; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",cash]; player removeWeapon (primaryWeapon player); {player removeMagazine _x} forEach magazines player; //Add new weapons player addMagazine '150Rnd_93x64_Mag'; player addWeapon 'MMG_01_hex_F'; player addMagazines ['150Rnd_93x64_Mag', 3]; }else{ hint "Not enough money"; }; I want to add something like this so it will work in conjunction with taking the money but I am not sure how to mix them together. if level >= 15) then {.... }else{ hint "Not High Enough Level"; };
  13. So, I cant get either of those examples to work, i guess i dont quite understand how functions work? I tried putting the function in the init right below my variables, but when I ran it in game it just stopped the UI from showing up for both the money and the level UI. If you want to see the whole mission and maybe you will see another problem I have in their that is stopping it from working or something I have it on a github https://github.com/Nebulazer/CWCKunduz
  14. hmm, are you saying I have to put it in the init of each playable unit instead? or just execVM from the init in the mission file?
  15. I could kiss you! haha. Thank you so much for explaining how an "or" statement works to me. I was trying to wrap my head around that for some time. This works like a charm in game and now i should be able to save my p_exp and cash variables using iniDB to save my players data on a dedicated server. This should be scale-able up to whatever level i want to make it to correct? Is there any limitations due to performance or is it a light enough script that it should work no matter how high of a level i make it? I am using this to give players XP and Money when they kill things, and it works for me but im not sure if it works for other players. //Get Cash and xp when you kill if (!isDedicated)then{ _unit=(_this select 0); _unit addEventHandler ["killed", { _unit= (_this select 0); _killer= (_this select 1); if (isPlayer _killer)then{ p_exp=p_exp+100; cash=cash+100; execVM "Levels.sqf"; hint "$+100 and +100XP"; (uiNameSpace getVariable "myUI_DollarTitle") ctrlSetText format ["Money: $%1",cash]; _unit removeAllEventHandlers "killed"; }; }]; }; Is there a way I can execute that on all AI without putting this line of code in all of their Init's? null =[this]execVM "cashOnKill.sqf" call BIS_fnc_MP; EDIT: Also I got it the UI to show at least level 10 so far, I want to make it go to level 100, maybe beyond eventually. switch (true) do { case (p_exp >= 19600): { p_level = 10; }; case (p_exp >= 11200): { p_level = 9; }; case (p_exp >= 6400): { p_level = 8; }; case (p_exp >= 3600): { p_level = 7; }; case (p_exp >= 1200): { p_level = 6; }; case (p_exp >= 2100): { p_level = 5; }; case (p_exp >= 1200): { p_level = 4; }; case (p_exp >= 700): { p_level = 3 }; case (p_exp >= 400): { p_level = 2; }; case (p_exp >= 0): { p_level = 1; }; }; (uiNameSpace getVariable "myUI_LevelTitle") ctrlSetText format ["Level: %1", p_level];
×