Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   open and closable level (https://forums.graalonline.com/forums/showthread.php?t=134263838)

Gunderak 07-12-2011 08:35 AM

open and closable level
 
hey, i know most of you got annoyed because i was asking for scripts that were wayyy above my scripting level, so iv decided to stick to easier things for now, basicly what iv tried to make is a door that if u write /open and your account is allowed to it will alloe you to enter the level when you touch it but if the account writes /close it closes it and you cant enter the level..
here is what i have so far..
the account and /open and /close work
but i cant get the if playertouchsme bit to work..
as for the player.chat once i get it working il change that to setlevel2("level.nw",30,30);

PHP Code:

function onPlayerChats(){
  if (
player.account == "Graal780374"){
    if (
player.chat == "/open"){
      
this.chat = "Secret Room Is Open!";
      if (
playertouchsme){
        
player.chat = "open";
      }
    }
    if (
player.chat == "/close"){
      
this.chat = "Secret Room Is Closed!";
    }
    if (
playertouchsme){
      
player.chat = "closed";
    }
  }
} 

Any Help Your Willing TO Give Is Much Appreciated
Thanks
-Gunderak

PowerProNL 07-12-2011 09:04 AM

Quote:

if (player.chat == "/open"){
this.chat = "Secret Room Is Open!";
}
if (playertouchsme){
player.chat = "open";
}
^^

Gunderak 07-12-2011 09:25 AM

im new to scripting, please dont mock me :(

fowlplay4 07-12-2011 03:10 PM

if (playertouchsme) { } is GS1. Don't mix the two up. You have to use:

function onPlayerTouchsMe() { }

You've also made it impossible to occur by placing playertouchsme in your onPlayerChats function/event.

PPNL: You have no idea what you're doing either.

callimuc 07-12-2011 03:33 PM

Quote:

Originally Posted by Gunderak (Post 1658464)
PHP Code:

function onPlayerChats(){
  if (
player.account == "Graal780374"){
    if (
player.chat == "/open"){
      
this.chat = "Secret Room Is Open!";
      if (
playertouchsme){
        
player.chat = "open";
      }
    }
    if (
player.chat == "/close"){
      
this.chat = "Secret Room Is Closed!";
    }
    if (
playertouchsme){
      
player.chat = "closed";
    }
  }
} 


I´d prefer to make it clientside. and if you want the player to say that its open as far as you open it I´d do something like:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.opencheck = false;
}
function 
onPlayerTouchsMe() {
  if (
this.opencheck = false) {
    
this.opencheck = true;
  }
  else 
this.opencheck = false;
  
player.chat = this.opencheck;
} 

That´s just an example and yes ik there is something like this.opencheck = !this.opencheck but I just wanted to tell him this way since I don´t know if he understands now how to do the if conditions and with else :asleep:

cbk1994 07-12-2011 04:01 PM

You'll want to do it serverside, not clientside. Otherwise, the door would only be open for you, and you'd have to trigger serverside to warp the player into the level (and serverside would have no way to verify that the door was legitimately opened).

callimuc 07-12-2011 07:02 PM

I think this should be good enough for him since he wanted to start slowly :) and probably he´d have placed a normal warp behind the door...

oo_jazz_oo 07-13-2011 01:19 AM

Instead of attempting to shove scripts together then posting on the forums asking why they don't work, why not take the time to learn the basics of the language?

Learning simple structure and syntax is the first thing to learning a new language...

You wouldn't try to learn German by shoving random sentences together and hope they produce what you want...

There are a lot of resources available, if you would actually look.
GS2 Wiki
Old Wiki (But has some things the new one doesn't)

Look through the code gallery at other people's scripts to get a good idea of what GS2 is, then try writing some basic code. (Note: I did not say copy/paste the codes, that would be pointless. Read through them and try to understand what they are doing)

Gunderak 07-13-2011 10:23 AM

YAY finally got it working..
thanks all who helped =D
one quick question, how would i make the room dark?
like as if u were in a cave...
Thanks
-Gunderak

callimuc 07-13-2011 04:08 PM

Quote:

Originally Posted by Gunderak (Post 1658604)
one quick question, how would i make the room dark?

I don´t think you really take a look at the guides. (personally) I think you are just out for commands/codes but you don´t really try to take a look at them at your own and if you don´t get it to ask than.
In case you are just out for commands:
GS2 commands

In case you need complete codes:
Code Gallery

cbk1994 07-13-2011 06:21 PM

Quote:

Originally Posted by Gunderak (Post 1658604)
how would i make the room dark?

setEffect is the command you're looking for. You'll find more information on it if you search for it on the wiki.


All times are GMT +2. The time now is 11:19 PM.

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