PDA

View Full Version : Clientr.PROBLEM


TalonShriner
10-10-2007, 01:54 AM
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
function onActionPlayerOnline() {
if (!clientr.mud_nation) {
clientr.mud_nation = "neutral";
}
}

Switch
10-10-2007, 03:24 AM
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
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

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
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
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
I thought clientr.mud_<varname> was reserved?

no

napo_p2p
10-10-2007, 07:32 AM
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
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
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
(clientr.mud_nation == null? "Neutral":clientr.mud_nation);

Angel_Light
10-10-2007, 11:20 PM
(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
clientr.mud_nation = (clientr.mud_nation == null? "Neutral":clientr.mud_nation);

Is the same like doing:


if (clientr.mud_nation == null) clientr.mud_nation = "Neutral";
else clientr.mud_nation = clientr.mud_nation;

napo_p2p
10-10-2007, 11:31 PM
Explain to me how all the operators work in this please. :p
Consider
something = (a > b) ? a : 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:
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
Consider
something = (a > b) ? a : 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:
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
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
*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:
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
I tried to put in that script that coreys suggested:
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..):

if (clientr.mud_nation == NULL) clientr.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
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
function onCreated()
{

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

for ( i = 0; i < this.weapons.size(); i++) {
findPlayer( player.account).addWeapon( this.weapons[ i]);
}
}

Skyld
10-11-2007, 09:56 PM
function onCreated()
{

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

for ( i = 0; i < this.weapons.size(); i++) {
findPlayer( player.account).addWeapon( this.weapons[ i]);
}
}

What the hell? findPlayer(player.account)?!
function onCreated()
{
temp.weapons = {"foo", "bar", "baz"};

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

xAndrewx
10-11-2007, 10:13 PM
better yet

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
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
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
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
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
I use onCreated() serverside and have yet to experience a major problem. o.O

In a WNPC put this serverside:

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

That's what I was talking about.