Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Old Scripting Engine (GS1)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-25-2012, 10:17 PM
Bleachlover551 Bleachlover551 is offline
Soul Reaper
Bleachlover551's Avatar
Join Date: Jul 2012
Location: Brunswick
Posts: 34
Bleachlover551 is an unknown quantity at this point
Post If (playerenters) and is second player to enter? [help]

i'm kinda lost here..Okay so im making this event and i want to make where when the first player enters he goes to a pacific location.. like this script below..
PHP Code:
if (playerenters){
playerx=x+.5;
playery=y;

but i have this script in like 10 different area. but i have no clue how to make a script where when the next player enter he goes to the other spot where this script was places.

Please Help

p.s. please forgive me on my bad grammer

Last edited by Bleachlover551; 07-26-2012 at 09:51 PM..
Reply With Quote
  #2  
Old 07-27-2012, 01:27 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
You can use variables to set if there is a player in there for instance you could try something such as this: (I am also coding this in GS2 not GS1 as it is outdated)
PHP Code:
function onPlayerEnters() {
  if (
this.inside == false) {
    
this.inside true;
    
player.30//Change This, this is the X of the 1st player that enters
    
player.30//Change This, this is the Y of the 1st player that enters
  
} else {
    
player.15//Change This, this is the X of the 2nd+ player(s) that enter
    
player.15//Change This, this is the Y of the 2nd+ player(s) that enter
  
}
  if (
player.chat == "/reset" && player.guild == "Events Team") {
    
this.inside false;
  }

Just plop this down as an NPC in the level and you're ready to go
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #3  
Old 07-27-2012, 07:01 PM
Bleachlover551 Bleachlover551 is offline
Soul Reaper
Bleachlover551's Avatar
Join Date: Jul 2012
Location: Brunswick
Posts: 34
Bleachlover551 is an unknown quantity at this point
Quote:
Originally Posted by Astram View Post
You can use variables to set if there is a player in there for instance you could try something such as this: (I am also coding this in GS2 not GS1 as it is outdated)
PHP Code:
function onPlayerEnters() {
  if (
this.inside == false) {
    
this.inside true;
    
player.30//Change This, this is the X of the 1st player that enters
    
player.30//Change This, this is the Y of the 1st player that enters
  
} else {
    
player.15//Change This, this is the X of the 2nd+ player(s) that enter
    
player.15//Change This, this is the Y of the 2nd+ player(s) that enter
  
}
  if (
player.chat == "/reset" && player.guild == "Events Team") {
    
this.inside false;
  }

Just plop this down as an NPC in the level and you're ready to go
so lets say i would have 7 slots open would i just keep adding else command?
Reply With Quote
  #4  
Old 07-27-2012, 07:48 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
An easier more efficient approach would be to create a multi-dimensional array of warp coordinates:

PHP Code:
function onCreated(){
  
//x, y
  
this.warplocations = {
    {
510},
    {
520},
    {
530},
    {
540},
    {
1510},
    {
1520},
    {
1530},
    {
1540},
  };
  
this.warpamount this.warplocations.size();

And then increment an array index variable each time a player enters:

PHP Code:
function onPlayerEnters(){
  
player.this.warplocations[this.warpindex][0];
  
player.this.warplocations[this.warpindex][1];
  
//Use % to reset a value back to 0 if it overlaps specified value
  
this.warpindex = (this.warpindex 1) % this.warpamount;

Reply With Quote
  #5  
Old 07-28-2012, 12:32 AM
Bleachlover551 Bleachlover551 is offline
Soul Reaper
Bleachlover551's Avatar
Join Date: Jul 2012
Location: Brunswick
Posts: 34
Bleachlover551 is an unknown quantity at this point
Quote:
Originally Posted by ffcmike View Post
An easier more efficient approach would be to create a multi-dimensional array of warp coordinates:

PHP Code:
function onCreated(){
  
//x, y
  
this.warplocations = {
    {
510},
    {
520},
    {
530},
    {
540},
    {
1510},
    {
1520},
    {
1530},
    {
1540},
  };
  
this.warpamount this.warplocations.size();

And then increment an array index variable each time a player enters:

PHP Code:
function onPlayerEnters(){
  
player.this.warplocations[this.warpindex][0];
  
player.this.warplocations[this.warpindex][1];
  
//Use % to reset a value back to 0 if it overlaps specified value
  
this.warpindex = (this.warpindex 1) % this.warpamount;

Thanks So Much! This Will Help Me A Lot In My Event(s)! Also do u have a kickall script? if i may ask?
Reply With Quote
  #6  
Old 07-28-2012, 12:47 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Bleachlover551 View Post
Also do u have a kickall script? if i may ask?
Scripting isn't really a matter of "what is the script for ...?", it's more about "which way would I script ...?".

A simple method to kick all players would be to loop through the built-in 'players' array.

One way of looping through the array would be:

PHP Code:
for(temp.pl players){
  if(
temp.pl.guild != "Events"){
    
temp.pl.setlevel2("levelname.nw",  xy);
  }

Note how temp.pl would be in reference to each player within the level (or each element within the 'players' array).
Variables which start with the 'temp.' prefix are simply temporary values.

Another would be:

PHP Code:
temp.playercount players.size();
for(
temp.0temp.temp.playercounttemp.++){
  if(
players[temp.i].guild != "Events"){
    
players[temp.i].setlevel2("levelname.nw",  xy);
  }

Note how temp.i is being incremented up to the last index value of the players array, and then how the players array elements are being read from directly by specifying the index.
Reply With Quote
  #7  
Old 07-28-2012, 12:43 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
This should help.

PHP Code:
function kick_all() {
  for (
temp.pl players) {
    if (
temp.pl.account == player.account) {
      continue; 
//This way you're not kicked.
    
}

    if (
temp.pl.guild in {"Events Team"}) {
      continue; 
//Prevents other Events Team members from being kicked.
    
}
    
    
temp.pl.setlevel2("level.nw"3030);
  }

__________________
Reply With Quote
  #8  
Old 07-28-2012, 12:57 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tim_Rocks View Post
PHP Code:
if (temp.pl.account == player.account) { 
Just compare the objects directly:

PHP Code:
if (temp.pl == player) { 
__________________
Reply With Quote
  #9  
Old 07-28-2012, 02:14 AM
Bleachlover551 Bleachlover551 is offline
Soul Reaper
Bleachlover551's Avatar
Join Date: Jul 2012
Location: Brunswick
Posts: 34
Bleachlover551 is an unknown quantity at this point
Cool My Sinario

Thanks So Much! Everyone. ^_^ um do you want to see my event? its fun.........but the last thing I'm having trouble with is removing the the players weapon once it leaves the event..or wait let me explain the much more clearly..

Example/My Situation:
I have this simple event. The event has 8 different positons/selections. like the script i was asking for in this thread to begin with. So they enter and my event starts they have daisines and i added inn the daisine script itself. once my player says /kickall it will destroy the daisine..but i had to add this to each individual daisine. but on one of the tracks, its like a trap(the track completely stops i didnt add any more npc tracks to this one specif track section), and once the player hits another npc i made it moves the player y+=1 with a sleep function to make the player actual move...up and hit the warp selection . once he/she hits the warp selection it warps them away to the unstick me level, but the player will steal have the daisine unlike the other plays which i said /lkickall to and removed the weapon, but how do i make it where once the player enters the unstick me level they get the diasine removed?

heres what i came up with..

PHP Code:
if (playerenters&&hasweapon(Draisine)){
 
say2 Your Draisine Will Be Removed!; 
im not sure what to put there please help .

Last edited by Bleachlover551; 07-28-2012 at 03:29 AM.. Reason: Made a copy to my own personal file
Reply With Quote
  #10  
Old 07-28-2012, 09:52 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
To remove a weapon from a player, use player.removeWeapon(weaponName).
__________________
Reply With Quote
  #11  
Old 07-28-2012, 10:28 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Oi tig, I could've benefited from what chris said unless it was out right abuse. Either way, i'm all curious as to what's wrong with the method
findweapon(weaponName).destroy()

Please explain?
Reply With Quote
  #12  
Old 07-28-2012, 10:42 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tricxta View Post
Oi tig, I could've benefited from what chris said unless it was out right abuse. Either way, i'm all curious as to what's wrong with the method
findweapon(weaponName).destroy()

Please explain?
Did you test it? This was my post:

__________________
Reply With Quote
  #13  
Old 07-28-2012, 12:49 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Quote:
Originally Posted by cbk1994 View Post
Did you test it? This was my post:

Cheers, I didn't think anyone would entrust such power to script functions readily available to anyone who has NC(whatever) access.
Reply With Quote
  #14  
Old 07-28-2012, 01:18 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Tricxta View Post
Cheers, I didn't think anyone would entrust such power to script functions readily available to anyone who has NC(whatever) access.
Limiting scripting functionality in fear of what abuse/poor scripting could cause is a horrible approach.

I'll probably pick up a negative rep or two for the following comment, but it'd be like not allowing immigrants from middle eastern countries in fear of letting in terrorists.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 07-28-2012, 10:46 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by xXziroXx View Post
Limiting scripting functionality in fear of what abuse/poor scripting could cause is a horrible approach.

I'll probably pick up a negative rep or two for the following comment, but it'd be like not allowing immigrants from middle eastern countries in fear of letting in terrorists.
Actually I would rep+ if it let me. The engine executes only what it is told to, limiting it would only hold back its maximum potential. This is why only trusted person(s) should be allowed access.
Reply With Quote
  #16  
Old 07-29-2012, 02:46 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Quote:
Originally Posted by xXziroXx View Post
Limiting scripting functionality in fear of what abuse/poor scripting could cause is a horrible approach.

I'll probably pick up a negative rep or two for the following comment, but it'd be like not allowing immigrants from middle eastern countries in fear of letting in terrorists.
Fair call, i'll +rep.

edit: (when I can...)
Reply With Quote
  #17  
Old 07-29-2012, 09:11 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xXziroXx View Post
Limiting scripting functionality in fear of what abuse/poor scripting could cause is a horrible approach.
With that said, I wish it was possible to control things like this better. It bothers me that any random LAT can delete every weapon on the server, drop all my SQL tables, spawn money or items, etc.
__________________
Reply With Quote
  #18  
Old 07-30-2012, 02:30 AM
Bleachlover551 Bleachlover551 is offline
Soul Reaper
Bleachlover551's Avatar
Join Date: Jul 2012
Location: Brunswick
Posts: 34
Bleachlover551 is an unknown quantity at this point
Agreed ^,^
Reply With Quote
  #19  
Old 07-30-2012, 11:37 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Do regular backups and limit write rights off (npcserver). Problem solved.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #20  
Old 08-02-2012, 07:34 PM
Bleachlover551 Bleachlover551 is offline
Soul Reaper
Bleachlover551's Avatar
Join Date: Jul 2012
Location: Brunswick
Posts: 34
Bleachlover551 is an unknown quantity at this point
Oh i get it lol (the truth is obvisous lol) i spelt that wrong >.<
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 02:28 AM.


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