Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   slashing game is broken :( (https://forums.graalonline.com/forums/showthread.php?t=75281)

theHAWKER 07-12-2007 10:43 PM

slashing game is broken :(
 
this is in a barrel npc in a level. you are sapost to slash the barrel a bunch of times untill the barrel has 0 hits left, then it gives you cash.

the only part that wont work is the give you cash part at the botem.
PHP Code:

//NPC by theHAWKER
function onCreated(){
this.hits 1000;
setTimer(.5);
}
function 
onWa****(){
this.hits -= int(random(1,10));
onHitCheck;
}
function 
onTimeout(){
this.chat = @this.hits" hits left!";
setTimer(.5);
}
//#CLIENTSIDE
function onHitCheck(){
if (
this.hits == || this.hits 0){
player.chat "I got 250$!";
player.rupees += 250;
onCreated();
}
echo(
"HitCheckIsWorking");



killerogue 07-12-2007 10:45 PM

Yes, let's all call CLIENTSIDE FUNCTIONS, from SERVERSIDE.

theHAWKER 07-12-2007 10:51 PM

it still dose the same thing with no clientside...

Gambet 07-12-2007 10:53 PM

Quote:

Originally Posted by theHAWKER (Post 1328703)
it still dose the same thing with no clientside...



When you set a this. variable serverside or clientside, it won't read the same with the counterpart (I.E if you set a this. variable clientside, it won't read the same serverside unless you use a trigger and send the variable over, and the same goes for setting it serverside).

Twinny 07-12-2007 10:54 PM

you have onhitcheck serverside and the function is clientside. Yeehaw.

Also, you can't set player rupees clientside.

theHAWKER 07-12-2007 10:56 PM

it still dose the same thing with no clientside....

Gambet 07-12-2007 10:57 PM

Quote:

Originally Posted by theHAWKER (Post 1328707)
it still dose the same thing with no clientside....



Who said that all of those functions work serverside? x-x

theHAWKER 07-12-2007 10:59 PM

Quote:

Originally Posted by Gambet (Post 1328708)
Who said that all of those functions work serverside? x-x

can u help me out? :D

Twinny 07-12-2007 11:00 PM

Quote:

Originally Posted by theHAWKER (Post 1328707)
it still dose the same thing with no clientside....

You said it all works except the money part. You have the money part clientside. You cannot set money clientside. You also call a clientside function from serverside which is impossible. Hell, you call onCreated() clientside when the only onCreated block is serverside.

Also, when calling a function, do blah(); not blah;

theHAWKER 07-12-2007 11:05 PM

Quote:

Originally Posted by Twinny (Post 1328710)
Also, when calling a function, do blah(); not blah;

that worked xD thx :D

Gambet 07-12-2007 11:11 PM

PHP Code:

function onActionAward()
{
 
player.rupees+=250;
}

//#CLIENTSIDE
function onCreated()
{
 
reset_NPC(0);
}

function 
onWa****()
{
 
this.to_deduct int(random(1,10));
 if (
this.hits this.to_deduct >= 0)
  {
   
this.hits this.hits this.to_deduct;
   
this.chat this.hits " hits left!";
  }
 else
  {
   
this.hits NULL;
   
NPC_Dead();
  }
}

function 
NPC_Dead()
{
 
this.chat "";
 
player.chat "I got $250!";
 
player.triggeraction(x+1.5,y+1.5,"Award","");
 
reset_NPC(2);
}

function 
reset_NPC(time)
{
 
sleep(time);
 
this.hits 1000;
 
this.chat this.hits;



Scripted it here on the forums so didn't test anything, but works in theory.


All times are GMT +2. The time now is 03:30 PM.

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