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 03-30-2006, 09:05 AM
wild8900 wild8900 is offline
Mr. Brightside
wild8900's Avatar
Join Date: Dec 2005
Posts: 418
wild8900 is an unknown quantity at this point
Send a message via MSN to wild8900
triggeractions and serverside question

Ive been having trouble with triggeraction and serverside. I know nothing about them. I know I need them in most online npcs though.
I was trieing to make it so on clients side when you say /kick (acc), it warps the acc to OSL, it works but only when you have the weapon equiped.
I attached the script for referance or w/e.
Attached Files
File Type: txt kick script.txt (744 Bytes, 168 views)
__________________
Reply With Quote
  #2  
Old 03-30-2006, 09:59 AM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
Im only half awake XD so it may not work

I did it in both Gscripts
Gs1 is on the top,Gs2 is below it
Attached Files
File Type: txt kick script.txt (1.8 KB, 176 views)
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #3  
Old 03-30-2006, 10:55 AM
wild8900 wild8900 is offline
Mr. Brightside
wild8900's Avatar
Join Date: Dec 2005
Posts: 418
wild8900 is an unknown quantity at this point
Send a message via MSN to wild8900
Thanks , aside from a few syntax errors (easy to solve), they worked good!
So, how do these actions work? Whats this #p(0)-4?
__________________
Reply With Quote
  #4  
Old 03-31-2006, 02:26 AM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
Quote:
Originally Posted by wild8900
Thanks , aside from a few syntax errors (easy to solve), they worked good!
So, how do these actions work? Whats this #p(0)-4?
Are you asking what its for?

Edit: I also did note, I dont script in GS1 anymore, So scripting in it for one script here and there is aquard, Sorry for any syntax errors :P

Edit2: Your right, It doesnt send to nc where the player was kicked from, Only where the kicker was at XD
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #5  
Old 03-31-2006, 06:56 AM
wild8900 wild8900 is offline
Mr. Brightside
wild8900's Avatar
Join Date: Dec 2005
Posts: 418
wild8900 is an unknown quantity at this point
Send a message via MSN to wild8900
Quote:
Your right, It doesnt send to nc where the player was kicked from, Only where the kicker was at XD
What do you mean? isnt that like, the same thing?
The message is Admin has kicked player from level
__________________
Reply With Quote
  #6  
Old 03-31-2006, 07:39 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Uhm, isn't case a lot better then doing if (params[1] == "blah") { } ?

And why not use substring? And is their any reason why .graal was used, and not .nw?


Here, I did some edits, you don't need to use "" anymore as their is no need for tokens.

If theirs a bug with it, just tell me ;O. I tested, it worked fine:

