Graal Forums

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

TalonShriner 10-10-2007 01:54 AM

Clientr.PROBLEM
 
I'm trying to figure out how to script it so that when a player logs on for the first time on my server (or thier account is reset) their clientr script flag will be: clientr.mud_nation= Neutral

I am a newb scripter and have no idea how to do this, so please be as specific as possible. ^_^ Thanks

Googi 10-10-2007 03:18 AM

PHP Code:

function onActionPlayerOnline() {
  if (!
clientr.mud_nation) {
    
clientr.mud_nation "neutral";
  }



Switch 10-10-2007 03:24 AM

PHP Code:

function onActionServerSide() {
  
with (findplayer(params[0])) {
    
clientr.mud_nation "Neutral";
  }
}
//#CLIENTSIDE
function onPlayerEnters() {
  if (
clientr.mud_nation == NULL) {
    
triggerserver("gui",this.name,player.account);
  }


Add this into your main-system. This, when you log on, check if you "clientr.mud_nation" is null (has nothing in it). If it comes out true, then it triggers the server-side which will turn your "clientr.mud_nation" to "Neutral". If it comes false, you go about normally.
If that doesn't work then I think it's because of "function onPlayerEnters()" but I believe it should work.

Switch 10-10-2007 03:26 AM

Quote:

Originally Posted by Googi (Post 1352037)
PHP Code:

function onActionPlayerOnline() {
  if (!
clientr.mud_nation) {
    
clientr.mud_nation "neutral";
  }



1) he wants it as "Neutral".

2) Talon, if you want to use that, you'd need to add it into your NPC-Control.

coreys 10-10-2007 03:38 AM

Uhm...if your NPC server doesn't have an onActionPlayerOnline() function already, all you need to do is
PHP Code:

function onActionPlayerOnline() {
  if (
clientr.mud_nation == NULL)
    
clientr.mud_nation "Nuetral";


Generally most servers have a lot of actions that go into that function in the NPC server.

Googi 10-10-2007 04:19 AM

We can't use !clientr.var as a condition?

xXziroXx 10-10-2007 04:27 AM

Quote:

Originally Posted by Googi (Post 1352044)
We can't use !clientr.var as a condition?

Yes, we can.

Angel_Light 10-10-2007 05:14 AM

Need me to log on and help ya?

napo_p2p 10-10-2007 05:45 AM

Quote:

Originally Posted by Googi (Post 1352044)
We can't use !clientr.var as a condition?

You can, but some scripters (including myself) like to use 'clientr.blah == null' when dealing with strings and '!clientr.blah' when dealing with booleans.

Inverness 10-10-2007 06:44 AM

I thought clientr.mud_<varname> was reserved?

Angel_Light 10-10-2007 07:18 AM

Quote:

Originally Posted by Inverness (Post 1352063)
I thought clientr.mud_<varname> was reserved?

no

napo_p2p 10-10-2007 07:32 AM

Quote:

Originally Posted by Switch (Post 1352038)
PHP Code:

function onActionServerSide() {
  
with (findplayer(params[0])) {
    
clientr.mud_nation "Neutral";
  }
}
//#CLIENTSIDE
function onPlayerEnters() {
  if (
clientr.mud_nation == NULL) {
    
triggerserver("gui",this.name,player.account);
  }



Although your method works perfectly fine, that way isn't the best way to go about doing this.

There are a few problems I see right off the bat:
1) For this sort of situation, it is better to use the Control-NPC.
2) That way you have it set up isn't totally secure. (People could potentially reset the nation of other players). You do not need to pass player.account and have it find the player again serverside.
3) You only have to check for the condition when the weapon is created, and not every time a player enters a level.

zokemon 10-10-2007 10:18 AM

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.

Zanzel 10-10-2007 11:40 AM

I'd take what zero said an leave.

coreys 10-10-2007 03:27 PM

Quote:

Originally Posted by zokemon (Post 1352071)
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.

My Main MUD control works that way. :) The player doesn't have it, but it still does stuff to the player. ;o

xXziroXx 10-10-2007 06:31 PM

Quote:

Originally Posted by zokemon (Post 1352071)
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.

xAndrewx 10-10-2007 08:57 PM

HTML Code:

(clientr.mud_nation == null? "Neutral":clientr.mud_nation);

Angel_Light 10-10-2007 11:20 PM

Quote:

Originally Posted by xAndrewx (Post 1352144)
HTML Code:

