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 08-13-2007, 05:42 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Calling upon the scripting community yet again!

Hello, I need your guys help again. If your REALLY GOOD with scripting serverside, I majorly need your help. I have a class and with functions that are clientside only but I need the class to to be shown to all players. Forum PM if you think you can help.
__________________
Deep into the Darkness peering...
Reply With Quote
  #2  
Old 08-13-2007, 05:50 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
What do you mean "shown" to all players?
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #3  
Old 08-13-2007, 06:22 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
well, it uses the commands like setZoomEffect etc which can only be used in client. My scripting knowledge of serverside is quite limited. :[
__________________
Deep into the Darkness peering...
Reply With Quote
  #4  
Old 08-13-2007, 06:23 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Classes aren't objects so you can't "show" them. If you are talking about local npcs (a npc made with putnpc2) then you should say local npc. Classes are just blocks of text that you append to scripts.

If you are talking about a local npc, I don't understand. Why would the npc not show to everyone?

EDIT:
Oh, on the serverside just do like:
this.attr[1] = thezoomyouwant;

Then on clientside you can do
setZoomEffect(this.attr[1]);
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 08-13-2007, 06:24 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
right in local NPC I join them to this class this I make the class an object (using thiso.var and so on) and it doesnt show to everyone becuase a player can push/pull/explode it which only shows in there client but I want evryone to see it.
__________________
Deep into the Darkness peering...
Reply With Quote
  #6  
Old 08-13-2007, 06:24 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Just set things like setZoomeffect on the clientside and it will show for everyone on their clientside.
Maybe post the script and explain exactly what you're trying to do?
Reply With Quote
  #7  
Old 08-13-2007, 06:32 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Well, there's probably many ways to optimize this script so please tell me how CONSTRUCTIVELY but here's the script, it's a basic bomb plant.

Note: I'm am not handing out this script to others servers. If you can learn from it, good, do so. BUT DO NOT STEAL IT!

sorry for all the rude legal stuff guys but I really love this script and dont want it be stolen.

PHP Code:
// Scripted by Jex Varia for the Server Varia
//#CLIENTSIDE
function onCreated() {
  
hideImgsthiso.indexthiso.index+2);
  
thiso.ox thiso.x;
  
thiso.oy thiso.y;
  
thiso.setImgPart"varia_bombplant.png"0016*216*2);
  
thiso.canBePushed();
  
thiso.canBePulled();
  
thiso.setShape13232);
  
thiso.blockAgain();
}

public function 
onStartBoom() {
  if (
thiso.boom == 0)
  {
    
thiso.boom 1;

    
sleep3);

    for ( 
thiso.0thiso.5thiso.m++)
    {
      
thiso.setImgPart"varia_bombplant.png"16*2016*216*2);
      
sleep0.1);
      
thiso.setImgPart"varia_bombplant.png"16*4016*216*2);
      
sleep0.1);
      
thiso.setImgPart"varia_bombplant.png"0016*216*2);
      
sleep0.1);
      
thiso.setImgPart"varia_bombplant.png"16*2016*216*2);
      
sleep0.1);
      
thiso.setImgPart"varia_bombplant.png"0016*216*2);
      
sleep0.1);
    }

    
onStartQBoom();
  }
}


public function 
onStartQBoom() {
  
Flame();
  
onTimeout();
  
sleep0.01);
  
thiso.setColorEffect1110.01);
  
play"bomb.wav");
  
sleep0.01);
  
play"bomb.wav");
  
sleep0.01);
  
play"bomb.wav");
  
thiso.gx = { -2, -2, -200, +2, +2, +2};
  
thiso.gy = { -20, +2, -2, +2, -20, +2};

  for ( 
0thiso.gx.size(); i++)
  {
    
triggeractionthiso.thiso.gxi], thiso.thiso.gyi], "explode"thiso.xthiso.y4);
  }
  
  
sleep0.2);
  
play"spell_fire");
  
sleep2.77);
  
hideImgsthiso.indexthis.index+2);
  
