Shovel/Mining Script

This script is really messing up with the ganis and the mining part…
Can someone lead me in the right direction?

if(playerchats && strequals(#c,buy shovel)){
  toweapons shovel;
}
if(weaponfired){
  setani benji_shovel,;
  replaceani walk,benji_shovel-walk;
  replaceani idle,benji_shovel-idle;
}else {
  replaceani idle,idle;
  replaceani walk,walk;
  setani idle,;
}
if(player && strequals(#L,mine.nw)){
  this.y=0;
  this.x=int(random(1,10));
  if(this.x>1){
    setplayerprop #c,you got nothing!;
  }else{
    this.y=#v(player && strequals(#s,client.ore)){
      this.y=this.y+1;
      replacestring client.ore,0,#v(this.y);
      setplayerprop #c,You found an ore!;
    }
  }
  sleep 1;
  showani default;
}

and I haven’t tested this part out yet…

if(playerchats && strequals(#c,Get Dirt Pale)){
toweapons Dirt Pale;
}
if(weaponfired){ // make players chat say the string holding Ore count.
    setplayerprop #c,#v(#s(client.oreamount)));
}

That script is retarded.

O_o, almost none of that is correct…

For one,

if(weaponfired){ if(this.on==0){ replaceani walk,benji_shovel-walk; replaceani idle,benji_shovel-idle; setani benji_shovel,; } else { replaceani idle,idle; replaceani walk,walk; setani idle,; } this.on=(this.on+1)%2; }

Then for the rest, you should look through the NPCs section and observer how to work with strings correctly.

It’ll only do what you tell it to. The only input allowed from the player is to fire the weapon–which changes their gani.

if([I][B]player[/B][/I] && strequals(#L,mine.nw)){ this.y=0; this.x=int(random(1,10)); if(this.x>1){ setplayerprop #c,you got nothing!; }else{ [I][B]this.y=#v(player && strequals(#s,client.ore)){[/B][/I] this.y=this.y+1; replacestring client.ore,0,#v(this.y); setplayerprop #c,You found an ore!; [I][B]}[/B][/I] }

What.

Also if you want a basic mining script, look at the newfeatures2001.txt, theres an example in there.

[QUOTE=Beholder;57578]

this.y=#v(player && strequals(#s,client.ore)){[/B][/I] this.y=this.y+1; }

[/QUOTE]

This part still isn’t working… Is there something I’m supposed to do there?

what does the flag player do?

[QUOTE=benjiro;57589]This part still isn’t working… Is there something I’m supposed to do there?[/QUOTE]

He was making fun of you, because it’s completely wrong and makes no sense. He didn’t change anything.

This script is so, fucking, funny. I literally laughed several times aloud to myself while reading through this.

I don’t claim to be a scripting expert but I must say… lolwut?

Is there any way to fix this? It would be an awesome script if this part worked… :frowning:

this.y=#v(player && strequals(#s,client.ore)){ this.y=this.y+1; }

No it wouldn’t be… I suggest you start over with my better idea. You should draw up a stick of dynamite and make a toss gani… Then you just throw the dynamite to blow the ore right out of the ground. If it’s not there, there’s no need for a message, because talking to yourself in Graal is pretty much idiotic.

[QUOTE=VariousWeapon;57610]No it wouldn’t be… I suggest you start over with my better idea. You should draw up a stick of dynamite and make a toss gani… Then you just throw the dynamite to blow the ore right out of the ground. If it’s not there, there’s no need for a message, because talking to yourself in Graal is pretty much idiotic.[/QUOTE]
That would be pretty cool. Too bad I don’t know how to script very well…
***Ooops… I’m on my testing account :0

When converting a string to a variable you have to do this:
this.y=strtofloat(#s(client.ore));
rather than
this.y=#v(player && strequals(#s,client.ore)
The strtofloat command converts a string (text) to a float (number) so that you can perform math on it or use it with variables

I’m not really sure what you are trying to do in your script, increase the value?
If so, you can do it like this:
this.y=strtofloat(#s(client.ore))+1; (Make sure you put your +1 outside of the brackets!)

Edit: Looking at your script

You don’t even need to use the this.y, you can just set it directly like so:

setstring client.ore,#v(strtofloat(#s(client.ore))+1);

You can perform any math operations you want inside a #v (variable / number)

As for this being ‘an awesome script’, no it’s not. You can just spam D anywhere inside a mine and you will get loads of ore.
You are better off looking for a mining script from another server and seeing how it works.

Normally you have ‘ore’ as npcs and you triggeraction them, you can find out how to use triggeraction in front of the player inside one of the newfeatures.txt (hint: CTRL+F for triggeraction)
Stefan made a “Freeze” npc which is a great base.

Thanks for the help. I know the part that allows you to “SPAM” the mines is a little stupid but it’s more realistic than just hitting rocks, and I’m also using a shovel.
SHOVEL VS. ROCK!
breaks shovel

You can use setshape to make massive invisible blocks that you can place all over the rock walls and then triggeraction those :slight_smile: