Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gman's questions thread (https://forums.graalonline.com/forums/showthread.php?t=50856)

Gman4pwnu 02-02-2004 04:35 PM

A pretty simple script not working online
 
Im an ET on server Dynasty, and I don't understand why this script won't work. Its supposed to warp the player on top of the winners platform if they touch the npc with a bush. It works offline, when its uploaded, no work.

if (playertouchsme && carriesbush){
with (getplayer(#a)){
setcharprop #c,#a;
hide;
setlevel2 bushrace2.nw,33.5,30.5;
}
}


if (playerchats && strequals(#c,/reset)){
if (strequals(#g,Events Admin) || strequals(#g,Events Team)){
show;
}
}
//#CLIENTSIDE
if (created) {
// Initialize the attributes
showcharacter;
setcharprop #3,head7.png;
setcharprop #C0,orange;
setcharprop #C1,darkblue;
setcharprop #C2,brown;
setcharprop #C3,black;
setcharprop #C4,brown;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
setcharprop #c, Touch me to win!;
}

WanDaMan 02-02-2004 08:00 PM

Well it's quite hard to tell who one when some 1 could touch it straight after some 1 else as and it would appear to have him as the winner...
I think the problem is
if (playertouchsme && carriesbush){
add a timeout and try it :o?
Or make it so if you pelt it it executes it ;)?

Gman4pwnu 02-02-2004 10:18 PM

where to put the timeout and how long is the timeout, and why will this make it work?

WanDaMan 02-02-2004 10:20 PM

It's worth a try, your telling me you don't know timeout's but you know quite complex commands such as with(getplayer(account))?

Gman4pwnu 02-02-2004 10:27 PM

:) Where should I put the timeout is what im asking and how long should I make it for.

DIABLO2099 02-02-2004 10:27 PM

I am guessing this is with an NPC-Server. The NPC may not know that the player is touching it, use setshape. I don't think with(getplayer()) is actually necessary in this case.

Gman4pwnu 02-02-2004 10:30 PM

That would help :)

Gman4pwnu 02-02-2004 10:36 PM

How do I get the size of it?

GoZelda 02-02-2004 10:51 PM

It's 2 tiles wide and 2 high. Use

setshape 1,width,height;

Where width is the width of tiles * 16, and the height is the height of tiles * 16.

Gman4pwnu 02-02-2004 10:58 PM

should i place this under if created and should it be client or serverside

GoZelda 02-02-2004 11:00 PM

1 Attachment(s)
NPC Code:

if (created){
//Set width of NPC
setshape 1(not sure 'bout 1),32,32;
}


If the setshape isn't used, it isn't an 'object', but just decoration, kinda. Read the attached text trough... it will increase your knowledge.

Gman4pwnu 02-02-2004 11:00 PM

if (created){
setshape 1,48,48;
}
if (playertouchsme && carriesbush){
with (getplayer(#a)){
setcharprop #c,#a;
hide;
setlevel2 bushrace2.nw,33.5,30.5;
}
}


if (playerchats && strequals(#c,/reset)){
if (strequals(#g,Events Admin) || strequals(#g,Events Team)){
show;
}
}
//#CLIENTSIDE
if (created) {
// Initialize the attributes
showcharacter;
setshape 1,48,48;
setcharprop #3,head7.png;
setcharprop #C0,orange;
setcharprop #C1,darkblue;
setcharprop #C2,brown;
setcharprop #C3,black;
setcharprop #C4,brown;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
setcharprop #c, Touch me to win!;
}

Thats the new script, doesn't work :(

Gman4pwnu 02-02-2004 11:03 PM

Btw im testing this in online mode

DarkShadows_Legend 02-02-2004 11:18 PM

NPC Code:

if (created) {
showcharacter;
setshape 1,48,48;
setcharprop #3,head7.png;
setcharprop #C0,orange;
setcharprop #C1,darkblue;
setcharprop #C2,brown;
setcharprop #C3,black;
setcharprop #C4,brown;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
setcharprop #c, Touch me to win!;
}

if (playertouchsme && carriesbush){
setcharprop #c,#a;
hide;
setlevel2 bushrace2.nw,33.5,30.5;
}

if (playerchats && strequals(#c,/reset)){
if (strequals(#g,Events Admin) || strequals(#g,Events Team)){
show;
}
}


I rearranged stuff in your script. I'm not really sure if this works since I haven't tested it.

Gman4pwnu 02-03-2004 12:33 AM

Still doesn't work, Stefan, where are you!?!?!?!

Nappa 02-03-2004 12:51 AM

You might want to read up about how to use serverside stuff and clientside.

setlevel2 and with are serverside commands and such. Use a //#CLIENTSIDE tag to seperate clientside and serverside. You're also making a mountain out of a speedbump problem.

-Ramirez- 02-03-2004 12:52 AM

The problem is "carriesbush". Stefan loves to make everyone rescript everything nowadays. The NPC Server apparently doesn't have detection for whether or not a player is carrying a bush.

Solution: Do the playertouchsme detection clientside (where carriesbush still works) and trigger serverside. If you wanted it more secure, check the coordinates of the player sending the trigger to make sure they're within a close enough distance to truly be touching the NPC.

Gman4pwnu 02-03-2004 01:06 AM

can you triggeraction from clientside to serverside? like triggeraction from if player touchs me to test if they have a bush and then triggeraction back to serverside for warp.

-Ramirez- 02-03-2004 01:08 AM

Quote:

Originally posted by Gman4pwnu
can you triggeraction from clientside to serverside?
Of course. It's the reverse that isn't possible in non-NPCWs, which is completely retarded in the first place.

That's what I was suggesting you do. Check if (playertouchsme && carriesbush) clientside... then trigger serverside telling the script that it's been touched while carrying a bush. Do some coordinate checking on the serverside trigger... then you can do your warping stuff.

Gman4pwnu 02-03-2004 01:18 AM

Ah ok, I just did the reverse of what you said lol.. I tried to check if player is touched and then go to client then go back hehe.

Ill try your way :)

Im a bit confused on x,y ???? what if i dont want to check if it happens at an x, y ?

wow the first time i saw trigger action (bout 8 months ago) i figured ill never touch this thing too confusing, seems a bit easier now that its been explained what it does.

DIABLO2099 02-03-2004 01:23 AM

That's the position at where the action occurs, use x,y or 0,0.

-Ramirez- 02-03-2004 01:25 AM

Quote:

Originally posted by Gman4pwnu
Im a bit confused on x,y ???? what if i dont want to check if it happens at an x, y ?
x and y are the coordinates where you're going to be sending the trigger. Think of it as a gunshot on those coordinates. Any NPC on those coordinates will receive the trigger. In this case, you want to trigger the same NPC, so use x + 0.5,y + 0.5. Triggering directly on x,y doesn't seem to work all of the time for some reason.

Gman4pwnu 02-03-2004 01:28 AM

Doesn't seem to detect the trigger action =\

if (actionplayerwins){
setcharprop #c, Detected triggeraction!;
sleep 1;
with (getplayer(#a)){
setcharprop #c,#a;
hide;
setlevel2 bushrace2.nw,33.5,30.5;
setcharprop #c, Complete!;
}
}

if (playerchats && strequals(#c,/reset)){
if (strequals(#g,Events Admin) || strequals(#g,Events Team)){
show;
}
}
//#CLIENTSIDE

if (playertouchsme){
setcharprop #c, Detected Touch!;
sleep 1;
if (carriesbush){
setcharprop #c, Detected Bush!;
sleep 1;
triggeraction x+.5,y+.5,playerwins,;
}
}

if (created){
showcharacter;
//setshape 1,48,48;
setcharprop #3,head7.png;
setcharprop #C0,orange;
setcharprop #C1,darkblue;
setcharprop #C2,brown;
setcharprop #C3,black;
setcharprop #C4,brown;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
setcharprop #c, Touch me to win!;
}

-Ramirez- 02-03-2004 01:30 AM

You need to have a setshape serverside. Without it, the server doesn't know how big the NPC is... therefore it can't receive a trigger.

Btw, the with () isn't necessary. The script will already be "attached" to that player... so things can be directly edited. Besides... you're attempting to set NPC properties inside the player's with () block.

Gman4pwnu 02-03-2004 01:34 AM

Thank you all of you for your help.

Here is the complete and working script for those who want it.

Thanks especially to ramirez.

NPC Code:

if (created){
setshape 1,48,48;
}
if (actionplayerwins){
with (getplayer(#a)){
setcharprop #c,#a;
hide;
setlevel2 bushrace2.nw,33.5,30.5;
setcharprop #c, Complete!;
}
}

if (playerchats && strequals(#c,/reset)){
if (strequals(#g,Events Admin) || strequals(#g,Events Team)){
show;
}
}
//#CLIENTSIDE

if (playertouchsme){
if (carriesbush){
triggeraction x+.5,y+.5,playerwins,;
}
}

if (created){
showcharacter;
setshape 1,48,48;
setcharprop #3,head7.png;
setcharprop #C0,orange;
setcharprop #C1,darkblue;
setcharprop #C2,brown;
setcharprop #C3,black;
setcharprop #C4,brown;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
setcharprop #c, Touch me to win!;
}


Admins 02-03-2004 03:59 AM

AAAAARRRGGG

I need to check this forum more often i guess x-x

1. PLEASE move the if (created) stuff to the serverside, how should the player be able to touch the npc if the npcserver doesn't event know that the npc is visible? since you only display stuff on the clientside; move it and you don't need weird stuff like setshape or whatever

2. with (getplayer(#a)) is completely nonsense, please kill the one who teached you such stuff

3. the stuff about the carriesbush is right - its from the old classic clientside-only mode and not supported anymore; you can still possible detect it on clientside and then send a trigger to the serverside which is warping you

Blitz_Hunter 02-03-2004 04:01 AM

Never seen Stefan so evil. :p

DIABLO2099 02-03-2004 04:11 AM

x.x, I always thought when showing a character it was to be done on the client.

Admins 02-03-2004 04:18 AM

Quote:

Originally posted by DIABLO2099
x.x, I always thought when showing a character it was to be done on the client.
x-x
You can do all initializations on the serverside, its faster anyway and causing less traffic since the script doesn't need to be sent to the client, and the npcs actually see each other then ;)
You can also drawoverplayer, drawunderplayer etc. on the server, don't know why some people always put that in the clientside part. The only problem is when you do lights or similar things, the commands setcoloreffect, setzoomeffect and seteffectmode only work on clientside.

DIABLO2099 02-03-2004 04:24 AM

Quote:

Originally posted by Stefan


x-x
You can do all initializations on the serverside, its faster anyway and causing less traffic since the script doesn't need to be sent to the client, and the npcs actually see each other then ;)
You can also drawoverplayer, drawunderplayer etc. on the server, don't know why some people always put that in the clientside part. The only problem is when you do lights or similar things, the commands setcoloreffect, setzoomeffect and seteffectmode only work on clientside.

I guess most people do that because they think it would cause less traffic being sent to the NPC-Server.

Admins 02-03-2004 04:27 AM

Quote:

Originally posted by DIABLO2099

I guess most people do that because they think it would cause less traffic being sent to the NPC-Server.

AAAH
The npcserver is doing all the npc stuff anyway, the question is if the thing needs to be sent to the client. If you do the initialization on the clientside then the npcserverr is bored, but needs to send the script to everyone who enters the level, the players then need to run the script which cause even more lag because entering the level causes delays from downloading the npcs, downloading the scripts and running the scripts.
When you do that on npcserver it just needs to be done one time and everything is fine. That is actually the purpose of the npcserver, doing the npcs

DIABLO2099 02-03-2004 04:31 AM

Quote:

Originally posted by Stefan


AAAH
The npcserver is doing all the npc stuff anyway, the question is if the thing needs to be sent to the client. If you do the initialization on the clientside then the npcserverr is bored, but needs to send the script to everyone who enters the level, the players then need to run the script which cause even more lag because entering the level causes delays from downloading the npcs, downloading the scripts and running the scripts,
when you do that on npcserver it just needs to be done one time and everything is fine.

I'm sorry, this is confusing me more. I am going to read my documents on the NPC-Server and then make some sense of this
:(.

-Ramirez- 02-03-2004 05:34 AM

Stefan, here's something for you to fix, since you say we should do it serverside.

Try putting this in a new NPC:
NPC Code:

if (created) {
showcharacter;
setcharprop #3,head0.png;
setcharprop #C0,orange;
setcharprop #C1,white;
setcharprop #C2,blue;
setcharprop #C3,red;
setcharprop #C4,black;
setcharprop #2,shield1.png;
shieldpower = 1;
dir = 2;
}



When you enter the level, you'll notice it has red and black for its outfit. It doesn't use the colors specified. At least... this is what happens on Classic Dev.

Termina_Owner 02-03-2004 06:07 AM

Quote:

Originally posted by Stefan

2. with (getplayer(#a)) is completely nonsense, please kill the one who teached you such stuff

This is hilarious. I should check Stefan's posts more often :)

adam 02-03-2004 06:09 AM

Well I didn't tell him to do that.

I told him if that bush flag didn't work to try checking #m for carrying.

Gman4pwnu 02-03-2004 02:09 PM

So how would I do a lights on / off script for everyone to see? A triggeraction from server to client?

Also, if I select an image for the npc, do I need to set a shape?

Gman4pwnu 02-03-2004 02:11 PM

Wavy Vision for drunk effect?
 
what command would I use if one at all?

Also how would I have a timer that slowly brings down drunk level?

Gman4pwnu 02-03-2004 02:17 PM

Custom Swords and Weapons
 
Again, im wondering what commands it'll take. What will I need to use? Im guessing setcharani, freezeplayer, but I really have no clue on hit detection. =\

Gman4pwnu 02-03-2004 02:22 PM

Triggeraction
 
Can a trigger action detect an NPC thats in a players inventory?

Sorry for all the posts, but im not jus goin 2 cram em all into one :)

WanDaMan 02-03-2004 03:22 PM

seteffect, setfocus.


All times are GMT +2. The time now is 10:26 PM.

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