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 10-10-2007, 06:31 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by zokemon View Post
You don't have to put it in the Control-NPC (You can use onPlayerLogin from any WNPC) but if you use WNPCs, just know that the player doesn't have to have the npc for the function to be called. It's very annoying when there something being done to the player when he logs in and you can't find the reason in the control-npc.
I've seen cases where onPlayerLogin and onPlayerLogout fail to trigger - especially on heavy populated servers. It's better to use onActionPlayerOnline in the Control-NPC.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #17  
Old 10-10-2007, 08:57 PM
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
HTML Code:
(clientr.mud_nation == null? "Neutral":clientr.mud_nation);
__________________
Reply With Quote
  #18  
Old 10-10-2007, 11:20 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by xAndrewx View Post
HTML Code:
(clientr.mud_nation == null? "Neutral":clientr.mud_nation);
Explain to me how all the operators work in this please.
__________________
Deep into the Darkness peering...
Reply With Quote
  #19  
Old 10-10-2007, 11:29 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
PHP Code:
clientr.mud_nation = (clientr.mud_nation == null"Neutral":clientr.mud_nation); 
Is the same like doing:

PHP Code:
if (clientr.mud_nation == nullclientr.mud_nation "Neutral";
else 
clientr.mud_nation clientr.mud_nation
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #20  
Old 10-10-2007, 11:31 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Angel_Light View Post
Explain to me how all the operators work in this please.
Consider
PHP Code:
something = (b) ? 
If the condition before the ? is true, then 'a' is assigned to 'something', otherwise 'b' is assigned.

So in this case, xAndrewx's expression is pretty much the equivalent to:
PHP Code:
if (clientr.mud_nation == null) {
  
clientr.mud_nation "Neutral";
}
else {
  
clientr.mud_nation clientr.mud_nation;

(You can see that this isn't the best situation to use a ternary operation because there is no need to set clientr.mud_nation to itself).

EDIT: Ziro beat me to it, but hopefully now you get the point :P.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #21  
Old 10-10-2007, 11:33 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by napo_p2p View Post
Consider
PHP Code:
something = (b) ? 
If the condition before the ? is true, then 'a' is assigned to 'something', otherwise 'b' is assigned.

So in this case, xAndrewx's expression is pretty much the equivalent to:
PHP Code:
if (clientr.mud_nation == null) {
  
clientr.mud_nation "Neutral";
}
else {
  
clientr.mud_nation clientr.mud_nation;

(You can see that this isn't the best situation to use a ternary operation because there is no need to set clientr.mud_nation to itself).

EDIT: Ziro beat me to it, but hopefully now you get the point :P.
Bah, way to steal points from me by explaining everything.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #22  
Old 10-10-2007, 11:46 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by xXziroXx View Post
Bah, way to steal points from me by explaining everything.
*Gives Ziro back his points*

Seriously though, when I pushed reply your post appeared. I wouldn't have replied if I knew you had already .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #23  
Old 10-11-2007, 12:01 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by napo_p2p View Post
*Gives Ziro back his points*

Seriously though, when I pushed reply your post appeared. I wouldn't have replied if I knew you had already .
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #24  
Old 10-11-2007, 12:23 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
it's an operator. beats an if statement for the same result.
__________________
Reply With Quote
  #25  
Old 10-11-2007, 12:43 AM
TalonShriner TalonShriner is offline
Levelsmith
TalonShriner's Avatar
Join Date: Feb 2006
Posts: 138
TalonShriner is on a distinguished road
Send a message via AIM to TalonShriner
I tried to put in that script that coreys suggested:
PHP Code:
function onActionPlayerOnline() {
  if (
clientr.mud_nation == NULL)
    
clientr.mud_nation "Nuetral";

But my NPC server already had the ActionPlayerOnline function and a bunch of other scripts under it. So what I did was take out the "function onActionPlayerOnline() {" part from coreys code and stuck in the rest, but I couldn't get it to work. Any suggestions?
__________________
Shall our paths cross on the road to where ever us humans are racing to, and lets walk instead.
Reply With Quote
  #26  
Old 10-11-2007, 01:32 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by TalonShriner View Post
I tried to put in that script that coreys suggested:
PHP Code:
function onActionPlayerOnline() {
  if (
clientr.mud_nation == NULL)
    
clientr.mud_nation "Nuetral";

But my NPC server already had the ActionPlayerOnline function and a bunch of other scripts under it. So what I did was take out the "function onActionPlayerOnline() {" part from coreys code and stuck in the rest, but I couldn't get it to work. Any suggestions?
Add this some where in your onActionPlayerOnline() function (prefferably at the bottom, since there's a chance you have a script in it that removes/loads your clients strings.. or.. something..):

PHP Code:
 if (clientr.mud_nation == NULLclientr.mud_nation "Neutral"
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #27  
Old 10-11-2007, 03:09 PM
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
A more simple way to put it:

foo = bool ? a : b;

If bool is true, foo would be assigned a.
If bool is false, foo would be assigned b.

You just then put a condition statement in place of the bool such as:

foo = (a < b) ? a : b;

Because condition statements are bools
__________________
Do it with a DON!
Reply With Quote
  #28  
Old 10-11-2007, 06:05 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
Because condition statements are bools
Because conditional statements produce resulting bools.
__________________
Skyld
Reply With Quote
  #29  
Old 10-11-2007, 09:40 PM
TalonShriner TalonShriner is offline
Levelsmith
TalonShriner's Avatar
Join Date: Feb 2006
Posts: 138
TalonShriner is on a distinguished road
Send a message via AIM to TalonShriner
Thanks everyone. I got it to work ^_^

Now I have a new problem, but its doesn't have to do with the clientr. flags or w/e. I'm trying to script something so that when this weapons is added to someone, it will also add a bunch of other weapons to the player. For instance, if I add the weapon "-StaffPackage" to the account "Wookieman", then it will also add the weapons "-Jump", "-Staffcontrol" and "Staff/Adder" to "Wookieman". Can anyone help me out here?
__________________
Shall our paths cross on the road to where ever us humans are racing to, and lets walk instead.
Reply With Quote
  #30  
Old 10-11-2007, 09:54 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
PHP Code:
function onCreated()
{

  
this.weapons = { "weapons1""weapons2", ...};

  for ( 
0this.weapons.size(); i++) {
    
findPlayerplayer.account).addWeaponthis.weaponsi]);
  }

__________________
Deep into the Darkness peering...
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 12:29 PM.


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