Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-22-2009, 05:28 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Question on Server... again ...

PHP Code:
function onCreated() {
  
this.setshape(13232);
}

function 
onActionSetMatchServer(match,vplayer,splayer){
if (
temp.match == "1"){
  
serverr.sdematch1 = {temp.vplayertemp.splayer};
}
if (
temp.match == "2"){
  
serverr.sdematch2 = {temp.vplayertemp.splayer};
}
if (
temp.match == "3"){
  
serverr.sdematch3 = {temp.vplayertemp.splayer};
}
if (
temp.match == "4"){
  
serverr.sdematch4 = {temp.vplayertemp.splayer};
}
if (
temp.match == "5"){
  
serverr.sdematch5 = {temp.vplayertemp.splayer};
}
if (
temp.match == "6"){
  
serverr.sdematch6 = {temp.vplayertemp.splayer};
}
if (
temp.match == "7"){
  
serverr.sdematch7 = {temp.vplayertemp.splayer};
}
if (
temp.match == "8"){
  
serverr.sdematch8 = {temp.vplayertemp.splayer};
}
if (
temp.match == "9"){
  
serverr.sdematch9 = {temp.vplayertemp.splayer};
}
if (
temp.match == "10"){
  
serverr.sdematch10 = {temp.vplayertemp.splayer};
}
}
//#CLIENTSIDE
function onCreated() {
  
this.setshape(13232);
}

function 
onPlayerChats(){
  if (!(
player.account in {"sssssssssss""Decus_Arillias"})) return;
  if (
player.chat.starts("setmatch")) {
    
temp.match player.chat.tokenize()[1];
    
temp.vplayer player.chat.tokenize()[2];
    
temp.splayer player.chat.tokenize()[3];
    
triggeraction(this.0.5this.0.5"SetMatchServer"temp.matchtemp.vplayer,temp.splayer);
  }

ok, now what I'm trying to do, obviously, is set 10 matches. There has got to be a better way to do this than have 10 different server flags isnt there?

I know I could go reading 10 in the array, and I think to pull it out i'd need a for(), but I tried. I've been out of this for 4 years. Sorry guys.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #2  
Old 08-22-2009, 06:01 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Yes, you can use a loop instead:

PHP Code:
function onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("serverr.sdematch" i) = {vplayersplayer};
  }

Please note that when defining names for parameters you do not use the temp. prefix to read their values.
Reply With Quote
  #3  
Old 08-22-2009, 06:10 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Should have known. Forgot to do the if match is i. xD
Like I said, been to long, thanks gambet.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #4  
Old 08-22-2009, 07:21 PM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
Quote:
Originally Posted by Gambet View Post
Yes, you can use a loop instead:

PHP Code:
function onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("serverr.sdematch" i) = {vplayersplayer};
  }

Please note that when defining names for parameters you do not use the temp. prefix to read their values.
Now, I've seen this in other scripts as well. Just a few questions;
1. Can you explain why the temp. is not required or that just the way it is and I better accept it?
2. Also, does it only apply to temp.variables?
3. Are there any exceptions to this rule? I've noticed that you can use pc[0....10] or whatever to access variables created with temp.pc = player.chat.tokenize();
__________________
[signature]insert here[/signature]
Reply With Quote
  #5  
Old 08-22-2009, 07:27 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by screen_name View Post
Now, I've seen this in other scripts as well. Just a few questions;
1. Can you explain why the temp. is not required or that just the way it is and I better accept it?
2. Also, does it only apply to temp.variables?
3. Are there any exceptions to this rule? I've noticed that you can use pc[0....10] or whatever to access variables created with temp.pc = player.chat.tokenize();
I meant parameter names with what I stated but it's also true with temp. vars.

If I do this:

PHP Code:
function myFunction(foobar) {

I could read the values of foo and bar by just using the words foo and bar without any prefixes (i.e player.chat = foo SPC bar; or so).

Now, with regards to temporary variables, you only need to use the temp. prefix when first defining them and then all other instances after that you don't need to. It's similar to the whole parameter naming I mentioned above where at first you just need to tell the engine that you're defining a temporary variable for the function, once you have defined it, you no longer need to use a prefix to access it.

So:

PHP Code:
function myFunction() {
  
temp.fooBar "apples";
  
player.chat fooBar;

Of course, you could still use the temp. prefix if you would like but it isn't necessary:

PHP Code:
function myFunction() {
  
temp.fooBar "apples";
  
player.chat temp.fooBar;

^Would work the same.


This doesn't work with this. vars., since this. vars can be accessed throughout the entire script whereas temp. vars are restricted to the function they are created in.
Reply With Quote
  #6  
Old 08-22-2009, 07:34 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by screen_name View Post
Now, I've seen this in other scripts as well. Just a few questions;
1. Can you explain why the temp. is not required or that just the way it is and I better accept it?
2. Also, does it only apply to temp.variables?
3. Are there any exceptions to this rule? I've noticed that you can use pc[0....10] or whatever to access variables created with temp.pc = player.chat.tokenize();
1) For for() loops, yes.

2) If you mean using a for() loop, no, but in most cases you'll want to unless you plan to loop through an array of things, find something specific, and use the data somewhere else.

3) player.chat.tokenize() separates the player's chat at every space (" ") and put it in an array (tokenize() can also separate at other points by using a string inside the ()). Using that in temp.pc just makes it so you can access that data using temp.pc (needed when defining it) or pc (any time after defining it) and can only be called inside the function it was defined in.
Array sizes start at 0 for the first param and end at the number 1 less than the last param (in normal counting). Params are accessed using [#]. As an example:
PHP Code:
function onCreated() {
  
temp.array = { 1,2,};
  if (array[
0] == 1)
    echo(
"first param at [0]");
  if (array[
1] == 2)
    echo(
"second param at [1]");
  if (array[
2] == 3)
    echo(
"third param at [2]");

__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #7  
Old 08-22-2009, 07:46 PM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
I knew how to access function parameters using said defined names. I think I took what you said the wrong way, but thanks for your clarifications. One more question though;

What should I expect this to output?
This? [foo] FOOED [temp.foo] foostring [bar] BARRED [temp.bar] barstring

|| This? [foo] foostring [temp.foo] foostring [bar] barstring [temp.bar] barstring
PHP Code:
function onFooMyBar(foo,bar) {
  
temp.foo "foostring";
  
temp.bar "barstring";
  
player.chat "[foo]" SPC foo SPC "[temp.foo]" SPC temp.foo SPC "[bar]" SPC bar SPC "[temp.bar]" SPC temp.bar;
}

function 
onCreated() {
  
onFooMyBar("FOOED","BARRED");

EDIT to Switch: I know how to access functions and use tokenize; I'm just curious as to how temp. works. I'm glad you told me it's scope is the function it's used in.

EDIT to s^11: Sorry to jack your thread
__________________
[signature]insert here[/signature]
Reply With Quote
  #8  
Old 08-22-2009, 08:30 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Switch View Post
PHP Code:
function onCreated() {
  
temp.array = { 1,2,};
  if (array[
0] == 1)
    echo(
"first param at [0]");
  if (array[
1] == 2)
    echo(
"second param at [1]");
  if (array[
2] == 3)
    echo(
"third param at [2]");

There's a way better way of doing this... by looping:

PHP Code:
temp.array = {1,2,3};
for (
temp.params : array) {
  
// blabla

Reply With Quote
  #9  
Old 08-22-2009, 09:05 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Pelikano View Post
There's a way better way of doing this... by looping:

PHP Code:
temp.array = {1,2,3};
for (
temp.params : array) {
  
// blabla

I was trying to show how arrays and params worked, not how looping works.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #10  
Old 08-22-2009, 10:37 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Switch View Post
I was trying to show how arrays and params worked, not how looping works.
I was showing how looping arrays works... oO?
Reply With Quote
  #11  
Old 08-24-2009, 06:29 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Ok. The forum I started was for this script.

PHP Code:
function onCreated() {
  
this.setshape(13232);
}

function 
onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("serverr.sdematch" i) = {vplayersplayer};
  }
}
function 
onActionWarpMatchServer() {
  
setlevel2("testtourny2.nw",30,30);
}
function 
onActionWarpMatchOutServer() {
  
setlevel2("testtourny.nw",1,1);
}

//#CLIENTSIDE
function onCreated() {
  
this.setshape(13232);
  if (
player.dies){
    if (
player.account == serverr.sdematch1[0] || player.account == serverr.sdematch1[1]){
      
triggeraction(this.0.5this.0.5"WarpMatchOutServer","");
    }
  }
}
function 
onPlayerTouchsMe()
  {
  
say2("Match1: " serverr.sdematch1[0] @ " vs. " serverr.sdematch1[1] @ "
  Match2: " 
serverr.sdematch2[0] @ " vs. " serverr.sdematch2[1] @ "
    Match3: " 
serverr.sdematch3[0] @ " vs. " serverr.sdematch3[1] @ "
      Match4: " 
serverr.sdematch4[0] @ " vs. " serverr.sdematch4[1] @ "
        Match5: " 
serverr.sdematch5[0] @ " vs. " serverr.sdematch5[1] @ "
          Match6: " 
serverr.sdematch6[0] @ " vs. " serverr.sdematch6[1] @ "
            Match7: " 
serverr.sdematch7[0] @ " vs. " serverr.sdematch7[1] @ "
              Match8: " 
serverr.sdematch8[0] @ " vs. " serverr.sdematch8[1] @ "
                Match9: " 
serverr.sdematch9[0] @ " vs. " serverr.sdematch9[1] @ "
                  Match10: " 
serverr.sdematch10[0] @ " vs. " serverr.sdematch10[1] @"");
}

function 
onPlayerChats(){
  if (
player.account in serverr.sdeaccess)
    {
    if (
player.chat.starts("setmatch")) {
      
temp.match player.chat.tokenize()[1];
      
temp.vplayer player.chat.tokenize()[2];
      
temp.splayer player.chat.tokenize()[3];
      
triggeraction(this.0.5this.0.5"SetMatchServer"temp.matchtemp.vplayer,temp.splayer);
    }
    if (
player.chat.starts("startmatches")){
      for (
temp.0temp.<= 10temp.i++) {
        if (
== 1){
          if (
!= ""){
            if (
player.account == serverr.sdematch1[0] || player.account == serverr.sdematch1[1]){
              
triggeraction(this.0.5this.0.5"WarpMatchServer","");
            }
          }
        }
      }
    }
  }

Now I'm lost, again. Im trying to set it where you can say "startmatches", and it will go through all the set matches, warping the people in for the first one, warp them out when they die, which will cause the 2nd set of matches to start, and warp them in, ect so on and so on.
Im just lost. Don't know where to go next, at all. help
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #12  
Old 08-26-2009, 07:51 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
probably not supposed to do this but all. bump
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #13  
Old 08-26-2009, 08:22 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Among other things, player.dies is not a variable I am aware of existing. There is a GS1 event called playerdies.

If you plan on using that, it should be in a timeout rather than created so it gets checked more than once.

Your serverside warping functions don't have a player to warp. I believe it is currently warping the NPC itself to another level if it's even being hit.

Take other peoples suggestions from before and create something to clean up the say2, creating a string with a loop.

"if (player.account == serverr.sdematch1[0] " is particularly confusing because you'll only ever warp that particular player in element of the array rather than all the match strings.
Reply With Quote
  #14  
Old 08-26-2009, 09:04 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
NPC Code:
function onActionSetMatchServer(match, vplayer, splayer) {
for (temp.i = 0; temp.i <= 10; temp.i++) {
if (match == i) makevar("serverr.sdematch" @ i) = {vplayer, splayer};
}
}


Why not this instead:
NPC Code:
function onActionSetMatchServer(match, vplayer, splayer) {
makevar("serverr.sdematch" @ match) = {vplayer, splayer};
}



Don't make a loop if you don't have to

This looks even sexier:

NPC Code:
function onActionSetMatchServer(i, v, s) serverr.(@"sdematch" @ i) = {v, s};



serverr. and server. are the devil though.
__________________
Do it with a DON!
Reply With Quote
  #15  
Old 08-26-2009, 01:20 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by zokemon View Post
This looks even sexier:

NPC Code:
function onActionSetMatchServer(i, v, s) serverr.(@"sdematch" @ i) = {v, s};

Get off my forum
__________________
Skyld
Reply With Quote
  #16  
Old 08-26-2009, 03:41 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by zokemon View Post
Why not this instead:
NPC Code:
function onActionSetMatchServer(match, vplayer, splayer) {
makevar("serverr.sdematch" @ match) = {vplayer, splayer};
}



Don't make a loop if you don't have to

Actually the loop idea is much better than your idea because your idea is insecure in that a player would have the potential of creating an unlimited number of serverr. vars.

If you want to go the route of not using a loop, you would have to add an extra check to prevent the above from happening, something like:

PHP Code:
if (match in |110|) 
Reply With Quote
  #17  
Old 08-26-2009, 08:05 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I stick with loop, and ya, server is annoying but thats what i was choosing to use.
What im stuck at is getting the matches to start, warp the player in, when they die, warp both out, and warp match 2 in.
I just need to know how ot approach it, dont have to give me codes or anything.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #18  
Old 08-26-2009, 08:32 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
Well the basic idea is:

Have a player queue script, when the queue is full, create the matches, warp the players in, have a loop scan the players until one of them is dead, add the winner to a list, warp the loser to OSL, the winner to spar waiting room or whatever, then continue with next match, continue till there are no matches, then re-create the matches with winners, continue the same process till the winners list is down to just one.

Of course you'll have to add some other things to make for a better player experience, to prevent AFK people and so forth.

Should probably draw a diagram/flowchart, to get a better idea of the "big picture." MS' Visio is good for that.
__________________
Quote:
Reply With Quote
  #19  
Old 08-26-2009, 10:12 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Thanks.
It probably would be easier for me to use this. scripts with all that wouldn it? And just do them serverside? I guess that would be alot on serverr flags wouldnt it?
And also, I've tried to do a triggeraction for warping players on a level npc, since actionserverside will not work on a level npc. Could I get a talk through on how or a sample on that?
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #20  
Old 08-26-2009, 10:27 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
Well I'd have a DBNPC for this called SparBot, or something.

It would hold all the data, spar locations, matches, etc. You wouldn't need to use serverr flags at all.

In a DB-NPC you could have:

DB NPC Name: SlaveBot

PHP Code:
public function onWarpPlayer(acct) {
  
findplayer(acct).setlevel2("onlinestartlocal.nw"3030);

Then in a weapon npc.

PHP Code:
function onActionServerSide() {
  switch (
params[0]) {
    case 
"kick":
      
findnpc("SlaveBot").onWarpPlayer(params[1]);
      
player.chat "Kicked" SPC params[1]; 
      break;
  }
}
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("/kick")) {
    
triggerserver("gui"name"kick"player.chat.substring("/kick ".length()));
  }

This is just an example of interacting with a DB NPC.

On the serverside you can do things in NPCs like:

PHP Code:
function onCreated() {
  
setTimer(1);
}

function 
onTimeout() {
  for (
temp.aallplayerstemp.a.chat "You are being watched by " this.name;
  
setTimer(10);

Will let everyone know they're being watched every 10 seconds Of course that's just an example.
__________________
Quote:
Reply With Quote
  #21  
Old 08-27-2009, 12:23 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I don't have access to the server this is going up on. I also cant make a wep for it.
ive done regular trigger actions to serverside script, then a setlevel2("levl.nw",x,y);
but it wouldnt seem to work at all.
also, this.commands work just fine serverside for this stuff right?
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #22  
Old 08-27-2009, 05:17 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by sssssssssss View Post
Thanks.
It probably would be easier for me to use this. scripts with all that wouldn it? And just do them serverside? I guess that would be alot on serverr flags wouldnt it?
And also, I've tried to do a triggeraction for warping players on a level npc, since actionserverside will not work on a level npc. Could I get a talk through on how or a sample on that?
I wouldn't use server vars to allow for more flexibility, to be honest.

If you're deadset on always having a 16 man tourney, that's cool, but if you use a DB NPC to manage vars, it would be easier to allow for an adjustable size spar tourney.
Reply With Quote
  #23  
Old 08-27-2009, 11:04 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
unfortunately, Im actually doing this for a guildhouse on a server, so I have no access to a DB NPC, and they wont let me. That would actually be easier on me than this for some reason. So this.flags will work fine for this too though correct?

And also, on the server warp, how do you get it to go on a level npc? I cant get it to work. :/
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #24  
Old 08-27-2009, 11:57 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by sssssssssss View Post
unfortunately, Im actually doing this for a guildhouse on a server, so I have no access to a DB NPC, and they wont let me. That would actually be easier on me than this for some reason. So this.flags will work fine for this too though correct?

And also, on the server warp, how do you get it to go on a level npc? I cant get it to work. :/
this vars on the NPC itself will work if the level is not emptied or updated.

As for setlevel2, it can be used on the serverside in any NPC as long as you have an object (typically a player) you are sending.

I believe people have already posted examples of this but if you want a function purely for warping players to a waiting room or spar room, you could write a function sending a player and another param (with the level name, an int, whatever) to warp the player.



PHP Code:
//pre: array dest contains levelname, x, y
//post: warps player pobj to dest.
function warpPlayer(pobjdest)
{
  
pobj.setlevel2(dest[0], dest[1], dest[2]);

Reply With Quote
  #25  
Old 08-28-2009, 01:14 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
ty.
btw, this.var is safe, as long as you dont get the level updated, as stated earlier. reconnecting, changing levels, it all stays. If i update level on rc, its erased. Tried on testbed. But, that works for me, because I wont be updating the level in the middle of a spar tournament.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #26  
Old 08-28-2009, 01:41 AM
TESTRETIS TESTRETIS is offline
Zvarri!
TESTRETIS's Avatar
Join Date: Oct 2003
Posts: 970
TESTRETIS has a spectacular aura about
fowl beat me to it, but I would also recommend that the case statement would be the best choice in what you are trying to do, less load on the server, and you will get the fastest response time.
Reply With Quote
  #27  
Old 08-28-2009, 02:29 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Just want to say first, I thank everyone for their help. I can do more than most, but I learn best through someone correct my mistakes, and at times showing me whats wrong. With that said:

PHP Code:
function onCreated() {
  
this.setshape(13232);
}

function 
onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("this.sdematch" i) = {vplayersplayer};
  }
}


function 
onPlayerTouchsMe()
  {
  for (
temp.1temp.<= 10temp.j++) {
    
say2("Match" @ var("this.sdematch" j) @ ": " this.sdematch1[0] @ " vs. " this.sdematch1[1] @ "
    "
);
    continue;
  }
}
function 
onPlayerChats(){
  if (
player.account in serverr.sdeaccess)
    {
    if (
player.chat.starts("setmatch")) {
      
temp.match player.chat.tokenize()[1];
      
temp.vplayer player.chat.tokenize()[2];
      
temp.splayer player.chat.tokenize()[3];
      
triggeraction(this.0.5this.0.5"SetMatchServer"temp.matchtemp.vplayer,temp.splayer);
    }
  }

I was attempting to make a loop, so when it does the playertouchsme, then does say 2, i dont have to type out every part of each var and array. I know you can do it, and I know im doing it wrong. I can only get it to say the first match.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #28  
Old 08-28-2009, 02:51 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by sssssssssss View Post
Just want to say first, I thank everyone for their help. I can do more than most, but I learn best through someone correct my mistakes, and at times showing me whats wrong. With that said:

I was attempting to make a loop, so when it does the playertouchsme, then does say 2, i dont have to type out every part of each var and array. I know you can do it, and I know im doing it wrong. I can only get it to say the first match.
rather than having it say2, you should make a var that keeps appending as you go through the loop, then say2 at the end.

also, in your script, you are only getting the say2 to display for the array sdematch1 rather than cycling through.

try replacing it with

PHP Code:
function onPlayerTouchsMe()
{
  
temp.matchlist "";
  for (
temp.1temp.<= 10temp.++)
  {
    
matchlist @= "Match " ": " this.sdematch(@i)[0] @ " vs. " this.sdematch(@i)[1] @ "#b";
  }
  
say2(matchlist);

Reply With Quote
  #29  
Old 08-28-2009, 04:46 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
odd, now it wont show anything except blank matches. before it at least showed the first one.

Just did a test with this.chat putting after the say2, its saying the this.var is there.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 08-28-2009 at 04:58 AM..
Reply With Quote
  #30  
Old 08-28-2009, 05:24 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by sssssssssss View Post
odd, now it wont show anything except blank matches. before it at least showed the first one.

Just did a test with this.chat putting after the say2, its saying the this.var is there.
that was my fault, I forgot how appending works a bit. This should fix it.

PHP Code:
function onPlayerTouchsMe()
{
  
temp.matchlist "";
  for (
temp.1temp.<= 10temp.++)
  {
    
matchlist @= "Match " ": " this.(@"sdematch" i)[0] @ " vs. " this.(@"sdematch" i)[1] @ "#b";
  }
  
say2(matchlist);

Reply With Quote
  #31  
Old 08-28-2009, 05:25 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
xD i just did that and was posting as fixed. Ty.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #32  
Old 08-28-2009, 06:41 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Skyld View Post
Get off my forum
__________________
Do it with a DON!
Reply With Quote
  #33  
Old 08-28-2009, 08:24 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Its for the same code, so I'm going to keep posting the same problems with it here.
PHP Code:
function onCreated() {
  
this.setshape(13232);
}
function 
onActionWarpPlayert() {
  
temp.dest = {"testtourny.nw"22};
  
player.setlevel2(dest[0], dest[1], dest[2]);
}
function 
onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("this.sdematch" i) = {vplayersplayer};
  }
}


function 
onPlayerTouchsMe(){
  
temp.matchlist "";
  for (
temp.1temp.<= 10temp.++)
    {
    
matchlist @= "Match " ": " this.(@"sdematch" i)[0] @ " vs. " this.(@"sdematch" i)[1] @ "#b";
  }
  
say2(matchlist);

}
function 
onPlayerChats(){
  if (
player.account in serverr.sdeaccess)
    {
    if (
player.chat.starts("setmatch")) {
      
temp.match player.chat.tokenize()[1];
      
temp.vplayer player.chat.tokenize()[2];
      
temp.splayer player.chat.tokenize()[3];
      
triggeraction(this.0.5this.0.5"SetMatchServer"temp.matchtemp.vplayer,temp.splayer);
    }
    if (
player.chat.starts("startmatches")){
      for (
temp.1temp.<= 10temp.i++) {
        
this.whatmatch = @ this.(@"sdematch" i) @;
        if (
this.whatmatch == 0){
        
this.whatmatch ++;
          
this.chat "End of Round!";

        }else{
          
temp.mplayer1 = @ this.(@"sdematch" this.whatmatch)[0] @;
          
temp.mplayer2 = @ this.(@"sdematch" this.whatmatch)[1] @;
          
this.chat this.whatmatch;
        }
      }
    }
  }

What im working on now is where it does the "startmatches". Trying to get it to work where it goes through each match, warps the players in, then when they die, warps them out, then moves to match 2, and does the same thing all the way through match 10.
An example, or even just an explanation of what code to use. Tried everything I can remember, been 4 years since I touched this stuff.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #34  
Old 08-28-2009, 05:46 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
Why are you putting @'s in the middle of no where lol.

I.e: this.whatmatch = @ this.(@"sdematch" @ i) @;
Should just be: this.whatmatch = this.(@"sdematch" @ i);

You generally use @ when you want to append things together. I.e:

PHP Code:
function onCreated() {
  
temp."ABC";
  
this.chat temp."DEF"// chat will be "ABCDEF"

and when you're using dynamic variables.

PHP Code:
function onCreated() {
  
this.lol "jk";
  
temp.var = "lol";
  
this.chat this.(@temp.var); // chat will be "jk"

But you are already using it that way.
__________________
Quote:
Reply With Quote
  #35  
Old 08-28-2009, 06:40 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
It didnt change a thing. Coding at 3am, that was my fault, I already understand how that works.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 08-29-2009 at 07:03 AM..
Reply With Quote
  #36  
Old 08-29-2009, 07:31 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Ok, so it got it to at least start one match, having a problem setting the area when the player dies. This was my last attempt. Ive already tried using the function onPlayerDies() as well, instead of the player.hp part, neither worked at all. Any obvious thing Im missing?

PHP Code:
function onCreated() {
  
this.setshape(13232);
}
function 
onActionWarpPlayer(pobj)
  {
  
temp.player1 pobj[0];
  
temp.player2 pobj[1];
  
this.playerbattle = {player1player2};
  
temp.pl1 findplayerbycommunityname(player1);
  
temp.pl2 findplayerbycommunityname(player2);
  
temp.dest = {"testtourny.nw"2020};
  
pl1.setlevel2(dest[0], dest[1], dest[2]);
  
pl2.setlevel2(dest[0], dest[1], dest[2]);
  
player.chat this.playerbattle;
}

function 
onActionWarpPlayert(){
  
temp.desta = {"testtourny.nw"3030};
  
player.setlevel2(desta[0], desta[1], desta[2]);

}

function 
onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("this.sdematch" i) = {vplayersplayer};
  }
}


function 
onPlayerTouchsMe(){
  
temp.matchlist "";
  for (
temp.1temp.<= 10temp.++)
    {
    
matchlist @= "Match " ": " this.(@"sdematch" i)[0] @ " vs. " this.(@"sdematch" i)[1] @ "#b";
  }
  
say2(matchlist);

}
function 
onPlayerChats(){
  if (
player.account in serverr.sdeaccess)
    {
    if (
player.chat.starts("setmatch")) {
      
temp.match player.chat.tokenize()[1];
      
temp.vplayer player.chat.tokenize()[2];
      
temp.splayer player.chat.tokenize()[3];
      
triggeraction(this.0.5this.0.5"SetMatchServer"temp.matchtemp.vplayer,temp.splayer);
    }
    if (
player.chat.starts("startmatches")){
      for (
temp.1temp.<= 10temp.i++) {
        
this.whatmatch = {this.(@"sdematch" i)};
        if (
this.whatmatch == 0){
          
this.whatmatch ++;
        }else{
          
triggeraction(this.0.5this.0.5"WarpPlayer"this.whatmatch);

        }
      }
    }
  }
}
//#CLIENTSIDE
function onCreated(){
  if (
player.hp <= 0){
    if (
player.account in this.playerbattle)
      {
      
triggeraction(this.0.5this.0.5"WarpPlayert""");
    }
  }

__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #37  
Old 08-29-2009, 08:08 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
I see you're using triggers to call functions on the serverside, from the serverside. You can just call them directly:

onActionSetMatchServer(temp.match, temp.vplayer, temp.splayer);

instead of

triggeraction(this.x + 0.5, this.y + 0.5, "SetMatchServer", temp.match, temp.vplayer,temp.splayer);

Generally triggeraction is used to go from client to server, and vice versa.

Personally I'd have a loop watch the players health.

I.e:

PHP Code:
function onCreated() {
  
setTimer(0.5);
}

function 
onTimeout() {
  
// Only watch if there's an actual spar.
  
if (this.sparring) {
    
onWatchSpar();
    
setTimer(0.5);
  }
}

// Variables used for sake of example.
// this.player_a = findplayer("whoever");
// this.player_b = findplayer("someoneelse");

function onWatchSpar() {
  
// Both players dead?
  
if (this.player_a.hearts <= && this.player_b.hearts <= 0onTie();
  
// Player A Alive, and B dead?
  
else if (this.player_a.hearts && this.player_b.hearts <= 0onWin(this.player_a);
  
// Player B Alive, and A dead?
  
else if (this.player_b.hearts && this.player_a.hearts <= 0onWin(this.player_b);

Personally I think this may be a bit complicated for one of your first scripts :P
__________________
Quote:
Reply With Quote
  #38  
Old 08-29-2009, 04:02 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Quote:
Originally Posted by sssssssssss View Post
having a problem setting the area when the player dies.
Your code only sets out one player, unless they both die. If you look at what I was trying to do, it's pretty obvious that I wanted to warp out both players if one dies. it doesnt matter who wins in this code, they both need to be warped out once one dies.

So, I guess i could use what you did, and put the timer, and check for sparring, and then go through and look for the hearts, but, in a spar, the only people that should be dying are the people sparring, and checking for a tie, winner 1, or winner 2, and all that is a bit redundant compared to just using a serverside function onPlayerDies() to check the level for any player that dies, then warp them both back, eh?

First code in 4 years btw, not first code.
Anywho, changed it a bit, no results. Im trying to set it where when it starts the match, it finds the players by comm name, then sets a this.array to hold it in, so that way, if the playerdies, it can check if any account in the level is in that array, then warp them out of the spar. This is what i have thus far.

PHP Code:
function onCreated() {
  
this.setshape(13232);
}

function 
onActionWarpPlayer(pobj)
  {
  
temp.player1 pobj[0];
  
temp.player2 pobj[1];
  
temp.pl1 findplayerbycommunityname(player1);
  
temp.pl2 findplayerbycommunityname(player2);
  
temp.dest = {"testtourny.nw"2020};
  
pl1.setlevel2(dest[0], dest[1], dest[2]);
  
pl2.setlevel2(dest[0], dest[1], dest[2]);
  
this.playerbattle = {pl1pl2};
  
player.chat this.playerbattle;
}

function 
onActionWarpPlayert(){
  
temp.desta = {"testtourny.nw"4040};
  
player.setlevel2(desta[0], desta[1], desta[2]);

}

function 
onActionSetMatchServer(matchvplayersplayer) {
  for (
temp.0temp.<= 10temp.i++) {
    if (
match == imakevar("this.sdematch" i) = {vplayersplayer};
  }
}


function 
onPlayerTouchsMe(){
  
temp.matchlist "";
  for (
temp.1temp.<= 10temp.++)
    {
    
matchlist @= "Match " ": " this.(@"sdematch" i)[0] @ " vs. " this.(@"sdematch" i)[1] @ "#b";
  }
  
say2(matchlist);

}
function 
onPlayerChats(){
  if (
player.account in serverr.sdeaccess)
    {
    if (
player.chat.starts("setmatch")) {
      
temp.match player.chat.tokenize()[1];
      
temp.vplayer player.chat.tokenize()[2];
      
temp.splayer player.chat.tokenize()[3];
      
triggeraction(this.0.5this.0.5"SetMatchServer"temp.matchtemp.vplayer,temp.splayer);
    }
    if (
player.chat.starts("startmatches")){
      for (
temp.1temp.<= 10temp.i++) {
        
this.whatmatch = {this.(@"sdematch" i)};
        if (
this.whatmatch == 0){
          
this.whatmatch ++;
        }else{
          
triggeraction(this.0.5this.0.5"WarpPlayer"this.whatmatch);

        }
      }
    }
  }
}
//#CLIENTSIDE
function onPlayerDies(){
  if (
player.account in this.playerbattle)
    {
    
triggeraction(this.0.5this.0.5"WarpPlayert""");
  }

__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #39  
Old 08-29-2009, 04:05 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by sssssssssss View Post
Your code only sets out one player, unless they both die. If you look at what I was trying to do, it's pretty obvious that I wanted to warp out both players if one dies. it doesnt matter who wins in this code, they both need to be warped out once one dies.

So, I guess i could use what you did, and put the timer, and check for sparring, and then go through and look for the hearts, but, in a spar, the only people that should be dying are the people sparring, and checking for a tie, winner 1, or winner 2, and all that is a bit redundant compared to just using a serverside function onPlayerDies() to check the level for any player that dies, then warp them both back, eh?

First code in 4 years btw, not first code.
He's not your butler, he's trying to help you.

"I want this, I want that!"

god
Reply With Quote
  #40  
Old 08-29-2009, 04:10 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
um, no crap?
People bomb on the way I do things, so if i do to someone else he is now my "butler"?
geeze.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
Reply


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 06:38 PM.


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