thiso.hide();
  
thiso.setColorEffect1111);
  
setTimer0);
  
sleeprandom48));
  
ReGrow();
}

function 
ReGrow() {
  
thiso.thiso.ox;
  
thiso.thiso.oy;
  
thiso.show();
  
thiso.zoom 0;

  for ( 
thiso.0thiso.9.5thiso.j++)
  {
    
thiso.setZoomEffectthiso.zoom);
    
thiso.zoom += 0.1;
    
sleep0.05);
  }

  
thiso.setZoomEffect1);

  
thiso.boom 0;

  
onCreated();
}


function 
Flame() {
  
with (findimg(thiso.index)) {
    
layer 2;
    
emitter.delaymin 0.05;
    
emitter.delaymax 0.05;
    
emitter.nrofparticles 4;
    
emitter.firstinfront false;
    
emitter.emissionoffset = { 000};

    
emitter.particle.lifetime 0.5;
    
emitter.particle.image "light2s.png";

    
emitter.particle.red 1;
    
emitter.particle.green 0;
    
emitter.particle.blue 0;
    
emitter.particle.alpha 0.99;
    
emitter.particle.zoom 0.2;
    
emitter.particle.mode 0;

    
emitter.particle.angle degToRad0);
    
emitter.particle.zangle degToRad0);
    
emitter.particle.speed 6;
    
emitter.addlocalmodifier("once"00"angle""add"2degToRad0), degToRad360));
    
emitter.addlocalmodifier("range"00.5"alpha""replace"0.990);
    
emitter.addlocalmodifier("range"00.5"zoom""replace"0.80);
    
emitter.addlocalmodifier("range"00.5"speed""replace"620);
  }

  
with (findimgthiso.index+1)) {
    
layer 0;
    
emitter.delaymin 0.05;
    
emitter.delaymax 0.05;
    
emitter.nrofparticles 2;
    
emitter.firstinfront false;
    
emitter.emissionoffset = { 000.3};

    
emitter.particle.lifetime 0.6;
    
emitter.particle.image "g4_animation_fire.gif";

    
emitter.particle.alpha 0.6;
    
emitter.particle.zoom 0.3;
    
emitter.particle.mode 2;

    
emitter.particle.angle pi 2;
    
emitter.particle.speed 6;
    
emitter.addlocalmodifier("once"00"angle""add", -0.10.1);
    
emitter.addlocalmodifier("once"00"x""add", -0.10.1);
    
emitter.addlocalmodifier("range"00.6"alpha""replace"0.60);
    
emitter.addlocalmodifier("range"00.3"zoom""replace"1.52.5);
    
emitter.addlocalmodifier("range"0.30.6"zoom""replace"0.30);
    
emitter.addlocalmodifier("range"00.6"speed""replace"610);
  }

  
with (findimg(thiso.index+2)) {
    
layer 1;
    
emitter.delaymin 0.05;
    
emitter.delaymax 0.05;
    
emitter.nrofparticles 4;
    
emitter.firstinfront false;
    
emitter.emissionoffset = { 000};

    
emitter.particle.lifetime 0.6;
    
emitter.particle.image "g4_animation_fire.gif";

    
emitter.particle.red 1;
    
emitter.particle.green 0.5;
    
emitter.particle.blue 0.5;
    
emitter.particle.alpha 0.6;
    
emitter.particle.zoom 0.2;
    
emitter.particle.mode 0// add like a light

    
emitter.particle.angle pi 2;
    
emitter.particle.speed 6;
    
emitter.addlocalmodifier("once"00"angle""add", -0.10.1);
    
emitter.addlocalmodifier("once"00"x""add", -0.050.05);
    
emitter.addlocalmodifier("range"00.6"alpha""replace"0.60);
    
emitter.addlocalmodifier("range"00.3"zoom""replace"12);
    
emitter.addlocalmodifier("range"0.30.6"zoom""replace"0.20);
    
emitter.addlocalmodifier("range"00.6"speed""replace"610);
  }

}

