Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Quick Question (https://forums.graalonline.com/forums/showthread.php?t=134264940)

Equinox 11-01-2011 10:13 PM

Quick Question
 
Would this script work online?

NPC Code:

function onActionLeftMouse() {
putnpc beer.png,beer.txt,mouse.x,mouse.y;
}

beer.txt:

function onPlayerTouchsme {
player.hearts += 3;
destroy;
}
else
sleep (10);
destroy;



fowlplay4 11-01-2011 10:17 PM

No.

PerfectDark 11-02-2011 12:07 AM

Quote:

Originally Posted by fowlplay4 (Post 1672633)
No.

Agreed it wouldn't work.. maybe make a class or something

>.> @ who ever sent rep in this thread (-PFA)

iBeatz 11-02-2011 12:36 AM

Quote:

Originally Posted by PerfectDark (Post 1672647)
Agreed it wouldn't work.. maybe make a class or something

A class NPC wouldn't fix the errors in the script. :rolleyes:

PerfectDark 11-02-2011 01:01 AM

i didnt mean that way... :(

fowlplay4 11-02-2011 01:16 AM

Here's why it won't work (don't want you to get confused by the inexperienced others):

1. putnpc isn't used anymore, and you'll have to create a class called beer instead. Use putnpc2 like this instead:

PHP Code:

function onCreated() {
  
temp.npc putnpc2(x,y,"");
  
temp.npc.join("class_name");


2. onActionLeftMouse only applies when you click an NPC. You have to use client-side events in a weapon script and send that data to the server-side then create the npc. Search the forums for triggerserver examples.

PHP Code:

//#CLIENTSIDE

function GraalControl.onMouseDown() {
  
player.chat format("Clicked! X: %s Y: %s"mousexmousey);


3. If you want the 'beer' to be destroyed 10 seconds after it's created you'll have to use the onCreated event and a timeout.

PHP Code:

function onCreated() {
  
setTimer(10); // Schedules a Timeout in 10 seconds from now.
}

function 
onTimeout() {
  
// Timeout occured
  
destroy();



Draenin 11-02-2011 02:13 AM

If you want to know whether a script will work online or not, check into getting access on the testbed server so you can work on your stuff online.


All times are GMT +2. The time now is 07:55 AM.

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