Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   spar arena script help (was titled "scripting help!") (https://forums.graalonline.com/forums/showthread.php?t=85243)

Kamakaze 04-21-2009 02:05 AM

spar arena script help (was titled "scripting help!")
 
i have this script for a spar arena and it will not place the bomb on player chats start. and i need help with the disabling weapons when not in spar and re-enabling them when the player says 'start' so they can spar!

here is the script if you could please help me get this script working that would be great thanks
-Joker


PHP Code:

//#CLIENTSIDE
    
function onCreated() {
      
setTimer(0.05);
    }
function 
onPlayerChats() {
      if (
player.chat == "start") {
        if (
this.sparring.size() == 2putbomb(03135);
      }
  elseif (
player.chat == "join") {
        if (
this.sparring.size 3) {
player.30;
    
player.30;
    }
      }
    }
function 
onTimeout() {
      
temp.sparAreaX 0;
      
temp.sparAreaY 0;

      
temp.sparAreaWidth 10;
      
temp.sparAreaHeight 10
  
if (player.x in |temp.sparAreaXtemp.sparAreaX temp.sparAreaWidth|
          && 
player.y in |temp.sparAreaYtemp.sparAreaY temp.sparAreaHeight|) {

           if (!(
player.account in this.sparring)) {
             if (
this.sparring.size() < 3) {
            
this.sparring.add(player.account);
             }

     else {
       
player.30;
       
player.30;
     }
       }
      }

      else {
    if (
player.account in this.sparringthis.sparring.remove(player.account);
      }
  
setTimer(0.05);
    } 


fragman85 04-21-2009 12:44 PM

PHP Code:

//#CLIENTSIDE
    
function onCreated() {
               
this.sparAreaX 0;
      
this.sparAreaY 0;

      
this.sparAreaWidth 10;
      
this.sparAreaHeight 10
               setTimer
(0.05);
    } 

Instead of constantly setting the Coordinates in a .05 TimeOut, you do better using this.vars and setting them once in the onCreated() Event.
PHP Code:

function onPlayerChats() {
      if (
player.chat == "start") {
        if (
this.sparring.size() == && player.account in this.sparring) {
                   
putbomb(03135);
                 }
      }
  elseif (
player.chat == "join" && !(player.account in this.sparring)) {
        if (
this.sparring.size() < 3) {
player.30;
    
player.30;
    }
      }
    } 

You forgot two checks here. When the player says start, you have to check if the Player is one of the two sparrers, otherwise everybody in the Level can start the Spar, which is pretty dumb. Also when someone attemps to join, he can't be one of the two sparrers :o.
You also forgot a .size() here.
PHP Code:

function onTimeout() {
  if (
player.x in |this.sparAreaXthis.sparAreaX this.sparAreaWidth|
          && 
player.y in |this.sparAreaYthis.sparAreaY this.sparAreaHeight|) {
  
enableweapons();
           if (!(
player.account in this.sparring)) {
             if (
this.sparring.size() < 3) {
            
this.sparring.add(player.account);
             }

     else {
       
player.30;
       
player.30;
     }
       }
      }

      else {
                 
disableweapons();
    if (
player.account in this.sparringthis.sparring.remove(player.account);
      }
  
setTimer(0.05);
    } 

Here, I just added enableweapons() if the player is in the Spar Area and disableweapons() if not, so outside can't be pked. Oh and of course the temp.vars were replaced with the this.vars.

Sorry if I forgot something, but try to style your scripts more in the future :o

Kamakaze 04-21-2009 08:28 PM

thanx dude that looks like everything, and that really helped me out a lot.
and it looks like everything is there [:.
and yea styling would prolly make it easier too. but yea thanks for all the help :D


Quote:

Originally Posted by fragman85 (Post 1485682)
PHP Code:

//#CLIENTSIDE
    
function onCreated() {
               
this.sparAreaX 0;
      
this.sparAreaY 0;

      
this.sparAreaWidth 10;
      
this.sparAreaHeight 10
               setTimer
(0.05);
    } 

Instead of constantly setting the Coordinates in a .05 TimeOut, you do better using this.vars and setting them once in the onCreated() Event.
PHP Code:

function onPlayerChats() {
      if (
player.chat == "start") {
        if (
this.sparring.size() == && player.account in this.sparring) {
                   
putbomb(03135);
                 }
      }
  elseif (
player.chat == "join" && !(player.account in this.sparring)) {
        if (
this.sparring.size() < 3) {
player.30;
    
player.30;
    }
      }
    } 

You forgot two checks here. When the player says start, you have to check if the Player is one of the two sparrers, otherwise everybody in the Level can start the Spar, which is pretty dumb. Also when someone attemps to join, he can't be one of the two sparrers :o.
You also forgot a .size() here.
PHP Code:

function onTimeout() {
  if (
player.x in |this.sparAreaXthis.sparAreaX this.sparAreaWidth|
          && 
player.y in |this.sparAreaYthis.sparAreaY this.sparAreaHeight|) {
  
enableweapons();
           if (!(
player.account in this.sparring)) {
             if (
this.sparring.size() < 3) {
            
this.sparring.add(player.account);
             }

     else {
       
player.30;
       
player.30;
     }
       }
      }

      else {
                 
disableweapons();
    if (
player.account in this.sparringthis.sparring.remove(player.account);
      }
  
setTimer(0.05);
    } 

Here, I just added enableweapons() if the player is in the Spar Area and disableweapons() if not, so outside can't be pked. Oh and of course the temp.vars were replaced with the this.vars.

Sorry if I forgot something, but try to style your scripts more in the future :o


Kamakaze 04-21-2009 09:14 PM

fragman85, i just inserted this in my level, but it wont start the other is working
and i noticed u forgot the focus on and focus off,
if you could help see whats up that would be cool
thanks
-Joker

Kamakaze 04-21-2009 09:56 PM

new script tell me what you think

PHP Code:

if(created){
 
setshape 1,32,32;
 
dontblock;
}
if(
actionstart){
 
this.conv_sparcount=0;
 unset 
this.conv_accounts;
 for(
this.conv_i=0;this.conv_i<playerscount;this.conv_i++){
  
with(players[this.conv_i]){
   if(
playerx in |17.5,43.5| && playery in |18,36|){
    if(
strequals(#c,start)){
     
this.conv_sparcount++;
     
addstring this.conv_accounts,#a;
     
setplayerprop #c,Spar starting!;
    
}
   }
  }
  if(
this.conv_sparcount==2){
   break;
  }
 }
 if(
this.conv_sparcount==2){
  for(
this.conv_i=0;this.conv_i<2;this.conv_i++){
   
with(getplayer(#I(this.conv_accounts,this.conv_i))){
    
set client.sparstart;
   }
  }
 }
}
if(
actionstop){
 
this.conv_sparcount=0;
 unset 
this.conv_accounts;
 for(
this.conv_i=0;this.conv_i<playerscount;this.conv_i++){
  
with(players[this.conv_i]){
   if(
playerx in |17.5,43.5| && playery in |18,36|){
    if(
strequals(#c,stop)){
     
this.conv_sparcount++;
     
addstring this.conv_accounts,#a;
    
}
   }
  }
  if(
this.conv_sparcount==2){
   break;
  }
 }
 if(
this.conv_sparcount==2){
  for(
this.conv_i=0;this.conv_i<2;this.conv_i++){
   
with(getplayer(#I(this.conv_accounts,this.conv_i))){
    
unset client.sparring;
    unset 
client.doorlock;
    
setplayerprop #c,Spar stopped!;
    
disableweapons;
   }
  }
 }
}
//#CLIENTSIDE
if(playerchats){
 if(
strequals(start,#c)){
  
if(playerx in |17.5,43.5| && playery in |18,36|){
   
this.conv_sparcount=1;
   for(
this.conv_i=1;this.conv_i<playerscount;this.conv_i++){
    if(
strequals(#c(this.conv_i),start)){
     
if(players[this.conv_i].x in |17.5,43.5| && players[this.conv_i].y in |18,36|){
      
this.conv_sparcount=2;
      break;
     }
    }
   }
   if(
this.conv_sparcount==2){
    
triggeraction x,y,start,;
   }
  }
 }
 if(
strequals(stop,#c)){
  
if(playerx in |17.5,43.5| && playery in |18,36|){
   
this.conv_sparcount=1;
   for(
this.conv_i=1;this.conv_i<playerscount;this.conv_i++){
    if(
strequals(#c(this.conv_i),stop)){
     
if(players[this.conv_i].x in |17.5,43.5| && players[this.conv_i].y in |18,36|){
      
this.conv_sparcount=2;
      break;
     }
    }
   }
   if(
this.conv_sparcount==2){
    
triggeraction x,y,stop,;
   }
  }
 }
}
if(
created||timeout){
 
timeout=.05;
 if(
client.sparstart){
  unset 
client.sparstart;
  
this.conv_timer=3;
  
putbomb 1,x,y;
 }
 if(
this.conv_timer>0){
  
this.conv_timer-=.05;
  if(
this.conv_timer==0){
   
set client.sparring;
   
set client.doorlock;
  }
 }
}
if(
playerchats){
 if(
startswith(warpto,#c)){
  
setplayerprop #c,No warping in this level!;
 
}
 if(
strequals(unstick me,#c)||strequals(unstuck me,#c)){
  
setplayerprop #c,No unsticking in this level!;
 
}
 if(
strequals(update level,#c)){
  
setplayerprop #c,No updating level!;
 
}
  elseif (
player.chat == "i call winner" && !(player.account in this.sparring)) {
        if (
this.sparring.size() < 3) {
player.30.5;
    
player.36;
  }



napo_p2p 04-21-2009 10:30 PM

Quote:

Originally Posted by Kamakaze (Post 1485847)
new script tell me what you think

Me no likey:
1) Script is in GS1
2) Script is copied from UN somewhere. I know this because I'm the one who added the this.conv_ prefix to all variables back when UN was trying to become GS2 compliant.

Kamakaze 04-21-2009 11:06 PM

i dont work for UN, i play it but dont work on it...
and for some reason i dont get the whole GS2 stuff
and it truns out like this GS1... its kinda weird actually


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

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