Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Money for all! (https://forums.graalonline.com/forums/showthread.php?t=75898)

theHAWKER 07-28-2007 12:41 AM

Money for all!
 
I am trying to make a target system where you have to shoot the targets...

BUT when ever i lose or gain money it dose the same for all the other players in the room...

so this is my script:
PHP Code:

//NPC Made By *theHAWKER
function onCreated(){
  
this.chat "Shoot Me!";
  
setTimer(.1);
}
function 
onActionAdd(){
  
with(findplayer(params[0])){
    
player.rupees += int(random(0,20));
  }
}
function 
onTimeout(){
  
this.+= random(0,1);
  
this.-= random(0,1);
  
setTimer(.3);
}
//#CLIENTSIDE
function onWasShot(){
  
this.chat "Hit!";
  
triggeraction(x,y,"add",player.account);
  
sleep(.5);
  
this.chat "Shoot Me!";


can someone tell me whats wrong, i think its the player.account part in the triggeraction...

DustyPorViva 07-28-2007 12:54 AM

triggeraction a WNPC(like have a money handling section or such) or DNPC to handle the money, don't do it inside the level NPC.

theHAWKER 07-28-2007 06:43 PM

Quote:

Originally Posted by DustyPorViva (Post 1334939)
triggeraction a WNPC(like have a money handling section or such) or DNPC to handle the money, don't do it inside the level NPC.

so i should make them a class?

WanDaMan 07-28-2007 09:16 PM

you need to add setshape to the serverside, inside onCreated

Crow 07-28-2007 09:40 PM

Exactly what Wan said. To explain that a bit: an npc needs a shape (setshape or setshape2) so it can be triggered.

theHAWKER 07-28-2007 09:59 PM

Quote:

Originally Posted by Crow (Post 1335098)
Exactly what Wan said. To explain that a bit: an npc needs a shape (setshape or setshape2) so it can be triggered.

ok, i have done all of this and i put it in a class, but it still gives money to other players...

here is my script:
PHP Code:

//NPC Made By *theHAWKER
function onCreated(){
  
setshape(1,32,48);
  
setimg("gl_target.png");
  
this.chat "Shoot Me!";
  
setTimer(.1);
}
function 
onActionAdd(){
  
with(findplayer(params[0])){
    
player.rupees += int(random(0,20));
  }
}
function 
onTimeout(){
hide();
sleep(random(1,3));
show();
sleep(random(1,3));
  
setTimer(.3);
}
//#CLIENTSIDE
function onWasShot(){
  
this.chat "Hit!";
  
triggeraction(x,y,"add",player.account);
  
sleep(.5);
  
this.chat "Shoot Me!";



DustyPorViva 07-28-2007 11:23 PM

No, what I meant was have a WNPC like a "-System" weapon, and on the serverside:
PHP Code:

function onActionserverside() {
if (
params[0]=="addrupees"findplayer(params[1]).rupees+=params[2];


Then in the level NPC, do something along the lines of:

PHP Code:

//#CLIENTSIDE
function onWasShot(){
  
this.chat "Hit!";
  
triggerserver("gui","-System","addrupees",player.account,int(random(0,20)));
  
sleep(.5);
  
this.chat "Shoot Me!";


I THINK you can triggerserver from a clientside of a level NPC, I'm not sure though.

theHAWKER 07-29-2007 08:10 PM

Quote:

Originally Posted by DustyPorViva (Post 1335115)
No, what I meant was have a WNPC like a "-System" weapon, and on the serverside:
PHP Code:

function onActionserverside() {
if (
params[0]=="addrupees"findplayer(params[1]).rupees+=params[2];


Then in the level NPC, do something along the lines of:

PHP Code:

//#CLIENTSIDE
function onWasShot(){
  
this.chat "Hit!";
  
triggerserver("gui","-System","addrupees",player.account,int(random(0,20)));
  
sleep(.5);
  
this.chat "Shoot Me!";


I THINK you can triggerserver from a clientside of a level NPC, I'm not sure though.

omg, so freaking complicated x.x

Quote:

I THINK you can triggerserver from a clientside of a level NPC, I'm not sure though.
nope

Chompy 07-29-2007 08:16 PM

Quote:

Originally Posted by theHAWKER (Post 1335274)
omg, so freaking complicated x.x

Uhm? You just need a weapon npc (The scripts that are listed when you click the weapons list) that can recieve the trigger from the other level npc (the target)

DustyPorViva 07-29-2007 09:58 PM

Quote:

Originally Posted by theHAWKER
omg, so freaking complicated x.x

It's not that complicated when you consider that once you make that one bit in the WNPC, you can triggerserver it from any NPC that needs to give the player money.

theHAWKER 07-30-2007 02:26 AM

Quote:

Originally Posted by DustyPorViva (Post 1335309)
It's not that complicated when you consider that once you make that one bit in the WNPC, you can triggerserver it from any NPC that needs to give the player money.

right, but it wont work with that strip of code in the npc x.x

dose it have to be in a class, or can it not be in a class?

Chompy 07-30-2007 09:01 AM

You could use a class.. and then trigger serverside in the class..
and from there using something like System.giveMoney() etc..


All times are GMT +2. The time now is 02:27 AM.

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