Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-21-2009, 02:05 AM
Kamakaze Kamakaze is offline
UN Levels Team Admin
Kamakaze's Avatar
Join Date: Sep 2008
Location: Virginia
Posts: 37
Kamakaze is on a distinguished road
Red face 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);
    } 
Reply With Quote
  #2  
Old 04-21-2009, 12:44 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
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

Last edited by fragman85; 04-21-2009 at 12:59 PM..
Reply With Quote
  #3  
Old 04-21-2009, 08:28 PM
Kamakaze Kamakaze is offline
UN Levels Team Admin
Kamakaze's Avatar
Join Date: Sep 2008
Location: Virginia
Posts: 37
Kamakaze is on a distinguished road
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


Quote:
Originally Posted by fragman85 View Post
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
Reply With Quote
  #4  
Old 04-21-2009, 09:14 PM
Kamakaze Kamakaze is offline
UN Levels Team Admin
Kamakaze's Avatar
Join Date: Sep 2008
Location: Virginia
Posts: 37
Kamakaze is on a distinguished road
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
Reply With Quote
  #5  
Old 04-21-2009, 09:56 PM
Kamakaze Kamakaze is offline
UN Levels Team Admin
Kamakaze's Avatar
Join Date: Sep 2008
Location: Virginia
Posts: 37
Kamakaze is on a distinguished road
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;
  }


Last edited by Kamakaze; 04-21-2009 at 09:57 PM.. Reason: put the wrong coding edit!
Reply With Quote
  #6  
Old 04-21-2009, 10:30 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Kamakaze View Post
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.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #7  
Old 04-21-2009, 11:06 PM
Kamakaze Kamakaze is offline
UN Levels Team Admin
Kamakaze's Avatar
Join Date: Sep 2008
Location: Virginia
Posts: 37
Kamakaze is on a distinguished road
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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:30 PM.


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