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 02-06-2006, 05:16 PM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Online player search

Hey there, I'm a good scripter, but I've done next to nothing of online stuff. My question is, how do I go through the players in a level in a for loop? I do for (i=0;i<playerscount;i++) serverside and nothing happens, clientside and only I am affected. How do I access everyone in a level?
__________________
Reply With Quote
  #2  
Old 02-06-2006, 05:58 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Idrox0
Hey there, I'm a good scripter, but I've done next to nothing of online stuff. My question is, how do I go through the players in a level in a for loop? I do for (i=0;i<playerscount;i++) serverside and nothing happens, clientside and only I am affected. How do I access everyone in a level?
This'll need to be done serverside.

In old gscript, it'll be something like this:
PHP Code:
for (0playerscount++)
{
  
with (players[i])
  {
    
// Now in the focus of the player
    
setplayerprop #c,Hello!;
  
}

Just for reference, in gscript2, the improved for () allows you to cycle straight through the players array, like so:
PHP Code:
for (plplayers)
{
  
// Now, pl will be the player's object, i.e.
  
pl.chat "Hello!";

__________________
Skyld
Reply With Quote
  #3  
Old 02-07-2006, 12:34 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Hmm... so say I wanted to make a weapon that searched through the room and killed everyone in it, it would be done like so?
PHP Code:
if ( weaponfired ) {
  for ( 
0playerscounti++ ) {
    
players[i].hearts 0;
  }

Pardon the odd (I'm sure) spacing methods; it seems UnrealScript has rubbed off a bit on me.
__________________

Last edited by Idrox0; 02-07-2006 at 12:35 AM.. Reason: Saving space with PHP tag
Reply With Quote
  #4  
Old 02-07-2006, 01:08 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
No it needs to be done serverside.

PHP Code:
if (actionserverside) { // receives the triggeraction
  
if (strequals(#p(0),params)) { // #p(x) are the params
// the above line was not needed but i just added it in for demo
    
for(i=0i<playerscounti++) {  // loops through everyone in the room
      
with(players[i]) {  // tells the npc which player to perform the actions on
        
playerhearts 0;
      }
    }
  }
}
//#CLIENTSIDE
if (weaponfired) {
  
triggeraction 0,0,serverside,WEAPONNAME,params;

__________________
Reply With Quote
  #5  
Old 02-07-2006, 01:12 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Aha! I was wondering how a server would recieve a weaponfired flag. Thanks!
__________________
Reply With Quote
  #6  
Old 02-07-2006, 06:25 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
For future reference, players[i].hearts should work also (meaning you don't need the with() statement)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 02-07-2006, 07:51 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by ApothiX
For future reference, players[i].hearts should work also (meaning you don't need the with() statement)
True.
__________________
Reply With Quote
  #8  
Old 02-09-2006, 01:47 AM
Idrox0 Idrox0 is offline
Registered User
Join Date: Oct 2003
Posts: 66
Idrox0 is on a distinguished road
Hmm... if a script that works suddenly doesn't work, and GS2 was recently installed onto the server, does that mean GS2 screwed it up?
__________________
Reply With Quote
  #9  
Old 02-09-2006, 02:10 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Idrox0
Hmm... if a script that works suddenly doesn't work, and GS2 was recently installed onto the server, does that mean GS2 screwed it up?
Means it was probably badly scripted or has an error in it.

The new engine's compiler is a lot more picky.
__________________
Skyld
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 05:47 PM.


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