PDA

View Full Version : Calling upon the scripting community yet again!


Angel_Light
08-13-2007, 05:42 AM
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.

coreys
08-13-2007, 05:50 AM
What do you mean "shown" to all players?

Angel_Light
08-13-2007, 06:22 AM
well, it uses the commands like setZoomEffect etc which can only be used in client. My scripting knowledge of serverside is quite limited. :[

zokemon
08-13-2007, 06:23 AM
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]);

Angel_Light
08-13-2007, 06:24 AM
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.

DustyPorViva
08-13-2007, 06:24 AM
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?

Angel_Light
08-13-2007, 06:32 AM
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.


// Scripted by Jex Varia for the Server Varia
//#CLIENTSIDE
function onCreated() {
hideImgs( thiso.index, thiso.index+2);
thiso.ox = thiso.x;
thiso.oy = thiso.y;
thiso.setImgPart( "varia_bombplant.png", 0, 0, 16*2, 16*2);
thiso.canBePushed();
thiso.canBePulled();
thiso.setShape( 1, 32, 32);
thiso.blockAgain();
}

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

sleep( 3);

for ( thiso.m = 0; thiso.m < 5; thiso.m++)
{
thiso.setImgPart( "varia_bombplant.png", 16*2, 0, 16*2, 16*2);
sleep( 0.1);
thiso.setImgPart( "varia_bombplant.png", 16*4, 0, 16*2, 16*2);
sleep( 0.1);
thiso.setImgPart( "varia_bombplant.png", 0, 0, 16*2, 16*2);
sleep( 0.1);
thiso.setImgPart( "varia_bombplant.png", 16*2, 0, 16*2, 16*2);
sleep( 0.1);
thiso.setImgPart( "varia_bombplant.png", 0, 0, 16*2, 16*2);
sleep( 0.1);
}

onStartQBoom();
}
}


public function onStartQBoom() {
Flame();
onTimeout();
sleep( 0.01);
thiso.setColorEffect( 1, 1, 1, 0.01);
play( "bomb.wav");
sleep( 0.01);
play( "bomb.wav");
sleep( 0.01);
play( "bomb.wav");
thiso.gx = { -2, -2, -2, 0, 0, +2, +2, +2};
thiso.gy = { -2, 0, +2, -2, +2, -2, 0, +2};

for ( i = 0; i < thiso.gx.size(); i++)
{
triggeraction( thiso.x + thiso.gx[ i], thiso.y + thiso.gy[ i], "explode", thiso.x, thiso.y, 4);
}

sleep( 0.2);
play( "spell_fire");
sleep( 2.77);
hideImgs( thiso.index, this.index+2);
thiso.hide();
thiso.setColorEffect( 1, 1, 1, 1);
setTimer( 0);
sleep( random( 4, 8));
ReGrow();
}

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

for ( thiso.j = 0; thiso.j < 9.5; thiso.j++)
{
thiso.setZoomEffect( thiso.zoom);
thiso.zoom += 0.1;
sleep( 0.05);
}

thiso.setZoomEffect( 1);

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 = { 0, 0, 0};

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 = degToRad( 0);
emitter.particle.zangle = degToRad( 0);
emitter.particle.speed = 6;
emitter.addlocalmodifier("once", 0, 0, "angle", "add", 2* degToRad( 0), degToRad( 360));
emitter.addlocalmodifier("range", 0, 0.5, "alpha", "replace", 0.99, 0);
emitter.addlocalmodifier("range", 0, 0.5, "zoom", "replace", 0.8, 0);
emitter.addlocalmodifier("range", 0, 0.5, "speed", "replace", 6, 20);
}

with (findimg( thiso.index+1)) {
layer = 0;
emitter.delaymin = 0.05;
emitter.delaymax = 0.05;
emitter.nrofparticles = 2;
emitter.firstinfront = false;
emitter.emissionoffset = { 0, 0, 0.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", 0, 0, "angle", "add", -0.1, 0.1);
emitter.addlocalmodifier("once", 0, 0, "x", "add", -0.1, 0.1);
emitter.addlocalmodifier("range", 0, 0.6, "alpha", "replace", 0.6, 0);
emitter.addlocalmodifier("range", 0, 0.3, "zoom", "replace", 1.5, 2.5);
emitter.addlocalmodifier("range", 0.3, 0.6, "zoom", "replace", 0.3, 0);
emitter.addlocalmodifier("range", 0, 0.6, "speed", "replace", 6, 10);
}

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

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", 0, 0, "angle", "add", -0.1, 0.1);
emitter.addlocalmodifier("once", 0, 0, "x", "add", -0.05, 0.05);
emitter.addlocalmodifier("range", 0, 0.6, "alpha", "replace", 0.6, 0);
emitter.addlocalmodifier("range", 0, 0.3, "zoom", "replace", 1, 2);
emitter.addlocalmodifier("range", 0.3, 0.6, "zoom", "replace", 0.2, 0);
emitter.addlocalmodifier("range", 0, 0.6, "speed", "replace", 6, 10);
}

}

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.x - 1, thiso.x + 3| &&
player.y in | thiso.y - 1, thiso.y + 3|) {
triggerServer( "weapon", "-PlayerControl", "Fire");
}

setTimer( 0.01);
}

zokemon
08-13-2007, 09:23 AM
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?

Angel_Light
08-13-2007, 09:38 AM
ah, thanks, I forgot you could pass attr through server to clients XD Thanks Zero. ^^

zokemon
08-13-2007, 02:32 PM
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.

Googi
08-13-2007, 06:03 PM
Now how about those ethernet Wii pictures?

Angel_Light
08-13-2007, 06:24 PM
wrong forum and I'll get them as soon I can find my digital camera, which is lost in a vortex in my room.

Inverness
08-13-2007, 06:36 PM
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) {}

zokemon
08-13-2007, 06:36 PM
Like a Bag of Holding or a Portable Hole?

Angel_Light
08-13-2007, 07:12 PM
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.

Inverness
08-13-2007, 08:20 PM
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.

DustyPorViva
08-13-2007, 08:24 PM
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.

Angel_Light
08-13-2007, 09:47 PM
right I have multiple NPCS joined to this class in a single level. They all act as one not individuals without the thiso.

zokemon
08-13-2007, 11:48 PM
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).

Angel_Light
08-14-2007, 02:34 AM
gah, I can't get it, I suck. Serverside is too hard. T-T