Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Warp Player and Max Heart Problem (https://forums.graalonline.com/forums/showthread.php?t=56893)

Zickle 01-06-2005 01:44 AM

Warp Player and Max Heart Problem
 
2 Questions:

1) How do you warp a player in a while (visible) {if (mousedown) {WARP PLAYER} } (Thats not the full code but thats how its done, sorta. Setlevel2 isnt working. But it works in a simple if (playerchats&&strequeals(#c,)) {} script.

2) I got a server, how do I make it so that people start off with 5 hearts instead of 3?

Evil_Trunks 01-06-2005 01:46 AM

Quote:

Originally Posted by Zickle
while (visible) {if (mousedown) {WARP PLAYER} }

Ahhhhhhhhhhhh!

Quote:

2) I got a server, how do I make it so that people start off with 5 hearts instead of 3?
actionplayeronline, set a flag once you initialize their stats

ZeroTrack 01-06-2005 02:09 AM

Quote:

Originally Posted by Zickle
1) How do you warp a player in a while (visible) {if (mousedown) {WARP PLAYER} } (Thats not the full code but thats how its done, sorta.

for the love of your nc dont do that!
Quote:

Originally Posted by Zickle
Setlevel2 isnt working. But it works in a simple if (playerchats&&strequeals(#c,)) {} script.

setlevel2 is serverside just making sure you know this
Quote:

2) I got a server, how do I make it so that people start off with 5 hearts instead of 3?
most widely use with actionplayeronline in the control npc like trunks said, but using the graal default hp system is not recommended , at least not by me

Polo 01-06-2005 02:16 AM

Quote:

Originally Posted by ZeroTrack
...using the graal default hp system is not recommended , at least not by me

I emulated all of classic movement and hit detection because I agree with this... it was painful though, a small part of me died.

Zickle 01-06-2005 02:22 AM

Okay well look heres my code:
NPC Code:

removed, see newer code.


Works offline, not online.

xManiamaNx 01-06-2005 05:05 AM

AAahh dont use while loops for something like that. Use a timeout instead.

Why are there multiple instances of //#CLIENTSIDE?

Zickle 01-06-2005 05:13 AM

Quote:

Originally Posted by xManiamaNx
AAahh dont use while loops for something like that. Use a timeout instead.

Is there a difference?
Quote:

Originally Posted by xManiamaNx
Why are there multiple instances of //#CLIENTSIDE?

SHHH! You see nothing.

Tolnaftate2004 01-06-2005 05:37 AM

setlevel2 must be serverside.

Zickle 01-06-2005 06:26 AM

Okay! I got it down to a simple:
NPC Code:
// NPC made by ZicklePop
while (visible) {
if (client.statsgender=boy) {
setlevel2 zercha-start-boy.nw,30,32.5;
}
if (client.statsgender=girl) {
setlevel2 zercha-start-girl.nw,30,32.5;
}
sleep 0.1;
}


Whats wrong with it?

Evil_Trunks 01-06-2005 06:30 AM

that's a completely terrible script

I will tell you why

first of all, you are doing a 0.1 second loop serverside, which is the worst idea ever if you can at all avoid it

you are comparing strings wrong

NPC Code:
if (strequals(#s(this.string),some text)) {



that is the kind of format you must use in GScript

third you are doing your loop using while and sleep, that's a horrible idea
use timeout for loops

fourth, this kind of thing should be integrated into whatever system you have for picking the gender in the first place

good luck with improving your scripting abilities, we all have to start from somewhere

Slash-P2P 01-06-2005 06:42 AM

NPC Code:

// NPC made by ZicklePop
while (visible) {
if (client.statsgender=boy) {
setlevel2 zercha-start-boy.nw,30,32.5;
}
if (client.statsgender=girl) {
setlevel2 zercha-start-girl.nw,30,32.5;
}
sleep 0.1;
}



For the love of Govannon, don't use 'while'.

Your mouse stuff is clientside. Your setlevel stuff is serverside.
Practice using triggeraction to call serverside stuff for warping.

Sildae 01-06-2005 06:46 AM

Quote:

Originally Posted by Evil_Trunks
actionplayeronline, set a flag once you initialize their stats

What a waste of a perfectly fine flag! if (playerfullhearts < 5) playerfullhearts = 5; and be done with it!

Quote:

Originally Posted by Slash-P2P
Your mouse stuff is clientside. Your setlevel stuff is serverside.
Practice using triggeraction to call serverside stuff for warping.

Why could I not move the mouse stuff to the server side instead?

Zickle 01-06-2005 06:47 AM

But doesnt it have to be in its own NPC because of Serverside and Clientside?

Zickle 01-06-2005 06:58 AM

NPC Code:

// NPC made by ZicklePop
if (created) setshape 1,1,1;
if (actionplayerboy) setlevel2 zercha-start-boy.nw,30,32.5;
if (actionplayergirl) setlevel2 zercha-start-girl.nw,30,32.5;
//#CLIENTSIDE
if (strequals(#s(client.statsgender),boy)) {
sleep 0.1;
triggeraction x,y,playerboy,;
}
if (strequals(#s(client.statsgender),girl)) {
sleep 0.1;
triggeraction x,y,playergirl,;
}


Thats my current code, but it only works on update level (or level refresh wahtever you call it)

Evil_Trunks 01-06-2005 07:08 AM

where is client.statsgender being set?

that's where you should be calling the level switch

(as a side note: client. flags are insecure and are able to be edited clientside by malicious players using certain programs)

Sildae 01-06-2005 07:25 AM

Quote:

Originally Posted by Zickle
NPC Code:

//#CLIENTSIDE
if (strequals(#s(client.statsgender),boy)) {}
if (strequals(#s(client.statsgender),girl)) {}


only works on update level

I believe the KSI-GS covers that.

Velox Cruentus 01-06-2005 10:52 AM

First off, make it easy for people to read.
Second off... Do not put statements without commands.
Third... If you have a string that contains differant possibility, use "else if"
Fourth... Be lazy, It helps.
Fifth... Why the sleep?

Basically, I would've done it like this:
PHP Code:

// NPC made by ZicklePop
if (createdsetshape 1,2,2;
if (
actionplayerwarp){
  
setlevel2 zercha-start-#p(0).nw,30,32.5;
}
//#CLIENTSIDE
if (playerenters){
  if (
strequals(#s(client.statsgender),girl)
      
|| strequals(#s(client.statsgender),guy))
   
triggeraction x+1,y+1,playerwarp,#s(client.statsgender);


Now you're good to rule the world! :)

Hrm... Perhaps this violates the Forum Rule "Do not ask full scripts". Ohwell, it was quite short regardless.

Evil_Trunks 01-06-2005 02:19 PM

no clientside part is needed if it is triggered on playerenters
you realize this would be the same thing? but better

PHP Code:

if (playerenters){
  if (
strequals(#s(client.statsgender),girl) || strequals(#s(client.statsgender),guy)) {
     
setlevel2 zercha-start-#p(0).nw,30,32.5;
  
}



Zickle 01-06-2005 03:22 PM

Thanks you too, I think I've a got it!

JudgeDurst 01-06-2005 07:13 PM

If this is just for setting the gender of a player why not use
setgender male/female; and check if(playerismale) or if(playerisfemale)
(with else you'd only need to use one anyways)

I'm not sure if that is stored clientside or serverside but unless gender is important I thought that'd be okay. Unless setgender is a depreciated command now o.o

Evil_Trunks 01-07-2005 12:10 AM

I always thought it was deprecated, myself

I'm pretty sure Era uses it, though

Zickle 01-07-2005 03:07 PM

Quote:

Originally Posted by JudgeDurst
If this is just for setting the gender of a player why not use
setgender male/female; and check if(playerismale) or if(playerisfemale)
(with else you'd only need to use one anyways)

I'm not sure if that is stored clientside or serverside but unless gender is important I thought that'd be okay. Unless setgender is a depreciated command now o.o

I did think of using that but I can't remember in past experiences if it'd set the profile. Plus this way it allows people to change genders in the game lol.


All times are GMT +2. The time now is 04:45 AM.

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