Blockland Forums > Modification Help

Incorrect script, need fixing

Pages: << < (3/4) > >>

Chrono:


--- Quote from: CityRPG on January 10, 2012, 10:05:15 AM ---You do not need to package new functions, only when overwriting existing ones.

--- End quote ---
Not what he meant at all.

Port:


--- Quote from: Chrono on January 10, 2012, 10:36:33 AM ---Not what he meant at all.

--- End quote ---

--- Quote from: Superb on January 10, 2012, 10:07:56 AM ---He meant when you throw your stuff into a Server_zipFile and put it in the add-ons folder.

Welcome back Iban.  :cookieMonster:

--- End quote ---


CityRPG:


--- Quote from: jes00 on January 10, 2012, 10:11:31 AM ---No, it will generate a number between whatever you tell it to.

--- End quote ---
I hope you're just kidding.


--- Quote from: Chrono on January 10, 2012, 10:36:33 AM ---Not what he meant at all.

--- End quote ---
I see that now. I didn't think about the OP being unable to put a script file in a folder when I wrote that post.

Ipquarx:


--- Quote from: CityRPG on January 10, 2012, 10:05:15 AM ---
--- Code: ---function serverCmdRollDice(%client)
{
%rand = getRandom(1, 6);

switch(%rand)
{
case 6:
case 5:
case 4:
case 3:
case 2: messageClient(%client, '', "\c6You rolled a 2! LOL!"); %client.player.kill();
case 1:
default: messageClient(%client, '', "\c6What kind of die is that?");
}
}
--- End code ---

--- End quote ---
It's not good practice to have blank cases, just delete the blank cases and have the default, it's like a else.
Replace all the blank cases with the default, like this:

--- Code: ---function serverCmdRollDice(%client)
{
%rand = getRandom(1, 6);

switch(%rand)
{
case 2:
messageClient(%client, '', "\c6You rolled a 2! LOL!"); %client.player.kill();
default:
messageClient(%client, '', "\c6What kind of die is that?");
}
}
--- End code ---
Package that with a description and drop the sucker into add-ons.

CityRPG:

Except rolling anything but a 2 will render the default message. The objective was to show him how to do a switch to handle specific rolls.

If he was testing for just a 2, all you have to do is if(%rand == 2)

Pages: << < (3/4) > >>

Go to full version