Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Spawn Point (https://forums.graalonline.com/forums/showthread.php?t=76667)

Knightmare1 09-06-2007 10:45 PM

Spawn Point
 
like i said, i did gs1, so i still use if (playerdead).
can someone help? heres script.
PHP Code:

//#CLIENTSIDE
function onCreated() {
  if (
playerdead)
    
setlevel2("hospital.nw");
    
sleep(3);



Codein 09-06-2007 10:53 PM

Quote:

Originally Posted by Knightmare1 (Post 1346157)
like i said, i did gs1, so i still use if (playerdead).
can someone help? heres script.
PHP Code:

//#CLIENTSIDE
function onCreated() {
  if (
playerdead)
    
setlevel2("hospital.nw");
    
sleep(3);



setlevel2(); is clientside.

You should check for the event of when the player's dying. Like onPlayerDies().

Then you should trigger the server to set the level.

Also, setlevel2's syntax is:

setlevel2(level name as String, x as float, y as float);

:P

Kyranki 09-06-2007 11:02 PM

Also, you can't do...

PHP Code:

function onCreated() {
  if (
playerdead// yada yaa


That was a GS1 event, in GS2 it's a null temp variable and won't work that way. Also, setlevel2() is used wrong as well. The first parameters for the function should be the level name and then the x and y to place the player at. It also needs to be serverside. I would suggest reading the wiki to try and find a few good tutorials on scripting as well as trying to findout which functions and things are serverside only as such.

DustyPorViva 09-06-2007 11:22 PM

Ya...
PHP Code:

function onCreated() {
  if (
playerdead// yada yaa


Would assume the player is dead when the NPC is created. Even in GS1, there is the if (playerdies) event for something like this. Other than what's already been repeated... I can't really see what else there is to add.
I suggest studying up on clientside/serverside as well as what are events, booleans and so on.

PrinceOfKenshin 09-06-2007 11:57 PM

PHP Code:

function onCreated(){
if (
player.hp <= ) { 
setlevel2("hospital.nw",x,y);


simple as that.

DustyPorViva 09-07-2007 12:04 AM

No it's not, again, the player has to have already been dead when the NPC is created.

Knightmare1 09-07-2007 02:05 AM

function onCreated(){
if (player.hp <= 0 ) {
setlevel2("hospital.nw",x,y);
}
}
doesnt work

theHAWKER 09-07-2007 02:22 AM

Quote:

Originally Posted by DustyPorViva (Post 1346168)
Ya...
PHP Code:

function onCreated() {
  if (
playerdead// yada yaa



there is a gs2 function for dieing...

function onPlayerDies(){
//this is the gs2 way
}

Switch 09-07-2007 02:23 AM

PHP Code:

function onCreated()
 
setTimer(0.05);
function 
onTimeOut() {
 if (
player.hearts 0.5) {
  
setlevel2("hospital.nw",30,30);  //syntax: setlevel2(LevelNameInString,x,y);
 
}


That should work without much lag. If there is lag, then use this:
PHP Code:

function onPlayerDies() {  //I don't know if this is a real command, but Codein said there was one.
 
setlevel2("hospital.nw",30,30);  //syntax: setlevel2(LevelNameInString,x,y);



DustyPorViva 09-07-2007 02:39 AM

Quote:

Originally Posted by theHAWKER (Post 1346204)
there is a gs2 function for dieing...

function onPlayerDies(){
//this is the gs2 way
}

I know, hence my comment "event in GS1".

Googi 09-07-2007 02:57 AM

Quote:

Originally Posted by Switch (Post 1346205)
I don't know if this is a real command

http://skyld.vip.graal.net/wikka.php?wakka=onPlayerDies

Switch 09-08-2007 04:02 PM

Quote:

Originally Posted by Googi (Post 1346210)

Okay then, use this on that I posted above xD:

PHP Code:

//#CLIENTSIDE
function onPlayerDies() {  //function for when the player dies
 
setlevel2("hospital.nw",30,30);  //syntax: setlevel2(LevelNameInString,x,y);



Chompy 09-08-2007 05:55 PM

Quote:

Originally Posted by Switch (Post 1346499)
Okay then, use this on that I posted above xD:

PHP Code:

//#CLIENTSIDE
function onPlayerDies() {  //function for when the player dies
 
setlevel2("hospital.nw",30,30);  //syntax: setlevel2(LevelNameInString,x,y);



setlevel2 won't work on the clientside, it did work before gs2, but no longer..

Twinny 09-08-2007 06:24 PM

Quote:

Originally Posted by Chompy (Post 1346538)
setlevel2 won't work on the clientside, it did work before gs2, but no longer..

I thought NPC-Server would have caused the change: not the language :confused:

Codein 09-08-2007 07:15 PM

Quote:

Originally Posted by Twinny (Post 1346545)
I thought NPC-Server would have caused the change: not the language :confused:

It was definitely made serverside on the release of the NPC-Server.

I distinctively remember having to trigger to serverside when I scripted warp rings for an old project I was working on BEFORE the release of GS2.

Kyranki 09-08-2007 09:30 PM

Quote:

Originally Posted by Switch (Post 1346205)
PHP Code:

function onCreated()
 
setTimer(0.05);
function 
onTimeOut() {
 if (
player.hearts 0.5) {
  
setlevel2("hospital.nw",30,30);  //syntax: setlevel2(LevelNameInString,x,y);
 
}


That should work without much lag. If there is lag, then use this:
PHP Code:

function onPlayerDies() {  //I don't know if this is a real command, but Codein said there was one.
 
setlevel2("hospital.nw",30,30);  //syntax: setlevel2(LevelNameInString,x,y);



The first one won't work because that's serverside, and usually when a serverside script is initialized it is not in the scope of the player.

Isn't onPlayerDies clientside only? If it is that won't work either becauset setlevel2() is serverside only.

Crow 09-08-2007 09:45 PM

PHP Code:

function onActionServerSide() {
  switch (
params[0]) {
    case 
"dead":
      
setlevel2(level,x,y);
    break;
  }
}
function 
onCreated()
  
setshape(1,32,32);
//#CLIENTSIDE
function onCreated() {
  
setshape(1,32,32);
  
dontblock();
  
onTimeOut();
}
function 
onTimeOut() {
  if (
player.hearts .5)
    
triggeraction(1,1,"serverside","dead");

  
setTimer(.05);


Not tested, don't hurt me if it doesnt work ;[

Chompy 09-08-2007 10:01 PM

Quote:

Originally Posted by Twinny (Post 1346545)
I thought NPC-Server would have caused the change: not the language :confused:

I remmeber back way I made some clientside stuff if you say something I just did setlevel2 to warp them to a secret place ;o

Codein 09-09-2007 12:51 AM

Quote:

Originally Posted by Kyranki (Post 1346621)
The first one won't work because that's serverside, and usually when a serverside script is initialized it is not in the scope of the player.

Isn't onPlayerDies clientside only? If it is that won't work either becauset setlevel2() is serverside only.

onPlayerDies is both, however, they act differently.

On clientside, it triggers when the actual player dies. On serverside, it triggers when anybody dies :P

It'll set the level but I doubt you want to go to the hospital when someone else dies.

As I said, check for when the player dies, trigger to serverside and then set the level.

Mog 10-07-2007 03:21 AM

if you're creating the script on a single level, that's fine. if you want to automatically warp the player to the hospital whenever he/she dies in any level, one way of doing this is by adding it to players as a weapon script, which is added to all players when they log in.

how i'd personally do this is incorporate it inside a weapon script file. basically what i have is a custom GUI and it handles 3 things: updating GUI, checking player's heart count and warp them to OSL if their heart count is 0 and display event warper when an event is going on.

Tigairius 10-07-2007 03:48 PM

Examples in this thread have been horrendous.

Weapon:
PHP Code:

function onActionserverside() {
  switch(
params[0]) {
    case 
"dead":
      
setlevel2("levelname"xy);
    break;
  }
}
//#CLIENTSIDE
function onPlayerDies() 
  
triggerserver("gui"this.name"dead"); 


And for a single level:
PHP Code:

function onCreated() 
  
setshape(13232);

function 
onActionDied() 
  
setlevel2("levelname"xy);

//#CLIENTSIDE
function onPlayerDies() 
  
triggeraction(0.50.5"Died"); 


Switch 10-08-2007 12:05 AM

Quote:

Originally Posted by Kyranki (Post 1346621)
The first one won't work because that's serverside, and usually when a serverside script is initialized it is not in the scope of the player.

Isn't onPlayerDies clientside only? If it is that won't work either becauset setlevel2() is serverside only.

Looking back at this thread since the recent posts.
I forgot to use //#CLIENTSIDE stuff xD Also I recently, like, 2 weeks ago found out setlevel2() was serverside :\ I R STOOPID.

Zanzel 10-08-2007 12:22 PM

Quote:

Originally Posted by Tigairius (Post 1351537)
Examples in this thread have been horrendous.

Weapon:
PHP Code:

function onActionserverside() {
  switch(
params[0]) {
    case 
"dead":
      
setlevel2("levelname"xy);
    break;
  }
}
//#CLIENTSIDE
function onPlayerDies() 
  
triggerserver("gui"this.name"dead"); 


And for a single level:
PHP Code:

function onCreated() 
  
setshape(13232);

function 
onActionDied() 
  
setlevel2("levelname"xy);

//#CLIENTSIDE
function onPlayerDies() 
  
triggeraction(0.50.5"Died"); 


You made a good point Tig, they were kind of that..
although you could letup on the less advanced scripting peoples
than yourself :p

johny023 10-15-2007 04:51 PM

if (playerenters) {
toweapons -spawn;
}

if (playerdies){
sleep 0.1;
setlevel2 levelname.nw,x,y;
}

that's what i use for re spawning but my world is offline and i don't have a npc server so it may not work for you

Crow 10-15-2007 05:25 PM

Quote:

Originally Posted by Tigairius (Post 1351537)
Examples in this thread have been horrendous.

Weapon:
PHP Code:

function onActionserverside() {
  switch(
params[0]) {
    case 
"dead":
      
setlevel2("levelname"xy);
    break;
  }
}
//#CLIENTSIDE
function onPlayerDies() 
  
triggerserver("gui"this.name"dead"); 


And for a single level:
PHP Code:

function onCreated() 
  
setshape(13232);

function 
onActionDied() 
  
setlevel2("levelname"xy);

//#CLIENTSIDE
function onPlayerDies() 
  
triggeraction(0.50.5"Died"); 


Isnt triggeraction always asking for atleast 4 arguments?

xAndrewx 10-15-2007 07:25 PM

yes @ crow

Crow 10-15-2007 08:11 PM

Hah, I so knew it :p

Switch 10-15-2007 10:28 PM

Quote:

Originally Posted by johny023 (Post 1352974)
if (playerenters) {
toweapons -spawn;
}

if (playerdies){
sleep 0.1;
setlevel2 levelname.nw,x,y;
}

that's what i use for re spawning but my world is offline and i don't have a npc server so it may not work for you

1) That isn't setup right.
2) There's no distinct client/server side to this script.

Crow 10-15-2007 11:15 PM

Quote:

Originally Posted by Switch (Post 1353058)
1) That isn't setup right.
2) There's no distinct client/server side to this script.

He said he is using it offline...

Tigairius 10-15-2007 11:28 PM

Quote:

Originally Posted by Crow (Post 1353008)
Hah, I so knew it :p

triggeraction(x + 0.5, y + 0.5, "Died", null);

sorry

Crow 10-15-2007 11:35 PM

Quote:

Originally Posted by Tigairius (Post 1353077)
triggeraction(x + 0.5, y + 0.5, "Died", null);

sorry

You dont have to be sorry, that happens alot :o

Switch 10-16-2007 01:08 AM

Quote:

Originally Posted by Crow (Post 1353075)
He said he is using it offline...

Oh I didn't see that...

Edit:
No, he said his SERVER is offline and has no NPC Control. He said he USES it.

Crow 10-16-2007 01:35 AM

Quote:

Originally Posted by Switch (Post 1353089)
No, he said his SERVER is offline and has no NPC Control. He said he USES it.

Quote:

Originally Posted by johny023 (Post 1352974)
that's what i use for re spawning but my world is offline and i don't have a npc server so it may not work for you

Quote:

Originally Posted by Crow (Post 1353075)
He said he is using it offline...

Ok Switch, again, slowly, just for you. He said his world is offline. He also said he doesnt have an npc server. So if you add those two, what does that mean? Right! He has no playerworld, he makes things offline, in the editor! I never said he doesnt use it btw...

Switch 10-16-2007 01:39 AM

Quote:

Originally Posted by Crow (Post 1353098)
Ok Switch, again, slowly, just for you. He said his world is offline. He also said he doesnt have an npc server. So if you add those two, what does that mean? Right! He has no playerworld, he makes things offline, in the editor! I never said he doesnt use it btw...

No, I'm saying he said he uses it on servers. Atleast that's how he posted it.

Twinny 10-16-2007 06:12 AM

Quote:

Originally Posted by Switch (Post 1353099)
No, I'm saying he said he uses it on servers. Atleast that's how he posted it.

"that's what i use for re spawning but my world is offline and i don't have a npc server so it may not work for you"

Offline world...no NPC-Server....sounds like a level editor world to me. Read his statement carefully, Switch.

xXziroXx 10-16-2007 07:32 AM

Quote:

Originally Posted by Switch (Post 1353099)
No, I'm saying he said he uses it on servers. Atleast that's how he posted it.

Wrong. Fail. Read again.


All times are GMT +2. The time now is 12:43 AM.

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