Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Trouble with script (https://forums.graalonline.com/forums/showthread.php?t=61985)

excaliber7388 10-30-2005 05:02 PM

Trouble with script
 
can't get this to work, should warp player, set attributes, and gender :\
NPC Code:
// Graal2002 NPC by Excaliber
if(actionserverside){
if(strequals(#p(0),warp)){
setlevel2 begin_darkrival2.nw,31,31;
}
}
if (mousedown && leftmousebutton && mousex>x-.1 && mousex<x+2 && mousey>y-.1&&mousey<y+3){
setgender male;
sethead head.png;
setbody body.png;
enabledefmovement;
setlevel2 begin_darkrival2.nw,31,31;
hideplayer .05;
}
//#CLIENTSIDE
if (mousedown && leftmousebutton && mousex>x-.1 && mousex<x+2 && mousey>y-.1&&mousey<y+3){
setgender male;
sethead head.png;
setbody body.png;
enabledefmovement;
hideplayer .05;
triggeraction playerx,playery,serverside,warp;
}
if (created) {
showcharacter;
setcharprop #3,head0.png;
setcharprop #C0,orange;
setcharprop #C1,white;
setcharprop #C2,blue;
setcharprop #C3,red;
setcharprop #C4,black;
setcharprop #n,Male;
setcharprop #2,shield1.gif;
shieldpower = 1;
dir = 2;
}


Yen 10-30-2005 05:12 PM

Use 'actionleftmouse' in the serverside. This is called when the player left clicks the NPC.
The only part you need in the clientside is the showcharacter stuff.

Skyld 10-30-2005 05:22 PM

Also, please stop mixing conditional checks and events in single if () statements.

excaliber7388 10-30-2005 05:36 PM

so this is all i need?
NPC Code:
if (actionleftmouse && mousex>x-.1 && mousex<x+2 && mousey>y-.1&&mousey<y+3){
setgender male;
sethead head.png;
setbody body.png;
enabledefmovement;
hideplayer .05;
setlevel2 begin_darkrival2.nw,31,31;

}


because that didn't work X_X

Yen 10-30-2005 05:37 PM

actionleftmouse is called when you click on the NPC.

excaliber7388 10-30-2005 05:41 PM

still doesn't work

Yen 10-30-2005 05:45 PM

I'm a good little Yenny-poo, yes I am..
Nothing to see here, just move along..

excaliber7388 10-30-2005 05:54 PM

thats exactly what i had....not that you showed anything ;)

ZeLpH_MyStiK 10-30-2005 06:13 PM

stop using leftmousebutton with mousedown...mousedown carries a #p(0) along with it to show which mouse is being pressed.

excaliber7388 10-30-2005 06:16 PM

oh thanks.
however, this did not help

Skyld 10-30-2005 06:39 PM

Then stop depending so much on people to do the work for you, and do some thinking of your own too.

excaliber7388 10-30-2005 06:56 PM

Quote:

Originally Posted by Skyld
Then stop depending so much on people to do the work for you, and do some thinking of your own too.

i made the script in the first place, and it works perfectly offline, however online it does not work

Skyld 10-30-2005 07:00 PM

Quote:

Originally Posted by excaliber7388
i made the script in the first place, and it works perfectly offline, however online it does not work

That is no reason not do some thinking of your own...?

excaliber7388 10-30-2005 07:04 PM

i don't know whats wrong, from everything i know, this script should work...i'm guessing you know why it doesn't? :\

ZeLpH_MyStiK 10-30-2005 08:48 PM

Quote:

Originally Posted by excaliber7388
i don't know whats wrong, from everything i know, this script should work...i'm guessing you know why it doesn't? :\

yes...you're using it wrong

Lance 10-30-2005 10:01 PM

Quote:

Originally Posted by Yen
actionleftmouse is called when you click on the NPC.

Except his script is apparently a weapon. Don't give bad advice.

Lance 10-30-2005 10:03 PM

Quote:

Originally Posted by excaliber7388
can't get this to work, should warp player, set attributes, and gender :\

You've had approximately the same problem with your approach in several threads already. We've explained in great detail what the problems with your approach are. We've enumerated what is clientside and what is serverside. We've explained how to translate between the two. There is a second part to rule 1, you know.

I'll try this:
The following information is available in newfeatures2002.txt:

Quote:

- mouse variables:
mousex, mousey - position of the mouse in the level
mousebuttons - tells you which mouse buttons are pressed,
it's a sum of the values 1 for left mouse button, 2 for middle
mouse button and 4 for the right mouse button, so it's 1+2+4=7
when all buttons are pressed; you can also use the flags described
later to easier check for the mouse buttons
mousescreenx, mousescreeny - position of the mouse in the game screen
mousewheeldelta - the movement of the mouse wheel in the last 0.05 seconds
- flags for checking if a mouse button is pressed:
leftmousebutton - is set when the left mouse button is down
middlemousebutton - is set when the middle mouse button is down
rightmousebutton - is set when the right mouse button is down
- events:
mousedown - occurs when a mouse button has been pressed, so
you can do things like if (mousedown && leftmousebutton) message hi;
mouseup - occurs when a mouse button has been released
mousewheel - occurs when the mouse wheel has been used
- triggered actions (only on npcs where the player has clicked on,
is also sent to the npcserver):
actionleftmouse - the player has clicked on the npc
actionmiddlemouse - the player has clicked with the middle mouse button on the npc
actionrightmouse - the player has right-clicked on the npc
actiondoublemouse - the player has double-clicked on the npc
The following is the correct format of weapon triggeractions:
NPC Code:
triggeraction 0,0,serverside,weaponname,params;



What do you suppose the problem(s) with your approach could be? I'll make this easier by bolding the parts you ought to look at:

NPC Code:
// Graal2002 NPC by Excaliber
if(actionserverside){
...
}
if (mousedown && ...){
...
}

//#CLIENTSIDE
if (mousedown && ...){
...
triggeraction playerx,playery,serverside,warp;
}
if (created) {
...
}



What do you suppose is wrong with that?

Other than that, I do have a suggestion: you should definitely consider placing a lot of those conditional checks within the event block you have associated them with. It might help you understand what's going on with your script better.

Yen 10-30-2005 11:25 PM

Since when do weapons use showcharacter?

Lance 10-30-2005 11:30 PM

Quote:

Originally Posted by Yen
Since when do weapons use showcharacter?

Perhaps since the time showcharacter NPCs use reserved triggeractions for weapons? Your advice was bad becuase you didn't elaborate.

excaliber7388 10-30-2005 11:56 PM

this is not a weapon this is the current script, it does not warp the player

NPC Code:
if (actionservside){
if(strequals(#p(0),warp)){
setlevel2 begin_darkrival2.nw,31,31;
}
}
//#CLIENTSIDE
if(actionleftmouse){
setgender male;
sethead head.png;
setbody body.png;
enabledefmovement;
hideplayer.05;
triggeraction playerx,playery,serverside,warp;
}


ZeLpH_MyStiK 10-31-2005 12:40 AM

-.- do you read?
1. you're triggering at the player not the npc
2. you spelled serverside wrong

excaliber7388 10-31-2005 12:47 AM

still doesn't work:

NPC Code:
if (actionserverside){
if(strequals(#p(0),warp)){
setlevel2 begin_darkrival2.nw,31,31;
}
}
//#CLIENTSIDE
if(actionleftmouse){
setgender male;
sethead head.png;
setbody body.png;
enabledefmovement;
hideplayer.05;
triggeraction x,y,serverside,warp;
}


Skyld 10-31-2005 01:06 AM

Give the NPC a shape (setshape).

excaliber7388 10-31-2005 02:29 AM

it registers the fact that i clicked on the NPC, it changes the player's attributes, however, it does not warp the player

Lance 10-31-2005 03:18 AM

Quote:

Originally Posted by excaliber7388
this is not a weapon this is the current script, it does not warp the player

Then, as I said, you should not use special reserved triggeractions. Actions taking the name "server*" are received by the Control-NPC (except for actions taking the name "serverside", which are received by the weapon you specify as the next parameter).

If you insist on keeping a triggeraction, name the action something else. Perhaps 'warp' would do; then you would check it with if (actionwarp). Also, as Skyld said, you would need a serverside setshape for it to receive the action.

excaliber7388 10-31-2005 04:52 AM

thanks you guys this really helped :)


All times are GMT +2. The time now is 04:59 PM.

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