Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 05-08-2012, 03:45 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Loakey_P2P View Post
that's for clearing up why . it may not be perfect but i threw it together in less then a minute . it's a lot simpler and when you wanna teach someone to ride a bide you might not want to take off the training wheels right away.... or just throw em on a motorbike .
You didn't add anything new (it's very similar to my script) except bad script. I.e. unset, !var == 1.
__________________
Quote:
Reply With Quote
  #17  
Old 05-08-2012, 07:42 PM
Loakey_P2P Loakey_P2P is offline
SL Oldbie
Loakey_P2P's Avatar
Join Date: Apr 2006
Location: U.S.A
Posts: 137
Loakey_P2P is an unknown quantity at this point
Send a message via AIM to Loakey_P2P Send a message via Yahoo to Loakey_P2P
i would pos rep you but it wont let me
but yea it is, i just don't like using true and false . plus giving them a little exp with it having a value could come in handy later on if he needs to have multi steps to a quest . the unset was just to clean up any loose ends cause my ocd makes me . the not statement tho is just my exp that sometimes != will fail . i did kinda fudge that up as i ment it to be in an if(created or if(playerenters, so if they go back after they got the key it wont still be laying there . my bad
__________________
Shaded Legend Playerworld
-Past accounts - LoakeyTheElf - Loakey_P2P
-Past Servers - Rune - Sparitoria - Shaded Legends
-Past Sl Jobs * ET/LAT/NAT/LAT Admin/Developer/Admin/Head Admin/Asst. Manager/Manager
-Current Job - Retired

*Sorry you must have mistaken me for someone that cares .
Reply With Quote
  #18  
Old 05-08-2012, 07:45 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Quote:
Originally Posted by Loakey_P2P View Post
i would pos rep you but it wont let me
but yea it is, i just don't like using true and false . plus giving them a little exp with it having a value could come in handy later on if he needs to have multi steps to a quest . the unset was just to clean up any loose ends cause my ocd makes me . the not statement tho is just my exp that sometimes != will fail . i did kinda fudge that up as i ment it to be in an if(created or if(playerenters, so if they go back after they got the key it wont still be laying there . my bad
PHP Code:
temp.bool true;
echo(
temp.bool 5); 
Output: 6

In GS2 true == 1.

But it would be impractical to use that logic and might be confusing to fellow scripters.
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #19  
Old 05-09-2012, 12:10 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Loakey_P2P View Post
is just my exp that sometimes != will fail
No, it won't.
__________________
Reply With Quote
  #20  
Old 05-09-2012, 12:49 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by cbk1994 View Post
Once again, please put your code in PHP tags. Cleaning up a little bit and commenting some basic problems:
PHP Code:
function onActionServerSide(NULL) { // camel case; don't use NULL here, use some named argument, e.g. "cmd"
  
switch (params[0]) { // don't use params[0], use your named argument like "cmd"
    
case "givekey"// general consensus is don't use braces here, they're misleading since they don't do anything
      
if (clientr.quest1 == NULL) { // no reason to do this check
        
clientr.quest1 1;     // use true instead of 1 in this case, it's
        
clientr.items.key1 1// clearer to those trying to read your script
      
}
    break;
  }
}

