Jump to content

nebulazerz

Member
  • Content Count

    128
  • Joined

  • Last visited

  • Medals

Everything posted by nebulazerz

  1. I am using hold action to make scripts for power suit abilities and I am trying to use custom icons but I cant seem to get it working for some reason. Do I need to define the icon in the description.ext? [ /* 0 object */ player, /* 1 action title */ "Sprint 1", /* 2 idle icon */ "images\sprinticon.paa", /* 3 progress icon */ "images\suiticon.png", /* 4 condition to show */ "true", /* 5 condition for action */ "true", /* 6 code executed on start */ {player setAnimSpeedCoef 1.50}, /* 7 code executed per tick */ {player setAnimSpeedCoef 2}, /* 8 code executed on completion */ {player setAnimSpeedCoef 1}, /* 9 code executed on interruption */ {player setAnimSpeedCoef 1}, /* 10 arguments */ ["Sprint"], /* 11 action duration */ 3, /* 12 priority */ 0, /* 13 remove on completion */ false, /* 14 show unconscious */ false ] call bis_fnc_holdActionAdd;
  2. Thanks, Ill try this out in my bubble effect instead of using allowDamage false. I plan on making a sort of tank class if you buy the armor from the shop that gives you the skill. I could even make different variations of damage reduction. Is there a way to make this effect everyone inside a certain area? would be cool to have players follow the tank class around and stay inside his defense bubble to take less damage while advancing the enemy. I have decided using this in level rewards though is a bad idea because it would bring a lot of balance issues for new players. But I am also thinking about creating a deployable Item that is on a time limit and creates a defense shield where you take less damage inside. Here is my bubble effect currently, its activated by putting on a certain type of clothing. fnc_bubEffect = { params[ "_objNetID" ]; _unit = objectFromNetId _objNetID; _unit setVariable[ "bubEffect", true ]; //local object variable if ( local _unit ) then { _unit allowDamage false; //AL and EG }; _unit setAnimSpeedCoef 2;//Unsure of locality needs testing _unit switchMove "AmovPercMstpSnonWnonDnon_EaseIn"; //AG and EL _unit setAnimSpeedCoef 0; //Unsure of locality needs testing while ( _unit getVariable[ "bubEffect", false ] ) do { drop [ //EL ["\A3\data_f\ParticleEffects\Universal\Universal",16,13,7,0],"","BillBoard", 1,1,[0,0.25,1],[0,0,0], random pi*2,1.277,1,0, [3], [[1,0,0,.5],[1,0,0,.5]], [10000], 0,0,"","", _unit,0, false,-1 ]; playSound "electricshock"; //EL _unit switchMove "AmovPercMstpSnonWnonDnon_Ease"; //AG and EL sleep 0.25; //This is the equivilent of you action per tick 6/24 = 0.25 seconds }; }; _skillE = [ player, // 0 object "Bubble", // 1 action title "images\blinkicon.paa", // 2 idle icon "images\blinkicon.paa", // 3 progress icon "player getvariable [ 'Bubble', false ]", // 4 condition to show "true", // 5 condition for action // 6 code executed on start { //Create a unique name for the jip queue [ netId player ] remoteExec [ "fnc_bubEffect", 0, format[ "%1_bub", netId player ] ]; }, // 7 code executed per ACTION tick ( Range 0 - 24 ), tick duration = action duration / MAX tick 24 {}, // 8 code executed on completion { //No JIP [ netId player ] remoteExec [ "fnc_bubFinish", 0 ]; //Remove start from JIP queue remoteExec [ "", format[ "%1_bub", netId player ] ] }, // 9 code executed on interruption { //No JIP [ netId player ] remoteExec [ "fnc_bubFinish", 0 ]; //Remove start from JIP queue remoteExec [ "", format[ "%1_bub", netId player ] ] }, [], // 10 arguments 6, // 11 action duration 0, // 12 priority false, // 13 remove on completion false // 14 show unconscious ] call BIS_fnc_holdActionAdd;
  3. Hi, I have been away from arma coding for about 6 months to take some classes and I am picking back up on a mission I almost had finished when i left it. I have one major issue that I cannot seem to fix where I can die the first time I spawn in the mission, but I am invincible when I respawn. Any player that joins is invincible from the start. I have been digging through my code all morning but I cant find any line that would change damage after death. Anyone have any ideas on what could be happening here? Its been a little bit so I am kind of rusty at coding but its all coming back to me as I look it over, just not certain about some specifics. Could it be this is my description.ext? respawn = 3; respawnOnStart = -1;
  4. Holy crap, thanks... never thought to Cntrl + F "handledamage". Looks like i started experimenting with damage reduction and forgot about it -_- Found this in my function library (in a level reward script) player addeventhandler ["HandleDamage",{(_this select 2) / 10;} ];
  5. I am still having this issue, I cant find anything in my code that would cause this to happen. Has anyone else had this happen?
  6. So then i should write my own respawn system or use one from the community and it should fix the problem? I will start with trying that. Edit: I am trying to use respawn= 0; now with the onPlayerKilled but it takes me right to the death screen. Is there something specific I need to put in that EH file to stop it from ending the game? this is what I am currently trying in there. // Set Respawn Pos switch (side player) do { case west: { _posRandom = ["respawn_west1","respawn_west2"] call bis_fnc_selectRandom; _position = getMarkerPos _posRandom vectorAdd [0,0,400]; [_position] call neb_fnc_core_setStartingPos; }; case east: { _posRandom = ["respawn_east1","respawn_east2"] call bis_fnc_selectRandom; _position = getMarkerPos _posRandom vectorAdd [0,0,400]; [_position] call neb_fnc_core_setStartingPos; }; }; The function just makes sure that the player respawns correctly by checking in a loop until they are spawned. Edit 2: Using respawn= 3; with the above seems to fix the problem. thanks for the help. Edit 3: Nevermind, it seems I can kill myself with a grenade but cannot die any other way. Still working on a solution. Edit 4: I have recorded a video of the bug in action. You can see the health bar jumping as if I am taking damage but everytime I take new damage it resets my health to 100% then gives me the new damage. Seems it could be something with one of my eventhandlers.
  7. I am using progress bars to track the Score in my game mode, I was curious if there is a way to reverse the progress bar so it fills from right to left. Heres what I have Heres where it is calculating and displaying it _redProgress = linearConversion [ 0, endScore, redScore, 0, 1 ]; (uiNamespace getVariable "UIplayerInfo" displayCtrl UIredBar ) progressSetPosition _redProgress;
  8. I am trying to create a function that will let me add a remoteExec to the script of any object or vehicle that I want my players to be able to teleport to through a screen near where they spawn. I am getting an error that tells me _unit is undefined. EDIT: Nevermind, after thinking about this for a minute. I realise how silly of a question this is. Its always going to be the player so I dont need to pass the parameter... overthinking it once again haha sorry. EDIT2: seems my real issue now is that its telling me undefined variable in expression _truck. The hold action is showing up on the object BluTeleScreen so i know that variable is passing through, but not the truck. In vehicle script after vehicle creation [BluSpawnTruck, BluTeleScreen] remoteExec ["neb_fnc_core_teleToTruck"]; the function is in my coreFunctions neb_fnc_core_teleToTruck = { params ["_truck","_home"]; Blu_MobileFOB_Action = [ /* 0 object */ _home, /* 1 action title */ "Teleport To Mobile FOB", /* 2 idle icon */ "images\blinkicon.paa", /* 3 progress icon */ "images\blinkicon.paa", /* 4 condition to show */ "true", /* 5 condition for action */ "true", /* 6 code executed on start */ {}, /* 7 code executed per tick */ {}, /* 8 code executed on completion */ {player setPos (getPos _truck)}, /* 9 code executed on interruption */ {}, /* 10 arguments */ [], /* 11 action duration */ 1, /* 12 priority */ 0, /* 13 remove on completion */ false, /* 14 show unconscious */ false ] call bis_fnc_holdActionAdd; };
  9. School will be starting again in a few days for me and i wont have as much time as I would like to work on my multiplayer mission I have been working on for the past month or so called 'Base Wars'. It is a SC/MOBA style game with 64 players persistant levels/money/stats. There are shops with level restrictions and costs already in place. There are AI that act the same as 'Creeps' or 'Jungle' in MOBA games (the plan is to stop them from spawning after certain number of players are in the game). The mission is nearly finished, the whole core gameplay element is already there and it is a fully functioning game that works on dedicated. The majority of what is left to do is small feature adding and bug testing/fixing. Thanks, Nebulazer
  10. Contact me if you are interested in a demo run of the mission in its current form Steam: Nebulazer
  11. nebulazerz

    Invisible Players and JIP setPos

    I have fixed the JIP issue for setPos, but players are still invisible from eachother. Any ideas why? Here is the function that fixed my spawning issue, I found it in an older thread. EDIT: fixed the invisible players by never hiding the units in the first place, instead i burried them 100M under the map :D EDIT2: seems this is still not perfect, it more often than not drops any player that JIP from 2000m instead of 400... which i just dont get. EDIT3: added more sleeps and it fixed it, guess it needed to "load" waitUntil { !isNull player && time > 0 }; //after briefing //Define UI ctrls #define UIlevel 1000 #define UIprogress 1001 #define UIprogressBar 1002 #define UIcash 1003 #define UIkills 1004 #define UIredScore 1005 #define UIbluScore 1006 #define UIbluBar 1007 #define UIredBar 1008 #define UIendScore 1009 #define UIhealthBar 1010 #define UIhealthIcon 1011 #define UIdisplayFPS 1012 titleCut ["", "BLACK FADED", 999]; sleep 1; // Set Starting Pos switch (side player) do { case west: { _position = [2938.69,13107.5,400]; [_position] call neb_fnc_core_setStartingPos; playSound "airplanes"; }; case east: { _position = [2695.89,12334.4,400]; [_position] call neb_fnc_core_setStartingPos; playSound "airplanes"; }; default {_position = [0,0,0];}; }; titlecut [" ","BLACK IN",5]; neb_fnc_core_setStartingPos = { params ["_position"]; player setPos _position; // _position diag_log format["setting player's position to: %1", _position]; sleep 1; _real_player_pos = getPos player; diag_log format["position that has been set: %1", _real_player_pos]; _tries = 0; sleep 1; while {abs(abs(_real_player_pos select 0) - abs(_position select 0)) > 10 or abs(abs(_real_player_pos select 1) - abs(_position select 1)) > 10} do { diag_log format["player pos is %1 which is not target pos %2. retrying...", _real_player_pos, _position]; hint format["position wasn't set correctly; trying again... %1", _tries]; sleep 1; _tries = _tries +1; player setPos _position; sleep 1; _real_player_pos = getPos player; diag_log format["player pos is %1 which is not target pos %2. retrying...", _real_player_pos, _position]; }; };
  12. I am having trouble getting players to spawn in correctly, I have the units boxed all checked so they are pretty much not on the map until a player takes them over but this seems to be causing some issues. Also, I cant get setPos to work with JIP, it always puts players in the place where I have the units placed on spawn if they join after the game has started. Here is the top of my initPlayerLocal.sqf waitUntil { !isNull player && time > 0 }; //after briefing //Define UI ctrls #define UIlevel 1000 #define UIprogress 1001 #define UIprogressBar 1002 #define UIcash 1003 #define UIkills 1004 #define UIredScore 1005 #define UIbluScore 1006 #define UIbluBar 1007 #define UIredBar 1008 #define UIendScore 1009 #define UIhealthBar 1010 #define UIhealthIcon 1011 #define UIdisplayFPS 1012 player allowDamage true; player enableSimulation true; player enableStamina false; player hideObject false; player hideObjectGlobal false; enableSentences false; // Set Starting Pos switch (side player) do { case west: { player setPos [2938.69,13107.5,400]; //playSound "airplanes"; }; case east: { player setPos [2695.89,12334.4,400]; //playSound "airplanes"; }; default {player setPos [0,0,0];}; };
  13. Awesome, It all works from just my machine now. I cant test it JIP yet because I am having some issues still with players not getting setPos and hideObject false, but i trust that it works JIP and ill be testing it later today hopefully when i find a fix to the other JIP issues I am having. Is this a good way to check for the action instead of removing and adding it? Seems to work on my end but not sure if there are any multiplayer issues with this. if (isNil "BluActionSpawnTruckCheck") then { [ BluTeleScreen, "BluSpawnTruck" ] remoteExec ["neb_fnc_core_teleToTruck", 0, "BluTruckJIP" ]; BluActionSpawnTruckCheck = true; };
  14. I have this working now, there are some things that are nice about the profileNamespace such as the ability to carry your level over to multiple servers without a database. Im pretty sure this is how the guys who did KOTH do it, they must have some kind of check to see if you have manually edited the data. I will just need to figure out something similar in time, for now i'm not extremely worried about players editing their files. If I have active admins and am actively admining myself, It will be easy to figure out who has cheated. Leveling takes quite some time, if someone is a new player and high enough to buy a tank, i know they cheated.
  15. I need help from someone who has a lot of experience working with the profileNamespace for saving client data. I have it working for the most part, but I have a few bugs that I did not have before implenting it and it does not seem to be working 100% I need someone who is willing to look at my mission folder to look in my initplayer local/function library/ and shop dialog to find the bugs. I have another bug that has to do with spawning and the respawn system, that I have tried for days to fix but i can't find the answer. My mission is near completion and almost ready to be played but these bugs are holding me back from finishing it. Message me if you are interested. I have no money to offer currently for your services, but you will receive credit as part of the team that made my dream arma PVP mode happen.
  16. I have a new problem, When the truck gets destroyed and respawns, the setPos is putting me at [0,0,0] instead of at the newly spawned truck. Is this because the action is still ascociated with the old truck even though they have the same variable name? I tried removing the action but the second action always duplicates even when I try to remove it. Here is where the vehicle is being created. //BLU SPAWN TRUCK neb_fnc_core_bluSpawnTruck = { createMarker ["BluTruckSpawn",[3116.23,13584.7]]; "BluTruckSpawn" setMarkerType "Empty"; "BluTruckSpawn" setMarkerSize [2, 2]; while {true} do { _direction = 120; _position = getMarkerPos "BluTruckSpawn"; _mrk = "BluTruckSpawn"; _veh = createVehicle ["B_T_Truck_01_box_F", _position, [], 0, "NONE"]; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir _direction; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; _veh setVehicleVarName "BluSpawnTruck"; BluSpawnTruck = _veh; if (isNil "BluTruckAction") then { BluTruckAction = 0; BluTruckActionFree = 0; [BluSpawnTruck] call neb_fnc_addBounty; [BluTeleScreen, BluSpawnTruck, BluTruckAction] remoteExec ["neb_fnc_core_teleToTruck"]; [BluTeleScreen, BluSpawnTruck, BluTruckActionFree] remoteExec ["neb_fnc_core_teleToTruckFree"]; }; //Create trigger for shop _trigger = createTrigger[ "EmptyDetector", getMarkerPos _mrk, true ]; //Set trigger size on all clients and JIP [ _trigger, [ 5, 5, 0, false, 5 ] ] remoteExec [ "setTriggerArea", 0, true ]; //Attach it to the vehicle _trigger attachTo [ BluSpawnTruck, [0,0,0] ]; //Call shopInit on server and all clients and JIP _JIP = [ _trigger, "Blu Mobile FOB", "ALL", true, true ] remoteExec [ "NEB_fnc_shopInit", [ 0, 2 ], true ]; waitUntil {!alive BluSpawnTruck}; sleep .5; BluSpawnTruck = nil; sleep 10; }; }; Here is what the holdaction function currently looks like neb_fnc_core_teleToTruck = { params ["_home","_truck", "_action"]; _action = [ /* 0 object */ _home, /* 1 action title */ "Teleport To Mobile FOB ($500)", /* 2 idle icon */ "images\blinkicon.paa", /* 3 progress icon */ "images\blinkicon.paa", /* 4 condition to show */ "true", /* 5 condition for action */ "true", /* 6 code executed on start */ {}, /* 7 code executed per tick */ {}, /* 8 code executed on completion */ { param[ 3 ] params ["_home","_truck", "_action"]; [500] call neb_fnc_core_pay; player setPos [getPos _truck select 0, (getPos _truck select 1) +5, (getPos _truck select 2)]; }, /* 9 code executed on interruption */ {}, /* 10 arguments */ [_home,_truck,_action], /* 11 action duration */ 1, /* 12 priority */ 0, /* 13 remove on completion */ false, /* 14 show unconscious */ false ] call bis_fnc_holdActionAdd; }; EDIT: Doing this worked, though I wish it would let me assign action ID to names instead of numbers, It would be a lot easier to delete them without any issues that way. waitUntil {!alive BluSpawnTruck}; sleep .5; [BluTeleScreen,0] call bis_fnc_holdActionRemove; [BluTeleScreen,1] call bis_fnc_holdActionRemove; BluSpawnTruck = nil; sleep 10; EDIT2: Hmm after more testing, seems that it starts to duplicate after the second time the vehicle is destroyed. EDIT3: seems the only way to get decent results after the vehicle respawns is to removeAllActions from the screen.
  17. Thanks Larrow, i'll try that. EDIT: Once again, you have the answer for me when im stuck. :D Works like a charm, now just to tweak it to be more functional instead of putting you in the middle of the truck, haha. Heres the working hold action. I tried the top method first but it was telling me that it was an array instead of an object so I tried the method under and it worked. //Tele to Truck neb_fnc_core_teleToTruck = { params ["_home","_truck"]; hint format ["%1", _truck]; Blu_MobileFOB_Action = [ /* 0 object */ _home, /* 1 action title */ "Teleport To Mobile FOB", /* 2 idle icon */ "images\blinkicon.paa", /* 3 progress icon */ "images\blinkicon.paa", /* 4 condition to show */ "true", /* 5 condition for action */ "true", /* 6 code executed on start */ {}, /* 7 code executed per tick */ {}, /* 8 code executed on completion */ { param[ 3 ] params ["_home","_truck"]; player setPos getPos _truck; }, /* 9 code executed on interruption */ {}, /* 10 arguments */ [_home,_truck], /* 11 action duration */ 1, /* 12 priority */ 0, /* 13 remove on completion */ false, /* 14 show unconscious */ false ] call bis_fnc_holdActionAdd; };
  18. I am trying to get an Icon to display on a simple health bar I am using in my mission, I have used the method I am using here succesfully in full blown dialog with buttons and the health bar its self works but I can't get it to display the Icon. I get no errors, and I can get the text showing the location of the image if i just use ctrlSetText. neb_healthBar = addMissionEventHandler ["Draw3D",{ _className = "b_med"; _cfg = configFile >> "CfgMarkers" >> _className; _healthIcon = str getText( _cfg >> "texture"); _playerDamage = (1 - (damage player)); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIhealthBar ) progressSetPosition _playerDamage; (uiNamespace getVariable "UIplayerInfo" displayCtrl UIhealthIcon ) ctrlSetStructuredText parseText format [ "<t align='center' size='1' ><img image=%1 /></t>", _healthIcon ]; }]; EDIT: sorry, I was over complicating this. You can simply just add the image to the HPP file like this. Now I just need to find the right Image :D class healthIcon: RscText { idc = 1011; type = CT_STATIC; style = 48;//ST_PICTURE text = "\A3\ui_f\data\map\markers\nato\b_med.paa"; x = "SafeZoneX + (1800 / 1920) * SafeZoneW"; y = "SafeZoneY + (1050 / 1080) * SafeZoneH"; w = "(120 / 1920) * SafeZoneW"; h = "(30.0000000000002 / 1080) * SafeZoneH"; ColorText[] = {0.9, 0.9, 0.9, 0.9}; };
  19. nebulazerz

    Reversing Progress Bar

    yea, sadly this does not work, not sure what the point of that command is then. I will try the method KK suggested. so one RscText would be the border and the other one the bar? _UIdisplay = (uiNamespace getVariable "UIplayerInfo"); _redProgBar = _UIdisplay displayCtrl 1008; _redProgBar ctrlSetAngle [180,0,0]; also tried (uiNamespace getVariable "UIplayerInfo" displayCtrl UIredBar ) ctrlSetAngle [180,0,0];
  20. nebulazerz

    Reversing Progress Bar

    on the .hpp for it? Not sure what you mean by that class redBar: RscProgress { idc = 1008; x = "SafeZoneX + (900 / 1920) * SafeZoneW"; y = "SafeZoneY + (0 / 1080) * SafeZoneH"; w = "(360 / 1920) * SafeZoneW"; h = "(15 / 1080) * SafeZoneH"; colorBar[] = {1, 0.1, 0.1, 0.5}; texture = "#(argb,8,8,3)color(0.75,0.75,0.75,0.75)"; };
  21. I am trying to change the UI that is circled in the picture here. Is there info on this anywhere? I could not find it on the BIwiki or google or on the forums. Are the IDC's known? Can they be replaced?
  22. I have a bug that I have been trying to think of a solution for that happens whenever a player kills an enemy from a vehicle. If a player shoots an enemy player or AI they will get money and XP via this event handler that is called to the enemy. In its current form it does not take into account if you are in a vehicle or not, so when you run someone over or shoot them with a mounted weapon you will get no credit or lose xp and money because the game thinks it was friendly or not an enemy. How can i check for that or can I make the vehicles bypass that check? params["_unit"]; //Add event ( see initPlayerLocal.sqf for code comments ) _unit addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; if ( isPlayer _killer && !( _killer isEqualTo _unit ) ) then { _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _unit >> "side" ) ) call BIS_fnc_sideType; _isEnemy = _killedSide getFriend side _killer < 0.6; _currentCash = _killer getVariable [ "cash", 0 ]; _currentExperience = _killer getVariable [ "experience", 0 ]; _currentKills = _killer getVariable [ "kills", 0 ]; if ( _isEnemy ) then { [ 250, 100, 1 ] remoteExec [ "fnc_updateStats", _killer ]; }else{ [ -100, -200 ] remoteExec [ "fnc_updateStats", _killer ]; }; }; }]; //Flag unit as having had event added _unit setVariable [ "hasEvent", true ];
  23. well, seems its not fully fixed. it seemed it was fine, but its subtracting levels on relog. everything else seems to be saving and calculating fine. I will reposte the code in case I have made any changes from the last time it was posted Edit: nvm the one above is more correct. this whole thing is making my head spin and im rushing because i have to go to work soon. waitUntil {alive player}; //Define UI ctrls #define UIlevel 1000 #define UIprogress 1001 #define UIprogressBar 1002 #define UIcash 1003 #define UIkills 1004 player allowDamage true; player enableSimulation true; (_this select 0) enableStamina false; player hideObject false; enableSentences false; private _proXP = profileNamespace getVariable "pro_experience"; if (isNil "_proXP") then { profileNamespace setVariable ["pro_experience", 0]; _proXP = 0; }; private _proCash = profileNamespace getVariable "pro_cash"; if (isNil "_proCash") then { profileNamespace setVariable ["pro_cash", 0]; _proCash = 0; }; private _proKills = profileNamespace getVariable "pro_kills"; if (isNil "_proKills") then { profileNamespace setVariable ["pro_kills", 0]; _proKills = 0; }; private _proLevel = profileNamespace getVariable "pro_level"; if (isNil "_proLevel") then { profileNamespace setVariable ["pro_level", 0]; _proLevel = 0; }; _cash = switch (_proCash) do { case 0: {500}; default {_proCash}; }; player setVariable ["cash", _cash, true]; _level = switch (_proLevel) do { case 0: {1}; default {_proLevel}; }; player setVariable ["level", _level, true]; _myXP = switch (_proXP) do { case 0: {0}; default {_proXP}; }; player setVariable ["experience", _myXP, true]; _kills = switch (_proKills) do { case 0: {0}; default {_proKills}; }; player setVariable ["kills", _kills, true]; /* switch (side player) do { case west: { player setPos [2938.69,13107.5,0]; //playSound "airplanes"; }; case east: { player setPos [2695.89,12334.4,0]; //playSound "airplanes"; }; default {player setPos [0,0,0];}; }; */ //Add event to player player addEventHandler [ "Killed", { //Get passed killed and killer _unit = _this select 0; _killer = _this select 1; //If we were killed by a player AND did not kill ourself if ( isPlayer _killer && !( _killer isEqualTo _unit ) ) then { //Is our killer an enemy _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _unit >> "side" ) ) call BIS_fnc_sideType; _isEnemy = _killedSide getFriend side _killer < 0.6; //Get killers stats _currentCash = _killer getVariable [ "cash", 0 ]; _currentExperience = _killer getVariable [ "experience", 0 ]; _currentKills = _killer getVariable [ "kills", 0 ]; //If killer was an enemy if ( _isEnemy ) then { //Increase their stats _killer setVariable [ "cash", ( _currentCash + 500 ) , true ]; _killer setVariable [ "experience", ( _currentExperience + 200 ) , true ]; _killer setVariable [ "kills", ( _currentKills + 1 ) , true ]; }else{ //Decrease their stats _killer setVariable [ "cash", ( _currentCash - 100 ) max 0 , true ]; _killer setVariable [ "experience", ( _currentExperience - 200 ) max 0 , true ]; }; //Call updateStats on killers client [ [], "fnc_updateStats", _killer ] call BIS_fnc_MP; }; }]; //Function to update stats fnc_updateStats = { //Get current experience _exp = player getVariable [ "experience", 0 ]; _myLvl = player getVariable [ "level", 0 ]; _tmpExp = _exp; _level = 0; _oldLevel = _myLvl; //Max value of level 1 _expForNextLevel = 100; //Work out new level while { _tmpExp >= _expForNextLevel } do { _level = _level + 1; _tmpExp = _tmpExp - _expForNextLevel; //Every level needs twice as much exp as the level before _expForNextLevel = _expForNextLevel * 2; }; //Set players level, minimum it can be is 0 _myLvl = _level max 0; //If we increased in level if ( _level > _oldLevel ) then { //Inform player of level increase hint format [ " LEVEL UP \nNow Level %1", _myLvl ]; [ [], "fnc_levelUpRewards", player ] call BIS_fnc_MP; }; //Get progress to next level _progress = linearConversion [ 0, _expForNextLevel, _tmpExp, 0, 1 ]; //Get player stats _cash = player getVariable [ "cash", 0 ]; _kills = player getVariable [ "kills", 0 ]; player setVariable [ "level", _myLvl, true ]; profileNamespace setVariable [ "pro_level", _myLvl]; profileNamespace setVariable [ "pro_experience", _tmpExp]; profileNamespace setVariable [ "pro_cash", _cash]; profileNamespace setVariable [ "pro_kills", _kills]; saveProfileNamespace; //Update UI with stats (uiNamespace getVariable "UIplayerInfo" displayCtrl UIlevel ) ctrlSetText ( format [ "Level : %1", _myLvl ] ); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIprogress ) ctrlSetText ( format [ "XP : %1/%2", _tmpExp, _expForNextLevel ] ); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIprogressBar ) progressSetPosition _progress; (uiNamespace getVariable "UIplayerInfo" displayCtrl UIcash ) ctrlSetText ( format [ "Money : $%1", _cash ] ); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIkills ) ctrlSetText ( format [ "Kills : %1", _kills ] ); };
  24. I have been working on this for a couple days to try and rewrite the level script that Larrow wrote that I use in my mission so that it saves with profileNamespace. I can get it to save stats and give them back to me, but it always seems to double every time I log in and I know you are going to say, "you are adding 2 together". I know but for some reason this is the only way I could get it to work even a little bit. I have tried tons of varieties of combinations that look like this but different, but nothing is saving the stats exactly as I need them without having to rewrite everything in the mission that is tied to the level system to be able to save the stats. This is the closest I have gotten to it working. Its buggy (the shop gives you money instead of taking it for some reason, and it multiplies the stats on relog) but it saves stats and gives them back on relog, this is the only way I have gotten it to work even a bit. Solved this with Kylanias help, here is the solution. Edit: still not 100%, its subtracting levels waitUntil {alive player}; //Define UI ctrls #define UIlevel 1000 #define UIprogress 1001 #define UIprogressBar 1002 #define UIcash 1003 #define UIkills 1004 player allowDamage true; player enableSimulation true; (_this select 0) enableStamina false; player hideObject false; enableSentences false; private _proXP = profileNamespace getVariable "pro_experience"; if (isNil "_proXP") then { profileNamespace setVariable ["pro_experience", 0]; _proXP = 0; }; private _proCash = profileNamespace getVariable "pro_cash"; if (isNil "_proCash") then { profileNamespace setVariable ["pro_cash", 0]; _proCash = 0; }; private _proKills = profileNamespace getVariable "pro_kills"; if (isNil "_proKills") then { profileNamespace setVariable ["pro_kills", 0]; _proKills = 0; }; private _proLevel = profileNamespace getVariable "pro_level"; if (isNil "_proLevel") then { profileNamespace setVariable ["pro_level", 0]; _proLevel = 0; }; _cash = switch (_proCash) do { case 0: {500}; default {_proCash}; }; player setVariable ["cash", _cash, true]; _level = switch (_proLevel) do { case 0: {1}; default {_proLevel}; }; player setVariable ["level", _level, true]; _myXP = switch (_proXP) do { case 0: {0}; default {_proXP}; }; player setVariable ["experience", _myXP, true]; _kills = switch (_proXP) do { case 0: {0}; default {_proKills}; }; player setVariable ["kills", _kills, true]; /* switch (side player) do { case west: { player setPos [2938.69,13107.5,0]; //playSound "airplanes"; }; case east: { player setPos [2695.89,12334.4,0]; //playSound "airplanes"; }; default {player setPos [0,0,0];}; }; */ //Add event to player player addEventHandler [ "Killed", { //Get passed killed and killer _unit = _this select 0; _killer = _this select 1; //If we were killed by a player AND did not kill ourself if ( isPlayer _killer && !( _killer isEqualTo _unit ) ) then { //Is our killer an enemy _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _unit >> "side" ) ) call BIS_fnc_sideType; _isEnemy = _killedSide getFriend side _killer < 0.6; //Get killers stats _currentCash = _killer getVariable [ "cash", 0 ]; _currentExperience = _killer getVariable [ "experience", 0 ]; _currentKills = _killer getVariable [ "kills", 0 ]; //If killer was an enemy if ( _isEnemy ) then { //Increase their stats _killer setVariable [ "cash", ( _currentCash + 500 ) , true ]; _killer setVariable [ "experience", ( _currentExperience + 200 ) , true ]; _killer setVariable [ "kills", ( _currentKills + 1 ) , true ]; }else{ //Decrease their stats _killer setVariable [ "cash", ( _currentCash - 100 ) max 0 , true ]; _killer setVariable [ "experience", ( _currentExperience - 200 ) max 0 , true ]; }; //Call updateStats on killers client [ [], "fnc_updateStats", _killer ] call BIS_fnc_MP; }; }]; //Function to update stats fnc_updateStats = { //Get current experience _exp = player getVariable [ "experience", 0 ]; _myLvl = player getVariable [ "level", 0 ]; _tmpExp = _exp; _level = 0; _oldLevel = _myLvl; //Max value of level 1 _expForNextLevel = 100; //Work out new level while { _tmpExp >= _expForNextLevel } do { _level = _level + 1; _tmpExp = _tmpExp - _expForNextLevel; //Every level needs twice as much exp as the level before _expForNextLevel = _expForNextLevel * 2; }; //Set players level, minimum it can be is 0 _myLvl = _level max 0; //If we increased in level if ( _level > _oldLevel ) then { //Inform player of level increase hint format [ " LEVEL UP \nNow Level %1", _myLvl ]; [ [], "fnc_levelUpRewards", player ] call BIS_fnc_MP; }; //Get progress to next level _progress = linearConversion [ 0, _expForNextLevel, _tmpExp, 0, 1 ]; //Get player stats _cash = player getVariable [ "cash", 0 ]; _kills = player getVariable [ "kills", 0 ]; player setVariable [ "level", _myLvl, true ]; profileNamespace setVariable [ "pro_level", _myLvl]; profileNamespace setVariable [ "pro_experience", _expForNextLevel]; profileNamespace setVariable [ "pro_cash", _cash]; profileNamespace setVariable [ "pro_kills", _kills]; saveProfileNamespace; //Update UI with stats (uiNamespace getVariable "UIplayerInfo" displayCtrl UIlevel ) ctrlSetText ( format [ "Level : %1", _myLvl ] ); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIprogress ) ctrlSetText ( format [ "XP : %1/%2", _tmpExp, _expForNextLevel ] ); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIprogressBar ) progressSetPosition _progress; (uiNamespace getVariable "UIplayerInfo" displayCtrl UIcash ) ctrlSetText ( format [ "Money : $%1", _cash ] ); (uiNamespace getVariable "UIplayerInfo" displayCtrl UIkills ) ctrlSetText ( format [ "Kills : %1", _kills ] ); };
×