Blockland Forums > Modification Help
Incorrect script, need fixing
<< < (2/4) > >>
CityRPG:

--- Quote from: Headcrab Zombie on December 30, 2011, 02:51:22 PM ---Nothing is wrong with the code, its packaged incorrectly or not enabled or something similar.

--- End quote ---
You do not need to package new functions, only when overwriting existing ones.



--- 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 ---

getRandom will generate a number between 1 and 6. I don't know where you got 1 through 5 from.

switch() allows you to handle one variable based on many different values easily.

default: handles all exceptions not covered by specific cases. Since 1-6 is cased in the above code, the default message is entirely unnecessary -- hence the message.


The percent sign (%) is called the modulus sign. It gets the remainder of division by the following number. It's like division in elementary school, where the leftovers were put on the side as "r5" instead of being a decimal place.


--- Code: ---function serverCmdTest(%client)
{
%rand = getRandom(0, 9);

if( (%rand % 3 == 0) && (%rand != 0) )
{
messageClient(%client, '', "You rolled a" SPC %rand @ ", which is evenly divisible by 3.");
}
}
--- End code ---
Superb:

--- 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 ---

He meant when you throw your stuff into a Server_zipFile and put it in the add-ons folder.

Welcome back Iban.  :cookieMonster:
CityRPG:
Do people seriously develop Add-Ons in .ZIP format?
jes00:

--- Quote from: CityRPG on January 10, 2012, 10:05:15 AM ---getRandom will generate a number between 1 and 6. I don't know where you got 1 through 5 from.

--- End quote ---
No, it will generate a number between whatever you tell it to.
Superb:

--- Quote from: CityRPG on January 10, 2012, 10:09:07 AM ---Do people seriously develop Add-Ons in .ZIP format?

--- End quote ---

I don't, he may though..
Navigation
Message Index
Next page
Previous page

Go to full version