//#CLIENTSIDE
function onPlayerTouchsMe() { // camel case
  
player.chat "Test";
  
this.chat "Test"// don't use GS1; in addition, don't use message, even in GS2 (set this.chat instead)
  
triggerserver("gui"this.name"givekey");

Now that the code is clean and readable, we can talk about why it's not working. I'm guessing you're putting this in a weapon script, but even if you are putting it into an NPC, it won't work.

Assuming it's in a weapon, when would onPlayerTouchsMe ever get called? A weapon isn't an object in-game; it's a background script that runs on the client. It has no physical representation, and hence nothing to touch. This will never be called.

So, the best way to do this is to move your code into an NPC. Then, when the NPC is touched, you'll notice that the player and the NPC both say "Test", but that the trigger never reaches serverside.

If you've read about triggers, you'll know why. The trigger is being sent to a weapon with the NPC's name, but that weapon doesn't exist. In addition to that, level NPC names are arbitrary and somewhat unpredictable.

Normally you'd need to trigger serverside on the NPC instead, but this is a pain. In your case, it's actually a lot simpler than that: onPlayerTouchsMe is called serverside in addition to clientside, so there's no need to communicate between them. We can simplify your code:

PHP Code:
function onPlayerTouchsMe() {
  
player.chat "I completed the quest!";
  
  
// set the player flags
  
player.clientr.quest1 true// prefixing with player. is somewhat less ambiguous
  
player.clientr.items.key1 true;

Then if we want to check if the player has completed the quest later on...

PHP Code:
if (player.clientr.quest1) {
  
player.chat "You've already completed the quest!";
} else {
  
player.chat "You haven't completed the quest yet!";

(if your onPlayerTouchsMe still isn't being called on the serverside, make sure to give it a proper shape—normally this isn't necessary if you're using an image for the NPC)
Alright thanks so much. I'm not sure if i'm doing this right, Or not.
But this isn't working. Maybe I did something wrong???

And i'll start using PHP

PHP Code:
 function onActionServerSide(cmd) {
  switch (
cmd) {
    case 
givekey:
        
clientr.quest1 true;
        
clientr.items.key1 true;
      }
    break;
}

//#CLIENTSIDE
function onPlayerTouchsMe(cmd) {
  
player.chat "Test";
  
triggerserver("gui"this.name"givekey");

This isn't working either...?
Reply With Quote
  #21  
Old 05-09-2012, 01:15 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
He just explained why the last script you posted didn't work and how to script it properly instead, and you basically just re-posted it a slightly more broken version of your earlier code.

To clarify when he says 'put in an NPC' he's talking about a level NPC in an actual level.
__________________
Quote:
Reply With Quote
  #22  
Old 05-09-2012, 01:49 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by fowlplay4 View Post
He just explained why the last script you posted didn't work and how to script it properly instead, and you basically just re-posted it a slightly more broken version of your earlier code.

To clarify when he says 'put in an NPC' he's talking about a level NPC in an actual level.
This is the fixed version. The version he helped with.

This is also an "NPC. In an actual level".
If you re-read what he posted, You'd understand.

Kthxbye
Reply With Quote
  #23  
Old 05-09-2012, 01:56 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Fysez View Post
This is the fixed version. The version he helped with.

This is also an "NPC. In an actual level".
If you re-read what he posted, You'd understand.

Kthxbye
I believe you're the one who needs to re-read what he posted, he cleaned up and commented the script to display all the faults to explain what you were doing wrong. He never fixed your particular piece of script to work for the situation.

He also then explained the right way to do it, as have a couple others posted their solutions to what you're trying to do. You seem to have ignored or misunderstood that.
__________________
Quote:
Reply With Quote
  #24  
Old 05-09-2012, 02:00 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by fowlplay4 View Post
I believe you're the one who needs to re-read what he posted, he cleaned up and commented the script to display all the faults to explain what you were doing wrong. He never fixed your particular piece of script to work for the situation.

He also then explained the right way to do it, as have a couple others posted their solutions to what you're trying to do. You seem to have ignored or misunderstood that.
Alright well if i misunderstood his comment,
Then it only had to do with how to work with IF it's SOLVED/The quest has been done.
I can't figure out how to give this player the flag.
It seems I can't find threads on it, either.
Reply With Quote
  #25  
Old 05-09-2012, 02:01 AM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
You are really overcomplicating things...
Use this server side.

PHP Code:
function onPlayerTouchsMe(){
  
clientr.quest1 true;
  
clientr.items.key1 true;

__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #26  
Old 05-09-2012, 02:08 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by BlueMelon View Post
You are really overcomplicating things...
Use this server side.

PHP Code:
function onPlayerTouchsMe(){
  
clientr.quest1 true;
  
clientr.items.key1 true;

Ohhhhh okay! I'm sorry I got confused o.o
I thought that was the code to completing this "Mission".
Sorry about that.
Thank you so much
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:53 PM.


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