Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Beer Me ;D (https://forums.graalonline.com/forums/showthread.php?t=76556)

theHAWKER 08-28-2007 10:24 PM

Beer Me ;D
 
I am making a beer barrel where when you grab it 10 times you get a beer, then u can give it to a man for cash. So when the grab count reaches 0 it should but a beer in front of you to give to the man, but when it reaches 0 it goes to -1, then back to 9 with out doing any of the clientside functions which is laying the beer...

here is the script me and Takap2p made:
PHP Code:

//NPC By theHAWKER & Taka
function onCreated(){
this.grabs 10;
setTimer(.05);
}
function 
onTimeout(){
if (
this.grabs 1){
sleep 1;
onCreated();
}
setTimer(0.05);
}
function 
onActiongrabbed() {
this.grabs -= 1;
player.chat = @ this.grabs " grabs left..";
}
//#CLIENTSIDE
function onActiongrabbed() {
player.ani pull,;
}
function 
onTimeout(){
if (
this.grabs == 0){
say2("I Made A Beer!");
putnpc(1,beer,"beer.png",49.3,20);
setTimer(0.05);
}



Horrified 08-28-2007 10:43 PM

I see GS1 (sleep float; should be sleep(float);)...I doubt it makes a difference though, considering they compile the same.

bscharff 08-29-2007 02:56 AM

putnpc Cannot Be Clientside.
The System I Added To Graal Legacy Triggers onActionGrab. (If It Wasn't Deleted - If It Wasn't, Keep It!)
You should use putnpc2(x,y,"join beer;");

Perhaps:

PHP Code:


//NPC By theHAWKER & Taka (Bloo Loves Them)
function onCreated(){
this.grabs 10;
onTimeout();
}

function 
onTimeout(){
if (
this.grabs 1){
sleep(1);
onCreated();
}
sleep(.05);
onTimeout();
}

function 
onActionGrabbed() { //Possibly onActionGrab ?
this.grabs -= 1;
player.chat this.grabs " Grabs Left!";
}

function 
onActionGrabbed() {
setani("pull",NULL);
}

function 
onTimeout(){
if (
this.grabs <= 0){
say2("I Made A Beer!");
putnpc2(49.5,20,"join beer;"); //Might Be Easier To Round Coordinates To The Nearest .5
setTimer(0.05);
}



xXziroXx 08-29-2007 06:05 AM

Ack, bleh, urgh... such a CPU intensive script for something so simple.



PHP Code:

function onActiongrabbed() {
  
this.grabs ++;
  if (
this.grabs 10) {
    
say2("I Made A Beer!");  // might not work serverside, dont remember
    
temp.npc putnpc2(49.320"join(\"beer\");");
    
temp.npc.setimg("beer.png");
  } else 
player.chat this.grabs SPC "grabs left..";
  
setAni("pull""");



theHAWKER 08-29-2007 06:29 AM

Thx guys, ill try the both

theHAWKER 08-29-2007 07:29 AM

Quote:

Originally Posted by xXziroXx (Post 1344472)
Ack, bleh, urgh... such a CPU intensive script for something so simple.



PHP Code:

function onActiongrabbed() {
  
this.grabs ++;
  if (
this.grabs 10) {
    
say2("I Made A Beer!");  // might not work serverside, dont remember
    
temp.npc putnpc2(49.320"join(\"beer\");");
    
temp.npc.setimg("beer.png");
  } else 
player.chat this.grabs SPC "grabs left..";
  
setAni("pull""");



that worked tyvm :D

xXziroXx 08-29-2007 09:45 AM

PHP Code:

function onActiongrabbed() {
  
this.grabs ++;
  if (
this.grabs == 10) {
    
say2("I Made A Beer!");  // might not work serverside, dont remember
    
temp.npc putnpc2(49.320"join(\"beer\");");
    
temp.npc.setimg("beer.png");
    
this.grabs NULL;
  } else 
player.chat this.grabs SPC "grabs left..";
  
setAni("pull""");


Oops ^^


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

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