Blockland Forums > Modification Help
how to display variables?
(1/5) > >>
deathrider:
new op.

so how do you show variables?
i cant get it to work. i dont know what i have done wrong as i just learnt this last night and theres no posts on variables or what to put in the () at the end of
--- Code: ---function servercmdmessage(%client)
--- End code ---
all i know is that %client goes in there.

i also need to know how to do IF statements i know what they are i use them in batch.
if you get the chance whats the diffence between client.cs and server.cs?

--- Code: ---function serverCmdmessage(%client, %message)
{
announce("%message)";
  }
  
function serverCmdload(%client)
{
talk("Loading script...");
exec("Add-Ons/Script_Testing/server.cs");
talk("Script loaded!");
  }
--- End code ---
Axolotl:

--- Code: ---function serverCmdmessage(%client, %message)
{
announce(%message);
}
--- End code ---

If statements run what's inside them if the variable is equal to 1.

--- Code: ---if(%variable)
{
   echo("%variable is 1");
}
else
{
   echo("%variable is 0 :c");
}
--- End code ---

You can also check for values and strings.


--- Code: ---if(%variable == 12345)
{
   echo("%variable is 12345");
}
else
{
   echo("%variable is something else :c");
}

if(%variable $= "String")
{
   echo("%variable is \"String\"");
}
else
{
   echo("%variable is something else :c");
}
--- End code ---

Client.cs is executed when blockland is launched, server.cs is executed when a server is being hosted.
deathrider:

--- Quote from: Axolotl on April 06, 2012, 04:03:50 AM ---
--- Code: ---snip
--- End code ---

Client.cs is executed when blockland is launched, server.cs is executed when a server is being hosted.

--- End quote ---
Thank you so much. but i did it heres what i did and it did not work, i have no idea why. The file is server.cs, i loaded a server(singleplayer)

Anyway heres the code i used, it did not work it should reply with an id, right?

--- Code: ---function serverCmdme(%client)
{
  echo("%client");
}
--- End code ---
Axolotl:

--- Quote from: deathrider on April 06, 2012, 04:20:52 AM ---Thank you so much. but i did it heres what i did and it did not work, i have no idea why. The file is server.cs, i loaded a server(singleplayer)

Anyway heres the code i used, it did not work it should reply with an id, right?

--- Code: ---function serverCmdme(%client)
{
  echo("%client");
}
--- End code ---

--- End quote ---
Remove the ""s when using a variable.
deathrider:

--- Quote from: Axolotl on April 06, 2012, 05:03:53 AM ---Remove the ""s when using a variable.

--- End quote ---
done and it worked thanks. Are there any vars that are already set so like %client must be one idk what %player is but i got commands i did
--- Code: ---findclientbyname(deathrider).player.dump;
--- End code ---

quick edit:
any way i can get the console to talk to me? Like i do /load it then loads the script the problem is i have to open console just to see if any errors any whay i can get it to do talk();with all the errors. also i need to know how to ask the client for varabiles so like you say /admin dom

it would then do
findclientbyname(dom).player.isadmin(1);

dom is the var.

new edit:

--- Code: ---  function servercmdadmin(%client)
{
  if(%client.isAdmin)
    {
      talk(%clientname SPC "is hacking!");
    }
else
    {
    echo(no.");
    }
}
--- End code ---
has syntax errors after echo("no.");
%clientname is a var i set using

--- Code: ---%clientname = %client.getName();
--- End code ---
Navigation
Message Index
Next page

Go to full version