Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Turning no playerkilling off (https://forums.graalonline.com/forums/showthread.php?t=67684)

excaliber7388 07-28-2006 09:24 PM

Turning no playerkilling off
 
How can you turn off noplayerkilling in a level on clientside, so it's only for a few players. It's for a spar, but I'm having trouble with making it so only 2 people can enter, and disabling the nopk zone. I know other servers do it, but I can't figure it out.
Basically I need a script to turn off the no pk (without serverwarp)
and an idea for making a script that allows only 2 people in a spar

xXziroXx 07-28-2006 09:45 PM

How about:

PHP Code:

//#CLIENTSIDE
function onCreated() setTimer(.05);

function 
onTimeOut()
{
  if (
player.x in |startxendx| && player.y in |startyendy|) noplayerkilling();
  
setTimer(.05);


Should work. Uhm, replace startx/endx & starty/endy with actually locations though.

excaliber7388 07-28-2006 09:55 PM

That only turns on no pk when you walk out of the spar area. It doesn't turn off no pk when you walk into the spar area though

Skrobo2 07-29-2006 10:56 AM

You shouldn't even use noplayerkilling();. You should use disableweapons(); then enableweapons();. You'll probably want to use disablepause(); and disableselectweapons(); as well. Spars are a pain, so I won't bother to explain more about how you might do the door for the entrance and such.

calani 07-30-2006 07:21 PM

hehe spars are fun.
especially custom spars like darkspar, lightspar, etc ;)

Gambet 07-30-2006 08:58 PM

You can't make part of a level a killing zone and the other a non-player killing zone, but, you can do this:


PHP Code:

//#CLIENTSIDE
function onCreated()
{
 
setTimer0.05 );
}

function 
onTimeOut()
{
  if  ( 
player.x in |start[x]range,end[x]range| && player.y in |start[y]range,end[y]range| ) {
   
enableweapons();
  } else {
   
disableweapons();
   
//INSERT LINE HERE TO MAKE YOUR PLAYER HEARTS ALWAYS EQUAL YOUR MAX PLAYER HEARTS. NOT EVERY SERVER USES THE CUSTOM HEART SYSTEM, SO I'LL LEAVE THIS LINE EMPTY FOR YOU TO ADD TO FIT TO YOUR SERVER.
  
}
  
setTimer0.05 );



EDIT to Skyld's post right below mines: I would expect the person to have common sense. On Maloria, I'd do something like

PHP Code:

if (created)
  
setshape 1,32,32;

if (
actionheal) {
  
setstring clientr.hp,#s(clientr.hpmax);
  
set client.updateheart;
}
//#CLIENTSIDE
if ( created )
  
timeout=0.05;

if ( 
timeout ) {
  if ( 
playerx in |startxendx| && playery in |starty,endy| ) {
    unset 
client.disable;
    
enableweapons;
  } else {
    
set client.disable;
    
disableweapons;
   if ( 
strtofloat#s(clientr.hp) ) < strtofloat( #s(clientr.hpmax) ) ) {
    
triggeraction x+0.5,y+0.5,heal,;
    }
  }
  
timeout=0.05;



Skyld 07-30-2006 10:01 PM

Quote:

Originally Posted by Gambet
You can't make part of a level a killing zone and the other a non-player killing zone, but, you can do this:

For some reason, resetting the hearts in a loop seems like overkill.

KuJi 07-31-2006 03:18 AM

Quote:

Originally Posted by Gambet
PHP Code:

if (created)
  
setshape 1,32,32;

if (
actionheal) {
  
setstring clientr.hp,#s(clientr.hpmax);
  
set client.updateheart;
}
//#CLIENTSIDE
if ( created )
  
timeout=0.05;

if ( 
timeout ) {
  if ( 
playerx in |startxendx| && playery in |starty,endy| ) {
    unset 
client.disable;
    
enableweapons;
  } else {
    
set client.disable;
    
disableweapons;
   if ( 
strtofloat#s(clientr.hp) ) < strtofloat( #s(clientr.hpmax) ) ) {
    
triggeraction x+0.5,y+0.5,heal,;
    }
  }
  
timeout=0.05;



So you are triggering to the server to heal the player every 0.05 seconds. THATS WHERE MALS LAG COMES FROM :O

Now i wonder where eras comes from.. hmm

Here, just made this in a second - should work:

PHP Code:

function onPlayerTouchsMe() {
  
playersc 0;
  for (
i=0i<players.size(); i++) {
    
with (players[i]) {
      if (
player.x in |2030| && player.y in |2030|) { // You may want to change the position checks
        
playersc++;
      }
    }
  }
  if (
playersc >= 2) {
    
player.chat "There is currently two players in the spar!";
  } else {
    
player.chat "Sure, come on in";
  }


Maybe something like that?

Gambet 07-31-2006 04:59 AM

Quote:

Originally Posted by KuJi
So you are triggering to the server to heal the player every 0.05 seconds. THATS WHERE MALS LAG COMES FROM :O


No, it triggers only if you get hurt while outside of the box, can't you read code? You should really read entire code before making such accusations. I would never make a public npc trigger in a loop without any conditions to tell it when to trigger.

KuJi 07-31-2006 12:22 PM

Quote:

Originally Posted by Gambet
No, it triggers only if you get hurt while outside of the box, can't you read code? You should really read entire code before making such accusations. I would never make a public npc trigger in a loop without any conditions to tell it when to trigger.

My bad.. sorry about that. I just looked through your code and I couldn't see the yellow ;(

excaliber7388 07-31-2006 07:38 PM

That thing for the door doesn't work?

ApothiX 08-01-2006 04:12 PM

Quote:

Originally Posted by Gambet
No, it triggers only if you get hurt while outside of the box, can't you read code? You should really read entire code before making such accusations. I would never make a public npc trigger in a loop without any conditions to tell it when to trigger.

I smell abuse.


All times are GMT +2. The time now is 07:51 AM.

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