Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Shovel (https://forums.graalonline.com/forums/showthread.php?t=134259924)

xMane 07-22-2010 11:36 PM

Shovel
 
http://forums.graalonline.com/forums...ad.php?t=73836
/\
PHP Code:

function onActionServerside(serverOption)
{
  if (
temp.serverOption != "dig")
  {
    return 
false;
  }
  
temp.digPosition player.dropPosition();
  if (
clientr.lastDig[0] == temp.digPosition[0] && clientr.lastDig[1] == clientr.lastDig[1])
  {
    return 
false;
  }
  
  
temp.digCheck this.checkTiles(temp.digPosition);
  
  
clientr.lastDig temp.digPosition;
  
setani("v_shovel""v_shovel-"temp.digCheck @".png");
  
  switch (
temp.digCheck)
  { 
    case 
"grass":
      
this.doDrops(temp.digPosition, {{"object_hole"0}, {"object_artifact"290}});
    break;
    
    case 
"sand":
      
this.doDrops(temp.digPosition, {{"object_sandhole"280}, {"generator_dungeon"0}});
    break; 
  }
}
function 
checkTiles(position)
{
  
temp.tilePosition tiles[temp.position[0], temp.position[1]];
  
temp.allTiles = {
    {
"grass", {102329910100816130197131147114}},
    {
"sand", {301171170299329923010297715,  83813822881812976}},
    {
"darksand", {170947949895847904339905}}
  };
  for (
temp.currentTilestemp.allTiles)
  {
    if (
temp.tilePosition in temp.currentTiles[1])
    {
      
temp.foundTile temp.currentTiles[0];
      break;
    }
  }
  return 
temp.foundTile;
}
function 
doDrops(dropPositiondropMode)
{
  for (
temp.currentDroptemp.dropMode)
  {
    if (
temp.currentDrop[1] != 0)
    {
      
temp.doDrop = (random(0300) < temp.currentDrop[1]? truefalse);
    }
     else
    {
      
temp.doDrop true;
    }
    if (
temp.doDrop)
    {
      
putnpc2(temp.dropPosition[0], temp.dropPosition[1], ("join" SPC temp.currentDrop[0] @";"));
    }
  }
}
public function 
dropPosition()
{
  
temp.playerPos = {{0.751}, {0.61.5}};
  
temp.dropPos = {
    
player.+ (player.dir in {02}? temp.playerPos[0][0] : temp.playerPos[1][0]) + vecx(player.dir) * 2,
    
player.+ (player.dir in {02}? temp.playerPos[0][1] : temp.playerPos[1][1]) + vecy(player.dir) * 2
  
};
  return 
temp.dropPos;
}
//#CLIENTSIDE
function onWeaponFired()
{
  
triggerserver("weapon"this.name"dig");
  
setani("grab",NULL);


how would i make that drop sumthing? also only dig in sand and leave a rock lifted hole?

fowlplay4 07-22-2010 11:45 PM

By learning how to script.

xMane 07-22-2010 11:46 PM

Quote:

Originally Posted by fowlplay4 (Post 1589117)
By learning how to script.

Ha. Your funny. I know how to script im trying to do what i am saying but it isnt working out so good.

fowlplay4 07-22-2010 11:58 PM

Quote:

Originally Posted by xMane (Post 1589119)
Ha. Your funny. I know how to script im trying to do what i am saying but it isnt working out so good.

Then it should have been obvious to..

Edit the checkTiles, and how the switch statement evaluates the value returned by it.

You can use a script like this to get the tiles ID.

PHP Code:

//#CLIENTSIDE
function onMouseDown() {
  
player.chat "Tile: " tiles[mousexmousey];



xMane 07-23-2010 12:01 AM

oooooooooooo. lol so how would it check if player.x.tiles or wat how would i check if its in the tiles?

Crow 07-23-2010 12:13 AM

Where did you get this code from? It's obviously not yours, seems beyond your skill level.

xMane 07-23-2010 12:13 AM

they'res a link at the top >.> also how do i find the current tile i am on?

Soala 07-23-2010 12:25 AM

Quote:

Originally Posted by xMane (Post 1589127)
how do i find the current tile i am on?

Quote:

Originally Posted by fowlplay4 (Post 1589121)
You can use a script like this to get the tiles ID.

PHP Code:

//#CLIENTSIDE
function onMouseDown() {
  
player.chat "Tile: " tiles[mousexmousey];



:whatever:

xMane 07-23-2010 12:30 AM

OOOOOOOOOH. didnt notice xD

cbk1994 07-23-2010 01:33 AM

Look into putnpc2...

Quote:

Originally Posted by fowlplay4 (Post 1589117)
By learning how to script.


xMane 07-23-2010 06:07 AM

Ok I fully scriptd it from scrach thanks for ur help guys I ended up not using putnpc2 atm but imma add it l8r. 1 question also how do I change colors effect on a light2.png in a gani.

xAndrewx 07-23-2010 08:09 AM

haha you used my old script, thanks.

Inside the gani use
HTML Code:

COLOREFFECT SPRITEINDEX 1 1 1 0.5

xMane 07-23-2010 04:50 PM

Quote:

Originally Posted by xAndrewx (Post 1589191)
haha you used my old script, thanks.

Inside the gani use
HTML Code:

COLOREFFECT SPRITEINDEX 1 1 1 0.5

Thanks xD. I love the shovel script but for somereason it was'nt working properly so i had to script it again. xD mynes sucks but its "ok".
PHP Code:

function onActionServerSide(trigger)
{
 if(
trigger == "randomize")
 {
  
temp.random=int(random(0,10));
  if(
temp.random==0)
{
  
setani("ge_chestfound",NULL);
//adding diff amounts of gralats
}
 }
  if(
trigger == "dig")
 {
 
temp.sandtiles = {170,15,8,301,358,391};
 if(
tiles[player.x,player.yin temp.sandtiles)
 {
  
setani("ge_shovel",NULL);
  }else
   
setani("shovel2",NULL);
 }
}
//#CLIENTSIDE
function onWeaponFired()
{

 
triggerserver("gui"name"dig");
 
triggerserver("gui"name"randomize");



fowlplay4 07-23-2010 05:28 PM

Well that's some fail triggering right there, why are you doing things that should be done on the clientside on the serverside?

PHP Code:

function onActionServerSide(trigger

 if(
trigger == "award"
 { 
  
// stuff 
 


//#CLIENTSIDE 
function onWeaponFired() 

 
temp.sandtiles = {170,15,8,301,358,391}; 
 if(
tiles[player.x,player.yin temp.sandtiles
 { 
  
setani("ge_shovel",NULL); 
  
temp.random=int(random(0,10));  
  if(
temp.random==5)  
  {  
    
setani("ge_chestfound",NULL);
    
triggerserver("gui"name"award");
  } 
 } else {
   
setani("shovel2",NULL); 
 } 



xMane 07-23-2010 05:48 PM

Dont wanna be hackable :/. sooya. i changed it. but now how do i add freeze to it
PHP Code:

function onActionServerSide(trigger)
{
 if(
trigger == "randomize")
 {
  
temp.random=int(random(0,10));
  if(
temp.random==0)
  {
   
player.gralats+=int(random(10,75));
  
setani("ge_chestfound",NULL);
  }
 }
  if(
trigger == "dig")
 {
 
temp.sandtiles = {170,15,8,301,358,391};
 if(
tiles[player.x,player.yin temp.sandtiles)
 {
  
setani("ge_shovel",NULL);
  
//removed clientr.lastdig={player.x,player.y};
  
triggerclient("gui"name"DoRandom");
  }else
   
setani("shovel2",NULL);
 }
}
//#CLIENTSIDE
function onWeaponFired()
{
 
triggerserver("gui"name"dig");
}
function 
onDoRandom();
{
 
triggerserver("gui"name"randomize");




All times are GMT +2. The time now is 08:32 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.