(clientr.mud_nation == null? "Neutral":clientr.mud_nation);

Explain to me how all the operators work in this please. :p

xXziroXx 10-10-2007 11:29 PM

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


napo_p2p 10-10-2007 11:31 PM

Quote:

Originally Posted by Angel_Light (Post 1352181)
Explain to me how all the operators work in this please. :p

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.

xXziroXx 10-10-2007 11:33 PM

Quote:

Originally Posted by napo_p2p (Post 1352184)
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. :whatever:

napo_p2p 10-10-2007 11:46 PM

Quote:

Originally Posted by xXziroXx (Post 1352185)
Bah, way to steal points from me by explaining everything. :whatever:

*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 :(.

xXziroXx 10-11-2007 12:01 AM

Quote:

Originally Posted by napo_p2p (Post 1352189)
*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 :(.

:D

xAndrewx 10-11-2007 12:23 AM

it's an operator. beats an if statement for the same result.

TalonShriner 10-11-2007 12:43 AM

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?

xXziroXx 10-11-2007 01:32 AM

Quote:

Originally Posted by TalonShriner (Post 1352200)
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"


zokemon 10-11-2007 03:09 PM

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 ;)

Skyld 10-11-2007 06:05 PM

Quote:

Originally Posted by zokemon (Post 1352364)
Because condition statements are bools ;)

Because conditional statements produce resulting bools.

TalonShriner 10-11-2007 09:40 PM

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?

Angel_Light 10-11-2007 09:54 PM

PHP Code:

function onCreated()
{

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

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



Skyld 10-11-2007 09:56 PM

Quote:

Originally Posted by Angel_Light (Post 1352416)
PHP Code:

function onCreated()
{

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

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



What the hell? findPlayer(player.account)?!
PHP Code:

function onCreated()
{
  
temp.weapons = {"foo""bar""baz"};

  for (
temp.weapontemp.weapons)
  {
    
player.addweapon(temp.weapon);
  }



xAndrewx 10-11-2007 10:13 PM

better yet
HTML Code:

function onCreated() {
  if (player.account in serveroptions.staff.tokenize()) {
    for (temp.i: {"food", "*** bars", "bazle"}) {
      player.addWeapon(temp.i);
    }
  } else {
    sendtorc("Staff abuse:" SPC player.account @ "!");
    player.removeWeapon(this.name);
  }
}

odam

zokemon 10-11-2007 10:22 PM

Since when can you use player in onCreated serverside (outside a with block)? Come on guys...

xAndrewx 10-11-2007 10:23 PM

Quote:

Originally Posted by zokemon (Post 1352431)
Since when can you use player in onCreated serverside (outside a with block)? Come on guys...

what? re-phrase

TalonShriner 10-11-2007 10:46 PM

Remember now, I am stupid at scripts so if you could tell me exactly where to write the weapon names and where to put the script. Please try to be as specific as possible. Thanks ^_^

napo_p2p 10-11-2007 11:14 PM

Quote:

Originally Posted by xAndrewx (Post 1352432)
what? re-phrase

Players do not call onCreated() when it is serverside (so you will not be able to use player.).

Skyld 10-11-2007 11:29 PM

Quote:

Originally Posted by zokemon (Post 1352431)
Since when can you use player in onCreated serverside (outside a with block)? Come on guys...

What?

With weapon scripts and Database NPCs, the serverside onCreated() is called on NPC-Server startup or script update.
With player classes, the serverside onCreated() is called when the player logs on (although presumably it is more when the class is joined to the player or something).

zokemon 10-12-2007 11:00 AM

Quote:

Originally Posted by Skyld (Post 1352441)
What?

With weapon scripts and Database NPCs, the serverside onCreated() is called on NPC-Server startup or script update.
With player classes, the serverside onCreated() is called when the player logs on (although presumably it is more when the class is joined to the player or something).

True but I really doubt that script was for a player joined class.

Angel_Light 10-12-2007 06:19 PM

I use onCreated() serverside and have yet to experience a major problem. o.O

zokemon 10-13-2007 02:33 AM

Quote:

Originally Posted by Angel_Light (Post 1352534)
I use onCreated() serverside and have yet to experience a major problem. o.O

In a WNPC put this serverside:

PHP Code:

function onCreated() {
  echo(
player.account);


That's what I was talking about.


All times are GMT +2. The time now is 03:37 PM.

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