PHP Code:
function onActionServerSide(action) {
  switch (
action) {
    case 
"kick": {
      
plyr findplayer(params[2]);
      if (
plyr.level == "") return;
      if (
plyr.level == "onlinestartlocal.nw") {
        
plyr.setlevel2("jail.graal",33,31);
        
plyr.say2("You have been kicked from#b" SPC params[2SPC "#bNext time you might be jailed!");
      } else {
        
plyr.setlevel2("onlinestartlocal.nw",30.5,12.6);
        
plyr.say2("You have been kicked from#b" SPC params[2SPC "#bNext time you might be jailed!");
      }
      echo(
"NPC-Server:" SPC params[1SPC "has kicked" SPC plyr.level SPC "from" SPC params[2]@".");
      break;
    }
  }
}

//#CLIENTSIDE
function onWeaponfired(){
  if (
player.account == "wild8900"){
    
say2("Commands:#b/kick \"account\"");
  } else {
    
say2("You should not have this item.");
    
destroy();
  }
}
function 
onPlayerChats(){
  if (
player.chat.starts("/kick")) {
    
triggerserver("gui","WEAPONNAME","kick",player.account,player.chat.substring(6,-4)); 
  }

Also, if you use the above (its GS2) make sure you change WEAPONNAME to the name of the weapon.

*Edit* Alright, I added the check..and yeah, I do not know how to use GS2 return :-(. If anyone wants to post the correction way, you may do so, but I think that works fine.

Also, I took player.level off the params, and made it so you can get the level via findplayer (plyr.level). I also didn't test this version.

Last edited by KuJi; 03-31-2006 at 02:06 PM..
Reply With Quote
  #7  
Old 03-31-2006, 10:19 PM
Bl0nkt Bl0nkt is offline
Era Developer
Bl0nkt's Avatar
Join Date: Mar 2005
Location: Pennsylvania
Posts: 1,589
Bl0nkt will become famous soon enough
Send a message via AIM to Bl0nkt
Quote:
Originally Posted by wild8900
Thanks , aside from a few syntax errors (easy to solve), they worked good!
So, how do these actions work? Whats this #p(0)-4?
#p(#) (GS1) and params[#] (GS2) are for transfering information from the client -> server.

Here's a GS1 example:

NPC Code:
if (created) setshape 1, 32, 32;

if (actiontest) {
message You said #p(0)!;
}

//#CLIENTSIDE
if (playerchats) {
triggeraction x, y, test, #c;
}



Look in the triggeraction. #c is param 0, or #p(0). One thing you should know is that most things start with a value of 0. These include tokenizing, arrays, etc...

Anyway, param 0 is #c, or the player's chat. It's transfering what the player sayed in the action. So, when the action is recieved on the serverside, it's telling you param 0, or #p(0).

Triggeractions also need a surface to trigger. This can either be a non-transparent surface of an image or a setshape.

Here's an example of how this would work in GS2.

NPC Code:
function onCreated()
setshape(1, 32, 32);

function onActionTest()
message("You said" SPC params[0] @ "!");

//#CLIENTSIDE
function onPlayerChats()
triggerAction(x, y, "test", player.chat);



Not too much different.
Reply With Quote
  #8  
Old 03-30-2006, 03:56 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Hmm, that would not give an accurate representation of where the person has been kicked from. It would only say what level the person who kicked the player was in.

PHP Code:
// #p(0) - Action Type (kick)
// #p(1) - Account Name of player to kick
if(actionserverside) {
  if(
strequals(#a,wild8900)) {
    
if(strequals(#p(0),kick)) {
      
this.online 0;
      
setstring this.adminname,#a;
  
      
with(getplayer(#p(1))) {
        
this.online 1;

        
setstring this.levelname,#L;
        
setlevel2 onlinestartlocal.nw3030;
        
say2 You have been kicked by#s(this.adminname)#bFrom the level: #s(this.levelname);
      
}

      if(
this.online == 1) {
        
say2 #p(1) was successfully kicked.;
      
} else {
        
say2 #p(1) is not online.;
      
}
    }
  }
}

//#CLIENTSIDE
if(playerchats) {
  if(
startswith(/kick,#c)) {
    
triggeraction 0,0,serverside,WEAPONNAME,kick#T(#e(5,-1,#c));
  
}

You can probably combine parts of that, and the one hotrian provided. This one alerts you if the person was actually kicked or not, based on their onlinestatus.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #9  
Old 03-30-2006, 10:00 PM
wild8900 wild8900 is offline
Mr. Brightside
wild8900's Avatar
Join Date: Dec 2005
Posts: 418
wild8900 is an unknown quantity at this point
Send a message via MSN to wild8900
Ok thanks but how does the script work? I need to understand triggeractions and serverside stuff.
__________________
Reply With Quote
  #10  
Old 03-31-2006, 08:07 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
add a level check, if the player isn't online you'll get an ugly message in RC.
Reply With Quote
  #11  
Old 03-31-2006, 10:21 AM
hotrian hotrian is offline
Who?
Join Date: May 2003
Location: Eatonville, Washington, 98328
Posts: 56
hotrian is on a distinguished road
Send a message via AIM to hotrian Send a message via MSN to hotrian
Yea, I must of been really tired... I do use case lol...
__________________
Sometimes I wonder if I think too big.
Quote:
Originally Posted by Admins
I've moved the fox map to "levelstoobig/" because a terrain gmap of 1024x1024 levels is clearly too huge (the kingdoms main map is 40x40 and is already quite big). It was taking a lot of memory and was slowing down the computer.
Reply With Quote
  #12  
Old 03-31-2006, 02:15 PM
alissalee alissalee is offline
Mr. Ciprioni Atrius Admin
alissalee's Avatar
Join Date: Dec 2004
Location: Lawrence, Ma
Posts: 190
alissalee is an unknown quantity at this point
Send a message via AIM to alissalee Send a message via MSN to alissalee
this may be off topic but if u make the weapon -Staff/kick it would work still much easyer as i found out in my time scripting but wich i have stoped till i understand gs2 better
__________________
account was being used by jigga.... sorry for what he has said in the past
Reply With Quote
  #13  
Old 03-31-2006, 03:23 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
#p() or pramas[] refers to the paramater sent from the the triggeraction to the action.. in this case sending paramaters from clientside to serverside so

gs1 (which you shouldn't be using anymore)
triggeraction 0,0,serverside,Weapon,#a,test1,test2;
#a = the first paramater or #p(0)
test1 = the second paramater or #p(1)
so on and so forth

gs2
triggeraction(0,0,"serverside","Weapon",player.acc ount,"test1","test2");
player.account = the first paramter or params[0]

so on and so forth i am sure you get the idea by now and if your not triggering an action to a weapon the it just starts the first paramater after the action its calling

IE: triggeraction(x,y,"serverside",player.account);

hope that cleared it up a bit better for you
__________________

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 02:30 AM.


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