Author Topic: How do i make that minigame score can't go under 0?  (Read 833 times)

example its if under 0 e.g -1 it goes back to 0.

i'd like one thaat supports up to -50


Dunno what you're asking for.
Explain better.

I think he wants an addon that doesn't prevent an action that would created a score lower than a threshold
just an addon that if the score does go below the threshold, it gets set to it

not sure the best way to do this, I'd probably just loop and check it every so often and change it if need be, maybe check everybody's score 2-4 times a second
I don't think you can package every way there is to change the score to check after it updates

Dunno what you're asking for.
Explain better.

Example my minigame score is 0, I get killed lose 15.

The minigame score is now -15 :O I don't want to happen.

I think he wants an addon that doesn't prevent an action that would created a score lower than a threshold
just an addon that if the score does go below the threshold, it gets set to it

not sure the best way to do this, I'd probably just loop and check it every so often and change it if need be, maybe check everybody's score 2-4 times a second
I don't think you can package every way there is to change the score to check after it updates
Nah, the best way to do it is just package the inc/set score functions.

Code: [Select]
package positivescore
{
function GameConnection::incScore(%this,%count)
{
if(%this.score+%count < 0)
return %this.setScore(0);
return Parent::incScore(%this,%count);
}
function GameConnection::setScore(%this,%count)
{
if(%count < 0)
%count = 0;
return Parent::setScore(%this,%count);
}
};
activatePackage(positiveScore);


Haven't tested, should work.

Nah, the best way to do it is just package the inc/set score functions.

Code: [Select]
package positivescore
{
function GameConnection::incScore(%this,%count)
{
if(%this.score+%count < 0)
return %this.setScore(0);
return Parent::incScore(%this,%count);
}
function GameConnection::setScore(%this,%count)
{
if(%count < 0)
%count = 0;
return Parent::setScore(%this,%count);
}
};
activatePackage(positiveScore);


Haven't tested, should work.

Thanks! I hope it works

Thanks! I hope it works

Yes it did work. But broke this

Code: [Select]
$joinScore=100;
$brickCost=1;
$setScoreOnEnter=1;



package payToPlantBricks {
function fxDTSbrick::onPlant(%this) {
Parent::onPlant(%this);
%client = %this.getGroup().client;
if(%client.score > %brickCost-1) {
%client.score = %client.score - %brickCost;
commandToClient(%client, 'bottomPrint', "\c2You have paid 1 score point to plant this brick.", 1);
} else {
commandToClient(%client, 'centerPrint', "You have no more score to plant a brick.", 3);
%this.schedule(0,"delete");
}
}
function GameConnection::autoAdminCheck(%client){
Parent::autoAdminCheck(%client);
if($setScoreOnEnter == 1) {
%client.setScore($joinScore);
}
}
};
activatePackage(payToPlantBricks);