PDA

View Full Version : Archetypes with Gani Script


Angel_Light
06-02-2007, 05:50 AM
I have a gani script and I'm trying to load archetype variables. But it doesn't work.


SCRIPT
function onCreated() {
this.baddyname = "Default";
getBaddy();
onTimeOut();
}

function getBaddy() {
this.baddy.loadVars(
format("archetypes/baddies/%s.arc", this.baddyname));
}

function onTimeOut() {
showtext( this.index, this.x+2, this.y+3,"Verdana", "c",
this.baddy.nick);
showtext( this.index+1, this.x+2, this.y,"Verdana", "c",
this.baddy.hp @ "/" @ this.baddy.fullhp);

changeimgzoom( this.index, 0.75);
changeimgzoom( this.index+1, 0.75);

if (this.baddy.hp > this.baddy.hp/3)
changeimgcolors( this.index+1, 0, 1, 0, 0.99);
if (this.baddy.hp < this.baddy.hp/3)
changeimgcolors( this.index+1, 1, 1, 0, 0.99);
if (this.baddy.hp < this.baddy.hp/6)
changeimgcolors( this.index+1, 1, 0, 0, 0.99);

if (this.baddy.aggressor == 0) changeimgcolors( this.index, 0, 1, 1, 0.99);
if (this.baddy.aggressor == 1) changeimgcolors( this.index, 1, 1, 0, 0.99);
if (this.baddy.aggressor == 2) changeimgcolors( this.index, 1, 0, 0, 0.99);

setTimer(0.05);
}
SCRIPTEND

Inverness
06-02-2007, 06:23 AM
I don't work with ganis often, but I believe they're clientside? x.x

Angel_Light
06-02-2007, 06:30 AM
I don't work with ganis often, but I believe they're clientside? x.x

Tried, also if so how would I load the vars.

Inverness
06-02-2007, 06:41 AM
Tried, also if so how would I load the vars.Uh, they're automatically clientside even without the //#CLIENTSIDE thingy in the script. You would need to use player attributes or gani params I believe. Like I said, don't work with ganis often.

Novo
06-02-2007, 11:25 AM
You can't load serverside variables clientside... You can't display clientside showimg's serverside.

When you create the object (gani), leave 0.05 seconds for the attributes / params to work.

killerogue
06-02-2007, 11:31 AM
Since you can't load serverside vars clientside, I'd suggest making a frame class then using a function that uses with() on a putnpc2 to set the baddy name an any other variables prior to it's creation.

Also another serverside function for getting the baddy information would be good. Public is preferable.

Inverness
06-02-2007, 04:33 PM
You could use this script for calling serverside functions from the gani, I haven't tested it with ganis, but it is an object so it should work the same.
You would need to use serverFunction() since the second one doesn't wait for a return. Recommend placing this script in a weapon called System or something, it looks the coolest like that.