function 
onActionPulled()
onStartBoom();

function 
onActionPushed()
onStartBoom();

function 
onWa****() {
  
thiso.boom 1;
  
onStartQBoom();
}

function 
onActionExplode() {
  if ( 
thiso.boom == 0)
  {
    
thiso.boom 1;
    
onStartQBoom();
  }
}

function 
onTimeout() {
  if ( 
player.x in thiso.1thiso.3| &&
       
player.y in thiso.1thiso.3|) {
    
triggerServer"weapon""-PlayerControl""Fire");
  }
  
  
setTimer0.01);

__________________
Deep into the Darkness peering...
Reply With Quote
  #8  
Old 08-13-2007, 09:23 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Pretty creative script you have there, good job .
What you will want to do is like I said, use this.attr[i]'s to share various things with all clients. Have the control be serverside to control when it does what things (like changing modes to QBoom or so) and everytime the time interval has passed serverside, just use an attr (like attr[1]) as a "command" for all clients.

Then on the clientside just have a constant 0.05 timeout loop that checks what your attr (in this case attr[1]) is currently at and setting things accordingly to that.

Get it?
__________________
Do it with a DON!
Reply With Quote
  #9  
Old 08-13-2007, 09:38 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
ah, thanks, I forgot you could pass attr through server to clients XD Thanks Zero.
__________________
Deep into the Darkness peering...
Reply With Quote
  #10  
Old 08-13-2007, 02:32 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Angel_Light View Post
ah, thanks, I forgot you could pass attr through server to clients XD Thanks Zero.
Not a problem. It's pretty much the only good way other then using save[] but that is so depreciated by now.
__________________
Do it with a DON!
Reply With Quote
  #11  
Old 08-13-2007, 06:03 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Now how about those ethernet Wii pictures?
__________________
Reply With Quote
  #12  
Old 08-13-2007, 06:24 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
wrong forum and I'll get them as soon I can find my digital camera, which is lost in a vortex in my room.
__________________
Deep into the Darkness peering...
Reply With Quote
  #13  
Old 08-13-2007, 06:36 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
By the way, functions and static variables (built-in) don't require you to use this. before them.

And if you wanted anyways you should be using this. in the onCreated() part not thiso. because that is only for using inside the with (Object) {}
__________________
Reply With Quote
  #14  
Old 08-13-2007, 06:36 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Like a Bag of Holding or a Portable Hole?
__________________
Do it with a DON!
Reply With Quote
  #15  
Old 08-13-2007, 07:12 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by Inverness View Post
By the way, functions and static variables (built-in) don't require you to use this. before them.

And if you wanted anyways you should be using this. in the onCreated() part not thiso. because that is only for using inside the with (Object) {}
they dont appear correctly or the script doesnt run properly without the thiso.
__________________
Deep into the Darkness peering...
Reply With Quote
  #16  
Old 08-13-2007, 08:20 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Angel_Light View Post
they dont appear correctly or the script doesnt run properly without the thiso.
Then you obviously have a problem somewhere else that you need to fix instead of avoiding.
__________________
Reply With Quote
  #17  
Old 08-13-2007, 08:24 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
If you're joined with an object, I believe you need to use thiso to get the variables from the original object. Then again, I'm not that sure about it.
Reply With Quote
  #18  
Old 08-13-2007, 09:47 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
right I have multiple NPCS joined to this class in a single level. They all act as one not individuals without the thiso.
__________________
Deep into the Darkness peering...
Reply With Quote
  #19  
Old 08-13-2007, 11:48 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
When you join a class to an object, the object simply inherits the functions in that class. There is no separate objects created from the use of join. So I don't see how you would need to use thiso. just because you have joined a class (Sorry, can't read your script right now).
__________________
Do it with a DON!
Reply With Quote
  #20  
Old 08-14-2007, 02:34 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
gah, I can't get it, I suck. Serverside is too hard. T-T
__________________
Deep into the Darkness peering...
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 06:22 PM.


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