Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Server (https://forums.graalonline.com/forums/forumdisplay.php?f=14)
-   -   putnpc2 (https://forums.graalonline.com/forums/showthread.php?t=38457)

R0b1n-NPC 09-24-2002 02:28 AM

putnpc2
 
Ive been having real trouble trying to put variables from an npc that uses the putnpc2 command into the npc that got put on the level using putnpc2..

Can anyone tell me why?

I tried level.vars i tried this.vars and i tried normal vars :\ but not one works! :grrr:

R0b1n-NPC 09-24-2002 02:45 AM

well im doing this basically:

NPC Code:

if (actionserverside) {
putnpc2 playerx+3,playery,{
setstring num,#p(0);
setgif door.png;
message #s(num);
}
}



I dont think that is right, but i dont know how x.x

::EDIT

Someone suggested doing:

NPC Code:

with (getnpc(npcscount-1)) {
setstring num,#p(0);
}


R0b1n-NPC 09-24-2002 03:39 AM

it seems so inefficient.. i doubt thats how they did it with the 2k2 item trading..

R0b1n-NPC 09-24-2002 04:06 AM

well no, you should be able to use #p params from the serverside in putnpc2...

or like

putnpc3 x,y,param0,param1,etc,{
showcharacter;
message #p(0);
}

Graal2001_NAT 09-24-2002 04:30 AM

level strings don't exist last time i checked =/

R0b1n-NPC 09-24-2002 07:26 AM

level.vars

emortylone 09-25-2002 11:03 PM

Jagen when's the last time you checked? Level.strings are part of the NPC Server x.X Like this.string for D/B NPC's, level.strings are for that level only. Means don't update the level :P Using this.strings in the Control-NPC or equivalent may be just as good though if not better.
---Shifter

Graal2001_NAT 09-26-2002 02:35 AM

actually I just tested it, had one npc
setstring level.test,asdf;
had another npc
sendtorc hello #s(level.test);
(i had it do a sleep first to give it time just in case it would lag before setting the string) and the RC result was
'hello'
when is the last time you tested it?

Falcor 09-26-2002 04:54 AM

Quote:

Originally posted by Graal2001_NAT

(i had it do a sleep first to give it time just in case it would lag before setting the string)

It doesn't lag on the server, more or less, it would lag because it needs time to get to the client. To the server its just another day in the park.

Graal2001_NAT 09-26-2002 05:08 AM

Quote:

Originally posted by Falcor

It doesn't lag on the server, more or less, it would lag because it needs time to get to the client. To the server its just another day in the park.

I know, but just in case it took any time at all to set the string before the next npc loaded, I was doing that because I didn't want someone to say 'well the string must not have set before that npc loaded' after I said level.strings dont work/exist

R0b1n-NPC 09-26-2002 08:54 AM

:megaeek:

Bah someone lied to me again.. and if i find out who it was....


I will r0x0rz their s0x0rz.

BinaryCrash 09-26-2002 11:09 PM

that putnpc3 exists?
can someone pm me about it please?
i'd like to learn it.

R0b1n-NPC 09-27-2002 12:24 AM

putnpc3 doenst exist.

putnpc image,textfile,x,y;

putnpc2 x,y,{Script};

emortylone 09-27-2002 11:15 PM

I was curious as to where {Script} comes from. I take it basically putting out something from the Weapons List, I never played with it, more important things to do, lolz.
---Shifter

R0b1n-NPC 09-28-2002 07:46 AM

You type it in *******
NPC Code:

NPC Code:

if (weaponfired) {
putnpc2 playerx+5,playery,{setimg bush.png; message R0bin owns you;};
}




Loriel 09-28-2002 04:36 PM

Quote:

Originally posted by R0b1n-NPC
You type it in *******
NPC Code:

if (weaponfired) {
putnpc2 playerx+5,playery,{setimg bush.png; message R0bin owns you;};
}


Yes, you type it in, but you do not type it in clientside -.-
Also, you do not use script commands outside of if clauses with events.

NPC Code:

if (actionserverside)
tokenize #v(playerdir);
putnpc2 playerx+vecx(playerdir)*2,playery+vecy(playerdir)* 2,{
if (created) {
showcharacter;
dir = (strtofloat(#t(0))+2)%4;
setcharani sword,;
sleep 1;
destroy;
}
};
}
//#CLIENTSIDE
if (weaponfired)
triggeraction 0,0,serverside,Stupidy;


R0b1n-NPC 09-29-2002 03:40 AM

according to your script.. you can tokenize something in the serverside script.. then use a token in the putnpc2 script.. if thats tru then i bloody wub you :P

Loriel 09-29-2002 03:53 AM

You can :)
But the better way probably is to do...

NPC Code:
putnpc2 x,y,{
if (created) message #s(this.text);
};
with (npcs[npcscount-1]) setstring this.text,Hi :O;


R0b1n-NPC 09-29-2002 04:02 AM

ok, i bloody wub you :D

the problem with that is when you do that, the npc your aiming for might not be the last npc put.. the npc server does lag a tiny bit ;)

Loriel 09-29-2002 04:28 AM

It only lags between serverside and clientside. It does not lag at all here.

R0b1n-NPC 09-29-2002 04:30 AM

i dunno, i would feel safer using the tokens

Graal2001_Developer1 09-29-2002 04:33 AM

You can also use callnpc for this

NPC Code:

if (actionserverside) {
putnpc2,playerx,playery, {
if (created) {
showcharacter;
setcharani sword,;
sleep 1;
destroy;
}
if (thedir) dir = (strtofloat(#p(0))+2)%4;
};
callnpc npcscount-1,thedir,#v(playerdir);
}
//#CLIENTSIDE
if (weaponfired) triggeraction 0,0,Sillyweapon,serverside;



would work the same way and doesn't lagg too ^^

Com013 10-03-2002 11:00 AM

Quote:

Originally posted by R0b1n-NPC
i dunno, i would feel safer using the tokens
I wouldn't. The if (created) will just be called in the next frame, so imagine what would happen if some other script did tokenize.

R0b1n-NPC 10-03-2002 07:59 PM

If two npcs were dropped using putnpc2 at EXACTLY the same time, npcscount-1 might not be the one you are aiming for.


^^^ is possible.. kinda

R0b1n-NPC 10-03-2002 08:28 PM

What is the case then?

R0b1n-NPC 10-04-2002 01:25 AM

Ah ok.

Com013 10-04-2002 04:40 AM

Quote:

Originally posted by R0b1n-NPC
If two npcs were dropped using putnpc2 at EXACTLY the same time, npcscount-1 might not be the one you are aiming for.


^^^ is possible.. kinda

It is not possible, but let's assume it would be. You would use tokenize.
How would that help? Tokenize overwrites the last tokenize, so you'd have the same problem.
Even worse, because the result of tokenize would be read in the if (created) event, and this event will be processed one frame later, so it is even more possible that some other call to tokenize happend.

R0b1n-NPC 10-04-2002 04:50 AM

You confuse me greatly :|

Torankusu 10-04-2002 10:36 AM

Quote:

Originally posted by R0b1n-NPC
You confuse me greatly :|
Okay.
You tokenize something.
You have #t(0) and #t(1).
You tokenize something else, they overwrite that.

Correct me if I'm wrong someone. I didn't really pay attention to this thread that much.

R0b1n-NPC 10-05-2002 07:35 PM

yea... but you can save the tokens to a string, that way they'd be saved :-D


All times are GMT +2. The time now is 12:53 PM.

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