PDA

View Full Version : Spawn Point


Knightmare1
09-06-2007, 10:45 PM
like i said, i did gs1, so i still use if (playerdead).
can someone help? heres script.
//#CLIENTSIDE
function onCreated() {
if (playerdead)
setlevel2("hospital.nw");
sleep(3);
}

Codein
09-06-2007, 10:53 PM
like i said, i did gs1, so i still use if (playerdead).
can someone help? heres script.
//#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...


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...
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
function onCreated(){
if (player.hp <= 0 ) {
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
Ya...
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
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:
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
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
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
http://skyld.vip.graal.net/wikka.php?wakka=onPlayerDies

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

//#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
Okay then, use this on that I posted above xD:

//#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
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
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
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:
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
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(x + 1,y + 1,"serverside","dead");

setTimer(.05);
}

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

Chompy
09-08-2007, 10:01 PM
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
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:

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



And for a single level:

function onCreated()
setshape(1, 32, 32);

function onActionDied()
setlevel2("levelname", x, y);

//#CLIENTSIDE
function onPlayerDies()
triggeraction(x + 0.5, y + 0.5, "Died");

Switch
10-08-2007, 12:05 AM
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
Examples in this thread have been horrendous.

Weapon:

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



And for a single level:

function onCreated()
setshape(1, 32, 32);

function onActionDied()
setlevel2("levelname", x, y);

//#CLIENTSIDE
function onPlayerDies()
triggeraction(x + 0.5, y + 0.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
Examples in this thread have been horrendous.

Weapon:

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



And for a single level:

function onCreated()
setshape(1, 32, 32);

function onActionDied()
setlevel2("levelname", x, y);

//#CLIENTSIDE
function onPlayerDies()
triggeraction(x + 0.5, y + 0.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
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
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
Hah, I so knew it :p

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

sorry

Crow
10-15-2007, 11:35 PM
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
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
No, he said his SERVER is offline and has no NPC Control. He said he USES 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

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
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
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
No, I'm saying he said he uses it on servers. Atleast that's how he posted it.

Wrong. Fail. Read again.