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
  #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
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 05:42 PM.


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