John, before i would start on learning something new, i decided to go back on every thing i'v previously learnt with you, Emera, Callimuc and PerfecDark. As you know I'm highly energetic :D! So, what do you think i should earn next?
Printable View
John, before i would start on learning something new, i decided to go back on every thing i'v previously learnt with you, Emera, Callimuc and PerfecDark. As you know I'm highly energetic :D! So, what do you think i should earn next?
lol, im trying to learn haha
Yea:D, Imainly wanna gfx or LAT, but I can also gani.So if I learn to script, I could maybe be a developer! :D
Where did you stop at?
well, i forgot my password on graalians today, but at least i previously i went through the scripts again and i found out what you guys meant by styling the script.
i last stopped at triggering something to a ever side or a Client side, i still need to go through loops but if I'm currently not ready i can learn something else you would like me to learn in order for me to be good coder like you, John, Emera and PerfectDark.
So what would you like as to start now?
Loops are easy, useful and efficient tools in java, and I'm fairly sure they're just as useful in gs2
A for loop is simple:
The x=1 defines a variableHTML Code:for (x=1;x<=5;x++)
{
System.out.println("hello!"); //I believe echo is used in gs2
}
x<=5 shows how many times you want the loop to repeat
x++ will make the x value move up
As long as it is less than or equal to five in this case, the loop will repeat.
The output of the following is:
HTML Code:hello!
hello!
hello!
hello!
hello!
Lol, I don't even know what loops are xD
They make life easy by repeating a set of code a set amount of time.
With a loop, you can use the two easy lines of code instead of doing something like:
Loops are much more efficient when you need to repeat something a lot of times, like instead if typing that line 100 times, just change the 5 in the loop to a 100 for the same outputHTML Code:System.out.println("hello!");
System.out.println("hello!");
System.out.println("hello!");
System.out.println("hello!");
System.out.println("hello!");
Wow, complicated but getting it.
Can we start easy?
Oh yes poorface, I think we stopped at loops...
They're pretty easy to learn, I guess I can include them in my next tutorial, but here's an overview.
A loop can be either infinite, or specific, and the only way to stop a loop is to put 'break;' or 'return;' if it is infinite.
Lot's of ways to have loops on Graal.
I'm going to teach you the for(); loop today. Let me show you how it works correctly.
what this will echo is:PHP Code:
function onCreated() {
for (i = 0; i < 6; i++) {
echo(i);
}
}
So how does this work? You have three arguments to have in a for() loop.Quote:
0
1
2
3
4
5
You can replace all of the above this way:PHP Code:
for (i = 0; // This will be read once at the beginning
i < 5; // this will be checked everytime
i += 1 // or whatever you want to change every time the loop starts (WARNING, this does not take a semi colomn
) {
echo(i);
}
PHP Code:
function onCreated() {
i = 0;
if (i < 5) break;
echo(i);
i += 1; // or i++; whatever
if (i < 5) break;
echo(i);
i +=1;
if (i < 5) break;
echo(i);
i += 1;
if (i < 5) break;
echo(i);
i += 1;
if (i < 5) break;
echo(i);
i += 1;
// etc
}
Wow. So it is like counting, or continous things it says?
well, I understand now what "break;" does, I don't understand what not make them like a line like so:
PHP Code:
function onActionServerSide(pl, this.lucky) {
for (pl : players) {
if (pl.level == "era_lucky-grab.nw") {
pl.setlevel2("era_luck-grab.nw", 30, 30);
triggerclient("gui", name, pl)
}
if (this.lucky == true)
pl.setlevel2("era_lucky-grab.nw", 30, 40);
}
pl.setlevel2("era_start.nw", 30, 30);
}
}
function onCreated() {
for (this.num = 0; this.num < 5; this.num--) {
}
}
//#CLIENTSIDE
function onPlayerChats() {
this.staff = "Events Team";
if (player.guild in this.staff && player.chat == "down") {
triggerserver("gui", name, NULL);
}
}
function onActionClientSide(pl) {
this.lucky = "Yay I'm luck!";
if (player.guild in this.staff && player.chat == ":timer") {
player.chat = "kicking in: " @ this.num;
if (player.this.staff.chat == "0")
sleep(3);
if (pl.level == "era_lucky-grab.nw" && player.chat == "Yay I'm lucky!")
triggerserver("gui", name, pl, this.lucky)
}
if (player.chat != this.lucky) {
triggerserver("gui", name, NULL)
}
}
}
}
Serverside and clientside aren't even operated on the same things.
Clientside is compiled then sent off to be executed on the client whilst serverside is compiled then sent off to be executed by the server.
Therefore, this. variables will go through the whole script, but only on the size it's instanced on. So, a this.timer = 5; declaration on serverside will not set this.timer = 5; on clientside and vice versa.
You use while and do...while for conditional looping (you don't know how many times you have to loop). You use switch when you wanna compare 1 variable to a bunch of values (could also be done with a bunch of if...else if). You use break if you want to exit a loop early (I usually put those with a condition). You use return; when you want to exit a function early. I could give you java syntax, but you probably don't want that.
How do i make a stealth and a gagged script?
Stealth generally requires a gani on the player assigned to an attr and a gag/mute script is something that will probably be taught later but should not be attempted at this stage since it does require a few more complicated functions, etc.
Please don't give these types of partial explanations as they can mislead the coder.
He probably wants to know the whole system and not just setting a simple alpha or a simple chat upon the player chatting.
Aye, so here's how you pass a variable from the Clientside to the serverside.
I have not tested this yet because I'm not on my normal PC right now, so if you encounter any errors, I'll fix em later. As for a gag script, try this little hint. Write a player clientr flag when the player is gagged. In a weapon added to every player on the server, read the flag, and if it's added to the player, stop the player from chatting. As an example:PHP Code:
function onActionServerSide (cmd, temp.var1, temp.var2) { //cmd is the first param, you can call this w/e
if (cmd == "boop" ) {
echo(temp.var1 SPC temp.var2);
//Echoes corn dog and dog corn when the player says yo
}
}
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "yo") {
temp.variable1 = "corn dog";
temp.variable2 = "dog corn";
triggerServer("gui", this.name, "boop", temp.variable1, temp.variable2);
//Send the information to the server
}
}
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
if(player.clientr.isGagged) {
player.chat = "wtf man im gagged like omg";
}
}
Okay, I won't do a gagged script because it would probably be bad. I don't know what i need to learn to make a gagged script. What's clientr?
clientr is the client flag of the player (think of it like a variable..though it's actually an object). The 'r' at the end of it means that these flags are read-only by the clientside (meaning if the player tried to hack and change their clientr flag for ammo to 9999 for instance, it will not work because clientr is read-only for the clientside (player)).
we also have the normal client flags that can be read/written by both clientside and serverside
Can you see the benefits of both types of player object's client flags?
im 10 and turning 11 and i know how to sprint
yea I can.