Graal Forums

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

sssssssssss 08-22-2009 04:03 AM

Help :(
 
PHP Code:

function onCreated() setshape(1,32,32);

function 
onActionServerside(p0,p1) {
  if (
p0!="midi")return;
  
serverr.midi=p1;
  for(
i:players)i.triggerClient("gui",name,"midi");
}

//#CLIENTSIDE
function onCreated() setshape(1,32,32);

function 
onPlayerchats() {
  if (!(
player.account in {"sssssssssss""Decus_Arillias"})) return;
  if (!(
player.chat.starts("playmidi"))) return;
  
t=player.chat.tokenize();
  
triggerserver("gui",midi,t[1]);

  function 
onPlayerenters()
    
playmidi(serverr.midi);

  function 
onActionClientside(p0)
    if (
p0=="midi")onPlayerenters(); 

wont send server flag whatsoever. Im misisng something really easy probably.

Frankie 08-22-2009 04:41 AM

first off, you should style your scripts. they look really sloppy. you don't even have a closing bracket for onPlayerChats()

the reason why the server flag isn't being set is because if this is a level NPC, which I'm assuming it is, triggerserver won't work. you'll need to use triggeraction. as far as triggerclient, I'm not sure if that works in a level NPC.

sssssssssss 08-22-2009 04:59 AM

PHP Code:

function onCreated() setshape(1,32,32);

function 
onActionServerside(p0,p1){
  if (
p0!="midi")return;
  
serverr.midi=p1;
  for(
i:players)i.triggerClient("gui",name,"midi");
}

//#CLIENTSIDE
function onCreated() setshape(1,32,32);

function 
onPlayerchats(){
  if (
player.account!="sssssssssss""Decus_Arillias")return;
  if (!(
player.chat.starts("playmidi"))return;
  
t=player.chat.tokenize();
  
triggeraction(this.x+1,this.y+1,"midi",t[1]);
}

function 
onPlayerenters()
  
playmidi(serverr.midi);

function 
onActionClientside(p0)
  if (
p0=="midi")onPlayerenters(); 

this doesnt work either.

xXziroXx 08-22-2009 05:24 AM

Change
PHP Code:

if (player.account!="sssssssssss""Decus_Arillias")return; 

to
PHP Code:

if (!(player.account in "sssssssssss""Decus_Arillias" })) return; 


DustyPorViva 08-22-2009 05:35 AM

Could be missing an "s".

sssssssssss 08-22-2009 05:54 AM

Still nothing, i forgot i already made that change as well.

Gambet 08-22-2009 06:22 AM

If it's a level npc and you're using triggeraction, then you catch the event on the serverside via onActionActionname(), not onActionServerSide().

In your case:

PHP Code:

triggerAction(this.x+1this.y+1"Midi"t[1]); 

Would call the following on the serverside:

PHP Code:

function onActionMidi() {
  
//Do stuff


EDIT: Also, you can't use triggerClient() in level NPCs, you would have to do another triggerAction() on the serverside (making sure you're keeping the setshape on both clientside and serverside) to trigger back to the client.

sssssssssss 08-22-2009 06:39 AM

This is what it is now.

PHP Code:

function onCreated() setshape(1,32,32);

function 
onActionMidi(p0,p1){
  if (
p0!="midi")return;
  
serverr.sdemidi=p1;
  for(
i:players)i.triggerClient("gui",name,"midi");
}

//#CLIENTSIDE
function onCreated() setshape(1,32,32);

function 
onPlayerchats(){
  if (!(
player.account in "sssssssssss""Decus_Arillias" })) return;
  if (!(
player.chat.starts("playmidi"))return;
  
t=player.chat.tokenize();
  
triggeraction(this.x+1,this.y+1,"midi",t[1]);
}

function 
onPlayerenters()
  
playmidi(serverr.sdemidi);

function 
onActionClientside(p0)
  if (
p0=="midi")onPlayerenters(); 

still no server flag.
saying "playmidi midiname.mid"

Gambet 08-22-2009 06:42 AM

Quote:

Originally Posted by sssssssssss (Post 1517429)
This is what it is now.
still no server flag.
saying "playmidi midiname.mid"

Yes, read the edit I made to my previous post about triggerClient().

sssssssssss 08-22-2009 06:51 AM

PHP Code:

function onCreated() setshape(1,32,32);

function 
onActionMidi(p0,p1){
  if (
p0!="midi")return;
  
serverr.sdemidi=p1;
  for(
i:players)i.triggeraction(this.x+1,this.y+1,"enter",midi);

}

//#CLIENTSIDE
function onCreated() setshape(1,32,32);

function 
onPlayerchats(){
  if (!(
player.account in "sssssssssss""Decus_Arillias" })) return;
  if (!(
player.chat.starts("playmidi"))return;
  
t=player.chat.tokenize();
  
triggeraction(this.x+1,this.y+1,"midi",t[1]);
}

function 
onPlayerenters()
  
playmidi(serverr.sdemidi);

function 
onActionEnter(p0,p1)
  if (
p1=="midi")onPlayerenters(); 

tried a typical triggeraction, still nothing.

Gambet 08-22-2009 07:07 AM

Quote:

Originally Posted by sssssssssss (Post 1517433)
tried a typical triggeraction, still nothing.

The way you type the actionname is case-sensitive with regards to catching the event, so if you do:

PHP Code:

triggerAction(this.x+1this.y+1"Midi"""); 

Then the way to catch the event HAS to be like this:

PHP Code:

function onActionMidi() {


If you use "midi" or any other variant, then you will have to adjust the onActionActionname() part accordingly (i.e onActionmidi() instead--case-senstive).


As for your problem, I created a quick example of how to do it:

PHP Code:

function onCreated() {
  
setshape(13232);
}

function 
onActionTriggerServer(){
  echo(
"You triggered to the serverside!");
  
triggerAction(this.x+1this.y+1"TriggerClient""");
}

//#CLIENTSIDE
function onCreated() {
  
setshape(13232);
  
triggerAction(this.x+1this.y+1"TriggerServer""");
}

function 
onActionTriggerClient() {
  
this.chat "You triggered to the clientside!";



You can pass parameters by removing the part where I used empty quotations and replacing it with the parameters.

sssssssssss 08-22-2009 07:21 AM

I fixed the case problems, still nothing.
I missed the case problems, but I understand the triggers and what they do, but as you said as well, cant use triggerserver or client in a level npc.
so, im left with

PHP Code:

function onCreated() setshape(1,32,32);

function 
onActionmidi(p0,p1){
  if (
p0!="midi")return;
  
serverr.sdemidi=p1;
  for(
i:players)i.triggeraction(this.x+1,this.y+1,"enter",midi);

}

//#CLIENTSIDE
function onCreated() setshape(1,32,32);

function 
onPlayerchats(){
  if (!(
player.account in "sssssssssss""Decus_Arillias" })) return;
  if (!(
player.chat.starts("playmidi"))return;
  
t=player.chat.tokenize();
  
triggeraction(this.x+1,this.y+1,"midi",t[1]);
}

function 
onPlayerenters()
  
playmidi(serverr.sdemidi);

function 
onActionenter(p0,p1)
  if (
p1=="midi")onPlayerenters(); 

For whatever reason still, its not getting sent to the server.

Gambet 08-22-2009 07:30 AM

Quote:

Originally Posted by sssssssssss (Post 1517438)
I fixed the case problems, still nothing.
I missed the case problems, but I understand the triggers and what they do, but as you said as well, cant use triggerserver or client in a level npc.
For whatever reason still, its not getting sent to the server.


When you use triggerAction() it doesn't work like triggerServer() where the first parameter is the action name. In the serverside your script is always going to call the return unless you said "playmidi midi" since params[0] in this case would equal whatever it is that you're sending in the triggerAction()
command (i.e tokens[1] or t[1] in your case).

Also, on the clientside part when you're doing this:

PHP Code:

function onActionenter(p0,p1)
  if (
p1=="midi")onPlayerenters(); 

You need to use brackets and you need to take into account what I said above about passing parameters using triggerAction(), so you would end up with this:

PHP Code:

function onActionenter(p0) {
  if (
p0 == "midi"onPlayerenters();


If it's important for you to do an action name check, then you'll need to pass an extra parameter with just that action name, so you would do this:

PHP Code:

triggerAction(this.x+1this.y+1"midi""midi"t[1]); 

And then you could do this:

PHP Code:

function onActionmidi(p0) {
  if (
p0 != "midi") return;


The same would apply for the triggerAction() that leads back to clientside. You need to manually pass the action name as a parameter when using triggerAction() (it is automatically passed when you use
triggerServer()).

sssssssssss 08-22-2009 08:40 AM

PHP Code:

function onCreated() setshape(1,32,32);

function 
onActionmidi(p0,p1){
  
serverr.sdemidi=p1;
  for(
i:players)i.triggeraction(this.x+1,this.y+1,"enter",midi);

}

//#CLIENTSIDE
function onCreated() setshape(1,32,32);

function 
onPlayerchats(){
  if (!(
player.account in "sssssssssss""Decus_Arillias" })) return;
  if (!(
player.chat.starts("playmidi"))return;
  
t=player.chat.tokenize();
  
triggeraction(this.x+1,this.y+1,"midi",t[1]);
}

function 
onPlayerenters()
  
playmidi(serverr.sdemidi);

function 
onActionenter() {
onPlayerenters();


sorry, ended up watching a movie last night.
still not working, if i followed you right, this is what im using now.

[email protected] 08-22-2009 09:23 AM

HTML Code:

function onCreated() {
  this.setshape(1, 32, 32);
}

function onActionPlaySoundServer(sound){
  serverr.sdemidi = temp.sound;
  for(temp.i: players) {
    temp.i.triggeraction(this.x + 0.5, this.y + 0.5, "PlaySound", "");
  }
}

//#CLIENTSIDE
function onCreated() {
  this.setshape(1, 32, 32);
}

function onPlayerChats(){
  if (!(player.account in {"sssssssssss", "Decus_Arillias"})) return;

  if (player.chat.starts("playmidi")) {
    temp.sound = player.chat.tokenize()[1];
    triggeraction(this.x + 0.5, this.y + 0.5, "PlaySoundServer", temp.sound);
  }
}

function onPlayerEnters() {
  this.onActionPlaySound();
}

function onActionPlaySound() {
  playmidi(serverr.sdemidi);
}

Should work- hopefully... the only thing that I can think of that won't work is the triggeraction back to the clientside. You may want to do a timeout every second or so.

sssssssssss 08-22-2009 04:44 PM

everything works, except like you said the trigger by clientiside. tried a timeout, didnt work. maybe im still missing it somewhere.
and by the way its

PHP Code:

playlooped(serverr.sdemidi); 


LoneAngelIbesu 08-22-2009 04:48 PM

Quote:

Originally Posted by [email protected] (Post 1517468)
Should work- hopefully... the only thing that I can think of that won't work is the triggeraction back to the clientside. You may want to do a timeout every second or so.

2. Similarly, do not just post whole scripts for people as a response to their difficulties. If you wish to post a wordy solution, then please feel free; however, please do not post things that people can just copy and paste. It isn't helping people to learn just by doing so. If you'd like to show off your scripts to others, post them in the Code Gallery subforum.

sssssssssss 08-22-2009 04:51 PM

Actually, I'm self taught by trial, error, and viewing how other people code things. Can't say that something helps no one, when everyone is different in their learning patterns. Not saying do every script for everyone, just saying. Anyways off topic.
I forgot to add that it works when I enter the level, but not when I set it. Honestly, that's good enough for me. I'm tired of dealing with this script. If anyone want to explain how I could get it to play right after I set it, that would be cool, if not, I'm happy.

Switch 08-22-2009 05:29 PM

Why are you using a serverr flag for this? You can just send the token setting the midi/streaming URL to the server. Also, it would be so much easier if you used a Gani for this.

In a weapon/level:
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (!(
player.account in {"sssssssssss","Decus_Arilias"}))
    return;
  if (!(
player.chat.tokenize()[0] == "playmidi"))
    return;
  
setAni("playmidi",player.chat.tokenize()[1]);


In a Gani named "playmidi" with preferably the idle in it or something to show that you're playing a song, go down to below all the DEF stuff and do something like this under it:
PHP Code:

SCRIPT
function onPlayerEnters()
  
play(param[0]);
SCRIPTEND 


sssssssssss 08-22-2009 05:42 PM

That would have been easier, wish I would have thought of i, got it to go server flag though. I guess its the first thing that came to mind, then, just didn't think any further on the matter. xD
all well.
Thanks for everyones help on the subject!

Gambet 08-22-2009 05:51 PM

Quote:

Originally Posted by sssssssssss (Post 1517562)
That would have been easier, wish I would have thought of i, got it to go server flag though. I guess its the first thing that came to mind, then, just didn't think any further on the matter. xD
all well.
Thanks for everyones help on the subject!


The problem with your previous script was that you were looping on the serverside through all players in the level and trying to call the triggerAction() that way back to clientside when you didn't need to do so. Simply call the triggerAction() without any loops (the same way you did on the clientside part), and then do the loop on the clientside to have the track play for all the players in the level.

It would be smarter to use a seperate function for this because you would end up doing the loop on the onPlayerEnters() event which is not necessary. Instead of making the script call onPlayerEnters() after you trigger back to the clientside from the serverside, have it call a different function that will do the loop there. You're going to have to play around with the loop, though, since you would have to change around how you're doing it on the serverside to get the play command called on everyone in the level.

Quote:

Originally Posted by Switch (Post 1517558)
In a weapon/level:
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (!(
player.account in {"sssssssssss","Decus_Arilias"}))
    return;
  if (!(
player.chat.tokenize()[0] == "playmidi"))
    return;
  
setAni("playmidi",player.chat.tokenize()[1];



Your example is a little off since it would only set the animation for the player using the command.

[email protected] 08-22-2009 06:29 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1517541)
2. Similarly, do not just post whole scripts for people as a response to their difficulties. If you wish to post a wordy solution, then please feel free; however, please do not post things that people can just copy and paste. It isn't helping people to learn just by doing so. If you'd like to show off your scripts to others, post them in the Code Gallery subforum.

I didn't- his first post is basically my post.

Switch 08-22-2009 06:59 PM

Quote:

Originally Posted by Gambet (Post 1517566)
Your example is a little off since it would only set the animation for the player using the command.

It would but it would also play for everyone in the level, unless you mean that he wants to make it play for everyone on the server. If that's the case, then something like this should work:
PHP Code:

function onActionServerside(cmd,p1) {
  if (
cmd == "playmidi") {
    for (
plallplayers)
      
findPlayer(pl).setAni("playmidi",p1);
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (!(
player.account in {"sssssssssss","Decus_Arilias"}))
    return;
  if (
player.chat.tokenize()[0] == "playmidi")
    
triggerServer("gui",this,"playmidi",player.chat.tokenize()[1]);



Pelikano 08-22-2009 08:32 PM

Quote:

Originally Posted by Switch (Post 1517592)
It would but it would also play for everyone in the level, unless you mean that he wants to make it play for everyone on the server. If that's the case, then something like this should work:
PHP Code:

function onActionServerside(cmd,p1) {
  if (
cmd == "playmidi") {
    for (
plplayers)
      
findPlayer(pl).setAni("playmidi",p1);
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (!(
player.account in {"sssssssssss","Decus_Arilias"}))
    return;
  if (
player.chat.tokenize()[0] == "playmidi")
    
triggerServer("gui",this,"playmidi",player.chat.tokenize()[1]);



If that's the case something like this should, but won't work.

It should be:

PHP Code:

for (temp.pl allplayers) { 


[email protected] 08-22-2009 08:35 PM

Hiya sam- how're ya?

Since it's a level NPC I am assuming that he only wants it to effect the people in that level.

Pelikano 08-22-2009 08:38 PM

Quote:

Originally Posted by [email protected] (Post 1517627)
Hiya sam- how're ya?

Since it's a level NPC I am assuming that he only wants it to effect the people in that level.

I'm fine D: sup

The original poster yes, but Switch not D:

Switch 08-22-2009 08:55 PM

Quote:

Originally Posted by Pelikano (Post 1517625)
If that's the case something like this should, but won't work.

It should be:

PHP Code:

for (temp.pl allplayers) { 


Correct.


All times are GMT +2. The time now is 09:20 AM.

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