Blockland Forums > Modification Help
Help a starter scripter
(1/3) > >>
Chefzor:

--- Code: ---function servercmdtavernpot(%client,%empty)
{
if(%empty$=””)
{
 %rand=getrandom(1,10);
 if(%rand==1)
 {
  %client.prefix=”handicapped”;
 }
 if(%rand==2)
 {
  %client.prefix=”Cozy”;
 }
 if(%rand==3)
 {
  %client.prefix=”Sleeping”;
 }
 if(%rand==4)
 {
  %client.prefix=”Traveling”;
 }
 if(%rand==5)
 {
  %client.prefix=”Wandering”;
 }
 if(%rand==6)
 {
  %client.prefix=”Lovely”;
 }
 if(%rand==7)
 {
  %client.prefix=”Curious”;
 }
 if(%rand==8)
 {
  %client.prefix=”Sleepy”;
 }
 if(%rand==9)
 {
  %client.prefix=”Harmless”;
 }
 if(%rand==10)
 {
  %client.prefix=”Dangerous”;
 }
 %rand2=getrandom(1,10);
 if(%rand2==1)
 {
  %client.suffix=”Pillow”;
 }
 if(%rand2==2)
 {
  %client.suffix=”Bed”;
 }
 if(%rand2==3)
 {
  %client.suffix=”Blanket”;
 }
 if(%rand2==4)
 {
  %client.suffix=”Donkey”;
 }
 if(%rand2==5)
 {
  %client.suffix=”Shoe”;
 }
 if(%rand2==6)
 {
  %client.suffix=”Owl”;
 }
 if(%rand2==7)
 {
  %client.suffix=”Monstrosoty”;
 }
 if(%rand2==8)
 {
  %client.suffix=”Traveler”;
 }
 if(%rand2==9)
 {
  %client.suffix=”Willow”;
 }
 if(%rand2==10)
 {
  %client.suffix=”Dream”;
 }
 
 messageall("admin","<color:FFFFFF>"@%client.prefix@" <color:FFFF00>"@%client.suffix@" <color:FF00FF>might be a good name!");
}
else
{
 messageclient(%client,’’,”Invalid”);
}
}
--- End code ---
Above is server.cs and below is description.txt

--- Code: ---Title: Tavern name generator
Author: Kyttike
Does what it name says.
--- End code ---
Help is appreciated
Chefzor:
Its packed in a Script_Tavernpot.zip
Console says syntax error on 1st line.

PS. My first script evar
otto-san:
%client.clanSuffix

if(%empty $= "")
Chefzor:
I may sound noobish but wut.
Headcrab Zombie:
What are you even doing with %empty? I see no purpose for it.

Also, instead of using an assload of ifs, consider using a switch statement


--- Code: ---switch(%rand)
{
    case 1:
        //do stuff if %rand == 1
    case 2:
        //do stuff if %rand == 2
    case 3:
        //do stuff if %rand == 3
    default:
        //do stuff if one of the above cases is not true
}
--- End code ---

It's a lot less typing and looks neater.
Also try indenting more, it makes it easier to read.
Navigation
Message Index
Next page

Go to full version