dematti 10 Posted June 6, 2010 (edited) i've been trying for couple of hours to get this to work, but I cant find a solution for this. All i want is to give each side (west and east) 1 point for every 10kills it makes. and then when i call a radio trigger it shows me in hint format. 1st a trigger: radio .... on act: hint format["West: %1 East: %2", scoreW, scoreE] then I add this into each unit init: this addEventHandler ["killed",{_this exec "Score.sqf"}] this is the script: Score.sqf _victim = _this select 0 ?(side _victim == WEST):scoreE=scoreE+0.1;publicvariable "scoreE" ?(side _victim == EAST):scoreW=scoreW+0.1;publicvariable "scoreW" exit Can someone tell what i'm doing wrong? I just cant figure it out thx Edited June 6, 2010 by dematti Share this post Link to post Share on other sites
f2k sel 164 Posted June 7, 2010 I think I see a couple of errors, your calling sqf script with exec and the script is sqs. However the big problem is that as soon as you kill a unit it becomes a CIV so the if's will never be true. Share this post Link to post Share on other sites
dematti 10 Posted June 7, 2010 (edited) So I change the script to sqs? Or is there another way to give each side points and then display them via hint? Maybe i can use "addrating" to 2different units that I put on the side of the map apart from the mission, but the problem is the score should be displayed with hint or plain down text. I've seen in the wiki addscore doesn't work in SP, is this the same for ScoreW,ScoreE? Does anyone know anything about this, there is NO info anywhere about how to display score in SP. Edited June 7, 2010 by dematti Share this post Link to post Share on other sites
Sardaukar17 10 Posted June 7, 2010 Instead of using the "Killed" event handler try executing a script in the init field of each unit that would execute your score.sqf when the unit is no longer alive. That way you can get around the dead unit becoming a civilian and not being East or West. only problem with that is... depending on how many unit you have out there... it could be allot of processing for the computer. Just an idea Share this post Link to post Share on other sites
dematti 10 Posted June 7, 2010 (edited) Instead of using the "Killed" event handler try executing a script in the init field of each unit that would execute your score.sqf when the unit is no longer alive. That way you can get around the dead unit becoming a civilian and not being East or West. only problem with that is... depending on how many unit you have out there... it could be allot of processing for the computer. Just an idea Thx, any ideas are welcome, it MUST BE possible to create a scoreboard in SP. So there's nothing wrong with the sqf? Is this something like: !alive this execVM "score.sqf" ? It's a long mission with lots of respawns but the units on the map are limited (a total of 150maybe) I already have an eventhandler in the init to delete the dead bodies, and it's not so heavy on the pc....is this different with the !alive command? And finally, i need to get the result in hint format:confused: Edited June 7, 2010 by dematti Share this post Link to post Share on other sites
Sardaukar17 10 Posted June 7, 2010 You will have to experiment with it to make sure but I think you can do that through the int. with the !alive _unit execVM "Script.sqf" If not just make a simple secondary script that is executed on the init that does the same thing. As far is if anything is wrong. It looks fine to me but I haven't tried to make a scoring system yet. With hint format your syntax looks correct.. but again I have only ever hinted one variable at a time not 2 at once. Not sure if it is possible and my wife is waiting for me or I would have tested it to find out. gtg lol GL! Share this post Link to post Share on other sites
dematti 10 Posted June 7, 2010 (edited) I think I see a couple of errors, your calling sqf script with exec and the script is sqs.However the big problem is that as soon as you kill a unit it becomes a CIV so the if's will never be true. Ok, but what if I input the killer instead of the killed? for ex: ?(side _killer == west): WestScore = WestScore + 1 can use some help about how to put this in a script though, this scripting thing is totally new to me. Edited June 7, 2010 by dematti Share this post Link to post Share on other sites
Big Dawg KS 6 Posted June 7, 2010 Score.sqf: _killer = _this select 1; if(side _killer == WEST)then{scoreW = scoreW + 0.1}else{ if(side _killer == EAST)then{scoreE = scoreE + 0.1}}; Should be simple enough. Just make sure you initialize scoreW and scoreE. Share this post Link to post Share on other sites
dematti 10 Posted June 7, 2010 (edited) Should be simple enough. Just make sure you initialize scoreW and scoreE thx, you do mean in the init.sqf? scoreW = 0 scoreE = 0 Am i right here :)? then in the unit init (i'm not fully sure if this one is right neither...): this addEventHandler ["killed",{_this exec "Score.sqf"}] then the trigger: on act: hint format["West: %1 East: %2", scoreW, scoreE] And last, the only thing i'm sure of now: score.sqf _killer = _this select 1; if(side _killer == WEST)then{scoreW = scoreW + 0.1}else{ if(side _killer == EAST)then{scoreE = scoreE + 0.1}}; Maybe all of this should be added as a template or something, didn't find it anywhere, a lot of people are probably wondering if scoreboard works in SP. thanks, i will test it within the next few hours and report back asap Edited June 7, 2010 by dematti Share this post Link to post Share on other sites
Big Dawg KS 6 Posted June 7, 2010 Yes. Just don't forget to terminate every SQF expression with a semicolon: init.sqf: scoreW = 0; scoreE = 0; Otherwise it won't compile. Alternatively, you could just rename it init.sqs (I think the engine will still call init.sqs on startup, but I haven't touched an .sqs in years), but it's more proper to use .sqf. Share this post Link to post Share on other sites
f2k sel 164 Posted June 7, 2010 (edited) place in an init.sqf scoreE=0; scoreW=0; place in each unit Wests init this addEventHandler ["killed",{[_this select 1,"West"] execvm "Score.sqf"}] East init init this addEventHandler ["killed",{[_this select 1,"East"] execvm "Score.sqf"}]; Script score.sqf _killer = _this select 0; _side = _this select 1; //hint format ["%1",_killer]; if (_side == "East") then { scoreW = scoreW + 0.1; //Hint "East dead"; }; if (_side == "West") then { scoreE = scoreE + 0.1; //hint "West Dead"; }; That should do it. I think if you use killer it will count all kills even friendly fire. Edited June 7, 2010 by F2k Sel Share this post Link to post Share on other sites
Big Dawg KS 6 Posted June 7, 2010 :p Hey, that's just an improved version of what I showed him. Actually, I did just realize the problem with my code: points will be awarded for teamkills. No worry, here's a modification of F2k Sel's code that is even further improved! Using F2k Sel's eventhandlers: _killer = _this select 0; _side = _this select 1; switch(_side)do{ case "West":{if(side _killer == EAST)then{scoreE = scoreE + 0.1}}; case "East":{if(side _killer == WEST)then{scoreW = scoreW + 0.1}}; }; This will prevent teamkills from counting and will only add to the score for kills made by the enemy and not suicides or accidental deaths. :cool: Btw, F2k Sel, you gotta tell me how you put tabs into your post so I can stop copying them from you. ;) Share this post Link to post Share on other sites
f2k sel 164 Posted June 7, 2010 Btw, F2k Sel, you gotta tell me how you put tabs into your post so I can stop copying them from you. What are tabs :confused: Share this post Link to post Share on other sites
dematti 10 Posted June 7, 2010 (edited) It works!!! thank you all for helping me out. i just don't get the hint messages:confused: but that doesn't matter:) Thanks guys you're the best (yes yes, you 2 big dawg :D) Edited June 7, 2010 by dematti Share this post Link to post Share on other sites
f2k sel 164 Posted June 7, 2010 It works!!!thank you all for helping me out. i just don't get the hint messages:confused: but that doesn't matter:) Thanks guys you're the best I just used those for testing, if you want to use them just remove the // Share this post Link to post Share on other sites
dematti 10 Posted June 7, 2010 I just used those for testing, if you want to use them just remove the // lol, I got a lot to learn as you can see, but I'm getting there:) Share this post Link to post Share on other sites
Big Dawg KS 6 Posted June 7, 2010 (edited) What are tabs :confused: | |< this is a tab (used for indenting) Ex: while{true}do{ // this line is tabbed, as is the following line of code hintSilent "Hi!"; }; Edited June 7, 2010 by Big Dawg KS Share this post Link to post Share on other sites
f2k sel 164 Posted June 7, 2010 I wasn't aware I was doing anything, I just use Arma Edit which sometimes adds them when using {} I believe. Share this post Link to post Share on other sites
Big Dawg KS 6 Posted June 7, 2010 I wasn't aware I was doing anything, I just use Arma Edit which sometimes adds them when using {} I believe. Oh, ok. I figured you might have had a way of just entering tabs in your posts. Btw, I just found the code... lol. I feel stupid. Share this post Link to post Share on other sites
dematti 10 Posted June 9, 2010 something weird happened with the score.... All works perfect nothing about that but, I kept the game running for testing purposes and after 6hours in my mission i can see the score is 105.40003 while normally it should only show 105.4 (10kills=1point) Where did the 0.00003 come from? Need to know because there might be a group wich is not beeing spawned anymore because it is not "dead". Share this post Link to post Share on other sites
Big Dawg KS 6 Posted June 9, 2010 Hmm... maybe some sot of strange remainder business. Anyway you can round it off like this: scoreE = (round (scoreE * 10)) / 10; Share this post Link to post Share on other sites