Player Classes

A friend of mine asked me if I could make a simple Class system for his Gold server.
So I made this quick script in JS, since I know close to nothing about GS2 and hope that this will get me started.
After looking at the syntax on Graal Bible, I guess that it looks like a closer derivation of JS than GS1 does, so I hope that this won’t be too hard.
Here it is:

Scenario:
Player walks up to an NPC. NPC prompts him to choose a class.
Giving him the option of several classes (say2 …).
Player says which class he would like and a weapon is assigned to him
(ex: Archer’s get bow, Rogue’s get sword). Keep in mind that
all of the previous weapons (bombs and bow) are removed and 1 new weapon is added.

var player = prompt("Choose a Class!"); 
var Archer, Rogue; 
if (player === "Archer") {
    console.log("You chose Archer!");
}
else if (player === "Rogue") {
    console.log("You chose Rogue!");
}
else {
    console.log("I couldn't understand your pesky accent");
}

Something like this (tried to do it in GS1):

if (playerenters) {
// Add NPC Attributes here
say2 What Class would you like? Archer or Rogue;
}
if (playersays Archer) { // yes, this is wrong...
message You chose Archer!;
triggeraction 0,0,gr.deleteweapon, bow && bomb; //This is where it goes I guess? Removes weapons player has by default.
toweapons custom_bow;
timeout 0.5;
setlevel2 destination.nw,30,30; //Warps player to destination after class has been chosen
}
if (playersays Rogue) {
message You chose Rogue!;
triggeraction 0,0,gr.deleteweapon, bow && bomb;//Removes weapons player has by default
toweapons custom_sword;
timeout 0.5;
setlevel2 destination.nw,30,30; //Warps player to destination after class has been chosen
}
else {
message I couldn't understand your pesky accent!;
}

Help me out here!
Sorry for the GS2 request. I don’t feel like posting anywhere else.
-Thanks!

I dunno any gs2, but the way you have it the else will get called even if they choose archer.

[QUOTE=Rammy;107017]
A friend of mine asked me if I could make a simple Class system for his Gold server.
So I made this quick script in JS, since I know close to nothing about GS2 and hope that this will get me started.
After looking at the syntax on Graal Bible, I guess that it looks like a closer derivation of JS than GS1 does, so I hope that this won’t be too hard.
Here it is:

Scenario:
Player walks up to an NPC. NPC prompts him to choose a class.
Giving him the option of several classes (say2 …).
Player says which class he would like and a weapon is assigned to him
(ex: Archer’s get bow, Rogue’s get sword). Keep in mind that
all of the previous weapons (bombs and bow) are removed and 1 new weapon is added.

var player = prompt("Choose a Class!"); 
var Archer, Rogue; 
if (player === "Archer") {
    console.log("You chose Archer!");
}
else if (player === "Rogue") {
    console.log("You chose Rogue!");
}
else {
    console.log("I couldn't understand your pesky accent");
}

Something like this (tried to do it in GS1):

if (playerenters) {
// Add NPC Attributes here
say2 What Class would you like? Archer or Rogue;
}
if (playersays Archer) { // yes, this is wrong...
message You chose Archer!;
triggeraction 0,0,gr.deleteweapon, bow && bomb; //This is where it goes I guess? Removes weapons player has by default.
toweapons custom_bow;
timeout 0.5;
setlevel2 destination.nw,30,30; //Warps player to destination after class has been chosen
}
if (playersays Rogue) {
message You chose Rogue!;
triggeraction 0,0,gr.deleteweapon, bow && bomb;//Removes weapons player has by default
toweapons custom_sword;
timeout 0.5;
setlevel2 destination.nw,30,30; //Warps player to destination after class has been chosen
}
else {
message I couldn't understand your pesky accent!;
}

Help me out here!
Sorry for the GS2 request. I don’t feel like posting anywhere else.
-Thanks!
[/QUOTE]

function onCreated(){
  setshape(1,32,32);
  dontblock();
}

function onActionServerSide(){
  if (params[0] == "RemoveWep")
    player.removeweapon(params[1]);

  else if (params[0] == "AddWeapon")
    player.addweapon(params[1]);

  else if (params[0] == "WarpPlayer")
    player.setlevel2(params[1], strtofloat(params[2]), strtofloat(params[3]));
}

//#CLIENTSIDE
function onCreated(){
  setshape(1,32,32);
  dontblock();
}

function onPlayerenters(){
  // Add NPC Attributes here
  say2("What class would you like? Archer or Rogue?");
}

function onPlayerchats(){
  if (player.chat == "Archer") {
    this.chat = "You chose Archer!";
    
    callServer("RemoveWep", "bow",0,0);
    callServer("RemoveWep", "bomb",0,0);
    
    callServer("AddWeapon", "custom_bow",0,0);
    sleep(0.1);
    callServer("WarpPlayer", "destination.nw", 30, 30);
  }
  else if (player.chat == "Rogue"){
    this.chat = "You chose Rogue!";

    callServer("RemoveWep", "bow",0,0);
    callServer("RemoveWep", "bomb",0,0);

    callServer("AddWeapon", "custom_sword",0,0);
    sleep(0.1);
    callServer("WarpPlayer", "destination.nw", 30, 30);
  }
  else {
    this.chat = "I couldn't understand your pesky accent!";
  }
}

function callServer(param0, param1, param2, param3){
  triggeraction(this.x + 1, this.y + 1, "ServerSide", param0, param1, param2, param3);
}

There’s probably a few errors in here. I can’t remember whether gs2 implicity tries to cast strings to floating point. And there might be the odd syntax error seeing as I wrote this on the spot. Still, give it a shot.

[QUOTE=Rammy;107017]Sorry for the GS2 request.[/QUOTE]
That made me laugh. (I’m not making fun of you.)

Wouldn’t the code have to be diffrent of him changing a class like the starting out class wanting to switch to archer?

[QUOTE=Doskashin;107024]Wouldn’t the code have to be diffrent of him changing a class like the starting out class wanting to switch to archer?[/QUOTE]

Class Systems don’t exist in Graal and the code isn’t really creating a Class System (as you may have noticed).
It’s simply giving the user a specific weapon based on his answer.
Think of it like a man going to buy fruits at the supermarket.
If he chooses “Apple” he’ll have an apple.
If he chooses “Orange” he’ll have an orange. (logic).
But that doesn’t change the person itself, just what he has in his inventory.

[QUOTE=Doskashin;107024]Wouldn’t the code have to be diffrent of him changing a class like the starting out class wanting to switch to archer?[/QUOTE]

Only in regards to removing the other class’s weapons.

[QUOTE=Rammy;107045]
Class Systems don’t exist in Graal and the code isn’t really creating a Class System (as you may have noticed).
It’s simply giving the user a specific weapon based on his answer.
Think of it like a man going to buy fruits at the supermarket.
If he chooses “Apple” he’ll have an apple.
If he chooses “Orange” he’ll have an orange. (logic).
But that doesn’t change the person itself, just what he has in his inventory.
[/QUOTE]

What if he wants an “Apple” and “Orange”. Lol

[QUOTE=Doskashin;107053]What if he wants an “Apple” and “Orange”. Lol[/QUOTE]

[video=youtube;PkGrkNu6mDg]http://www.youtube.com/watch?v=PkGrkNu6mDg[/video]

[QUOTE=Doskashin;107053]What if he wants an “Apple” and “Orange”. Lol[/QUOTE]

I don’t care if you’re being figurative, you’re not helping the thread.

[QUOTE=Yggdrasil;107060]I don’t care if you’re being figurative, you’re not helping the thread.[/QUOTE]

It was suppose to be a joke.