Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Any ideas why it does not work. (https://forums.graalonline.com/forums/showthread.php?t=36625)

Spark910 08-25-2002 11:48 PM

Any ideas why it does not work.
 
Explain where I went wrong and why it doenst work, dont just give me a new code, also please explain your code, As I am only learning NPC Gscript,

Code In 1 NPC
NPC Code:

// NPC made by Spark911
if (created) {
x=27;
y=37;
}
if (playerenters) {
x=27;
y=37;
timeout=.05;
}
if (timeout) {
if (mousex=>27&&mousex=<28&&mousey=>37&&mousey=<38) {
setstring server.npc,One;
timeout=.05;
}
else {
setstring server.npc,;
unset string;
}
timeout=.05;
}



Code in 2nd NPC

NPC Code:


// NPC made by Spark911
if (created) {
x=31;
y=37;
}
if (playerenters) {
x=31;
y=37;
timeout=.05;
}
if (timeout) {
if (mousex=>31&&mousex=<32&&mousey=>37&&mousey=<38) {
setstring server.npc,Two;
timeout=.05;
}
else {
setstring server.npc,;
unset string;
}
timeout=.05;
}




Code in NPC that displays which NPC you are over:

NPC Code:

// NPC made by Spark911
if (playerenters) {
x=31.5;
y=58.25;
timeout=.05;
}

if (timeout) {
message #s(server.npc);
timeout=.05;
}



One works fine, Nothing happens when your mouse is over 2, If there is an Easier way for me to do the script please say so and explain what you are doing and how it works =)

mikepg 08-25-2002 11:56 PM

timeout must be 0.1 or greater serverside.

Also, it doesn't know who's mouse to read, so you may want to put the mouse clauses clientside.

Spark910 08-26-2002 12:02 AM

Ok that works fine now, But the second one still doesnt work:

NEW First:

NPC Code:

// NPC made by Spark911
if (created) {
x=27;
y=37;
}
if (playerenters) {
x=27;
y=37;
timeout=0.1;
}
//#CLIENTSIDE
if (timeout) {
if (mousex=>27&&mousex=<28&&mousey=>37&&mousey=<38) {
setstring server.npc,Ralf;
}
else {
setstring server.npc,;
unset string;
}
timeout=0.1;
}



New Second:

NPC Code:

// NPC made by Spark911
if (created) {
x=31;
y=37;
}
if (playerenters) {
x=31;
y=37;
timeout=0.1;
}
//#CLIENTSIDE
if (timeout) {
if (mousex=>31&&mousex=<32&&mousey=>37&&mousey=<38) {
setstring server.npc,Ralf;
}
else {
setstring server.npc,;
unset string;
}
timeout=0.1;
}



New Displayer:

NPC Code:

// NPC made by Spark911
if (playerenters) {
x=31.5;
y=58.25;
timeout=0.1;
}

if (timeout) {
message #s(server.npc);
timeout=0.1;
}




Still only first one works (Eventually it will be put in about 17NPC's)

Spark910 08-26-2002 12:25 AM

Clientside is now abover the playerenters part.

Python523 08-26-2002 12:30 AM

server strings can only be set serverside i believe

Spark910 08-26-2002 01:12 AM

Can you please answer my PM and reply =)

-Hadez- 08-26-2002 02:23 AM

Spark, I am your father... :)

nyghtGT 08-26-2002 02:47 AM

use triggeraction to triger the npc serverside and set the string.

emortylone 08-26-2002 08:15 AM

x.X I already told you x and y was stupid like that!
if (abs(mousex-x)=<1 && abs(mousey-y)=<1)
it is MUCh better and you can move it! x.X
---Shifter

Com013 08-28-2002 03:47 PM

Re: Any ideas why it does not work.
 
Quote:

Originally posted by Spark910
NPC Code:

if (mousex=>27&&mousex=<28&&mousey=>37&&mousey=<38) {
setstring server.npc,One;
timeout=.05;
}
else {
setstring server.npc,;
unset string;
}


NPC Code:

if (mousex=>31&&mousex=<32&&mousey=>37&&mousey=<38) {
setstring server.npc,Two;
timeout=.05;
}
else {
setstring server.npc,;
unset string;
}



I guess you tried this offline/as a non-server script, so the problem is not the client/serverside part.
But when your mouse is over the first NPC this will be executed:

1. Script: (mouse is over it)
NPC Code:

setstring server.npc,One;



2. Script: (mouse is not over it)
NPC Code:

setstring server.npc,;
unset string;



Since they are both executed after each other, the second script would remove the effect of the first one.
You could solve it by only clearing the string when the mouse just left the NPC, but not always when the mouse is not over it.
Just do "this.mouseoverme = true;" when the mouse was moved over it and when the mouse is not over the NPC, you should check this variable first: "if(mousex>... && this.mouseoverme == true) {"
Then you could clear the string...and you shouldn't forget to set the variable to false again.


All times are GMT +2. The time now is 08:26 AM.

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