public function waitForNotify(obj, action, time) {
return waitfor(obj, "Notify" @ action, time);
}
public function notifyClient(obj, ename, time) {
triggerClient("gui", name, "notify", obj, ename, time);
}
public function notifyServer(obj, ename, time) {
scheduleEvent(0, "ActionServerSide", obj, ename, time);
}
public function clientFunction(fobj, fname, fparams) {
temp.out = 0;

client.temp.(@ "clientfunction_" @ fname) = null;
triggerClient("gui", name, "clientfunction", fname, fparams, fobj);
waitForNotify(name, "ClientFunctionEnd", 5);
out = client.temp.(@ "clientfunction_" @ fname);
client.temp.(@ "clientfunction_" @ fname) = null;
return out;
}
public function clientFunction2(fobj, fname, fparams) {
triggerClient("gui", name, "clientfunction", fname, fparams, fobj);
}
function onActionServerSide() {
switch (params[0]) {
case "notify":
makevar(params[1]).scheduleEvent(params[3], "Notify" @ params[2], null);
break;
case "serverfunction":
temp.r = 0;
temp.fn = params[1];

if (params[3] != null)
r = makevar(params[3] @ "." @ params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
else
r = makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
client.temp.(@ "serverfunction_" @ fn) = r;
notifyClient(name, "ServerFunctionEnd", 0);
break;
case "serverfunction2":
if (params[3] != null)
r = makevar(params[3] @ "." @ params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
else
r = makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
break;
}
}
//#CLIENTSIDE
function onActionClientSide() {
switch (params[0]) {
case "notify":
makevar(params[1]).scheduleEvent(params[3], "Notify" @ params[2], null);
break;
case "clientfunction":
temp.r = 0;
temp.fn = params[1];

if (params[3] != null)
r = makevar(params[3] @ "." @ params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
else
r = makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
client.temp.(@ "clientfunction_" @ fn) = r;
notifyServer(name, "ClientFunctionEnd", 0);
break;
case "clientfunction2":
if (params[3] != null)
r = makevar(params[3] @ "." @ params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
else
r = makevar(params[1])(params[2][0], params[2][1], params[2][2], params[2][3], params[2][4], params[2][5]);
}
}
public function waitForNotify(obj, action, time) {
return waitfor(obj, "Notify" @ action, time);
}
public function notifyServer(obj, ename, time) {
triggerServer("gui", name, "notify", obj, ename, time);
}
public function notifyClient(obj, ename, time) {
scheduleEvent(0, "ActionClientSide", "notify", obj, ename, time);
}
public function serverFunction(fobj, fname, fparams) {
temp.out = 0;

client.temp.(@ "serverfunction_" @ fname) = null;
triggerServer("gui", name, "serverfunction", fname, fparams, fobj);
waitForNotify(name, "ServerFunctionEnd", 5);
out = client.temp.(@ "serverfunction_" @ fname);
client.temp.(@ "serverfunction_" @ fname) = null;
return out;
}
public function serverFunction2(fobj, fname, fparams) {
triggerServer("gui", name, "serverfunction2", fname, fparams, fobj);
}

Angel_Light
06-02-2007, 05:57 PM
i tried it with params and with attr, and I had no luck here's what I did both times.

params try:

in the class part:

setcharani( "nir_baddy_idle", this.baddy.nick,
this.baddy.hp, this.baddy.fullhp,
this.baddy.aggressor);


In the gani this:

SCRIPT
function onCreated() onTimeOut();

function onTimeOut() {
showtext( this.index, this.x+2, this.y+3,"Verdana", "c",
params[0]);
showtext( this.index+1, this.x+2, this.y,"Verdana", "c",
params[1] @ "/" @ params[2]);

changeimgzoom( this.index, 0.75);
changeimgzoom( this.index+1, 0.75);

if (params[1] > params[1]/3)
changeimgcolors( this.index+1, 0, 1, 0, 0.99);
if (params[1] < params[1]/3)
changeimgcolors( this.index+1, 1, 1, 0, 0.99);
if (params[1] < params[1]/6)
changeimgcolors( this.index+1, 1, 0, 0, 0.99);

if (params[3] == 0) changeimgcolors( this.index, 0, 1, 1, 0.99);
if (params[3] == 1) changeimgcolors( this.index, 1, 1, 0, 0.99);
if (params[3] == 2) changeimgcolors( this.index, 1, 0, 0, 0.99);

setTimer(0.05);
}
SCRIPTEND


in the attr try I did this

class part:

thiso.attr[1] = this.baddy.nick;
thiso.attr[2] = this.baddy.hp;
thiso.attr[3] = this.baddy.fullhp;
thiso.attr[4] = this.baddy.aggressor;


Gani:

SCRIPT
function onCreated() onTimeOut();

function onTimeOut() {
showtext( this.index, this.x+2, this.y+3,"Verdana", "c",
thiso.attr[1]);
showtext( this.index+1, this.x+2, this.y,"Verdana", "c",
thiso.attr[2] @ "/" @ thiso.attr[3]);

changeimgzoom( this.index, 0.75);
changeimgzoom( this.index+1, 0.75);

if (thiso.attr[2] > thiso.attr[2]/3)
changeimgcolors( this.index+1, 0, 1, 0, 0.99);
if (thiso.attr[2] < thiso.attr[2]/3)
changeimgcolors( this.index+1, 1, 1, 0, 0.99);
if (thiso.attr[2] < thiso.attr[2]/6)
changeimgcolors( this.index+1, 1, 0, 0, 0.99);

if (thiso.attr[4] == 0) changeimgcolors( this.index, 0, 1, 1, 0.99);
if (thiso.attr[4] == 1) changeimgcolors( this.index, 1, 1, 0, 0.99);
if (thiso.attr[4] == 2) changeimgcolors( this.index, 1, 0, 0, 0.99);

setTimer(0.05);
}
SCRIPTEND

Chompy
06-02-2007, 06:04 PM
I would use Inverness' method