FOnline Development > 3D Development

Scripting: Need help

(1/2) > >>

Karpov:
Hello. I've been trying to make those death animations work right, but all I could do was making my own character play them.
  I'll show you that chunk of code. Someone should know more than I do about this stuff.


--- Code: ---                         if(not isKo && anim2 == ANIM2_3D_DEAD_PRONE_FRONT) cr.Animate(0, ANIM2_3D_KNOCK_FRONT);
if(not isKo && anim2 == ANIM2_3D_DEAD_PRONE_BACK) cr.Animate(0, ANIM2_3D_KNOCK_BACK);
                                        if (cr.Stat[ST_GENDER] == 0) RunServerScriptUnsafe("debug@unsafe_specialdeath",0,293,0,null,null);
                                        if (cr.Stat[ST_GENDER] == 1) RunServerScriptUnsafe("debug@unsafe_specialdeath",0,296,0,null,null);
if(not isKo && cr.Stat[ST_GENDER] == 0 && anim2 == ANIM2_3D_DEAD_LASER) PlaySound("HMXXXXBI.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 1 && anim2 == ANIM2_3D_DEAD_LASER) PlaySound("HFXXXXBI.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 0 && anim2 == ANIM2_3D_DEAD_FUSED) PlaySound("HMXXXXBM.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 1 && anim2 == ANIM2_3D_DEAD_FUSED) PlaySound("HFXXXXBM.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 0 && anim2 == ANIM2_3D_DEAD_BURST) PlaySound("HMXXXXBG.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 1 && anim2 == ANIM2_3D_DEAD_BURST) PlaySound("HFXXXXBG.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 0 && anim2 == ANIM2_3D_DEAD_BLOODY_SINGLE) PlaySound("HMXXXXBD.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 1 && anim2 == ANIM2_3D_DEAD_BLOODY_SINGLE) PlaySound("HFXXXXBD.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 0 && anim2 == ANIM2_3D_DEAD_BLOODY_BURST) PlaySound("HMXXXXBF.ACM");
if(not isKo && cr.Stat[ST_GENDER] == 1 && anim2 == ANIM2_3D_DEAD_BLOODY_BURST) PlaySound("HFXXXXBF.ACM");
cr.Animate(0, anim2, item);
                                        cr.Animate(0, anim2, item);
--- End code ---

This is the line I need to change.


--- Code: ---if (cr.Stat[ST_GENDER] == 0) RunServerScriptUnsafe("debug@unsafe_specialdeath",0,293,0,null,null);
--- End code ---

It says that if the critter's gender is male, then run that script called unsafe_specialdeath with parameter 1 set to 293. Then that  other script has only this line:


--- Code: ---player.ChangeCrType(param1)
--- End code ---

What I need to do is this.


--- Code: ---if (cr.Stat[ST_GENDER] == 0) cr.ChangeCrType(293)
--- End code ---

Change the critter type directly from the main script. But somehow this does not work, and I get a script initialization error when starting the game.

What's wrong? why does this function work in the other script but not in this one?  ???
You can download it and work on the script. If you get it working let me know. ;)

Thanks for reading.

PS: just realised how many lines there are for playing sounds :D.

JovankaB:
ChangeCrType() is part of Critter class not CritterCl class.

Critter is for server modules.
CritterCl is for client modules.

Server modules run on FOnline server. Client modules run in FOnline client on player computer.
You can't use Critter class in client modules. It's available only on server.

That's why RunServerScriptUnsafe is called, because many things with critters only server can do.

Karpov:
Thanks Jovanka, I understand. I'm trying to change a parameter in another critter from my client, which is of course, not permitted.
 So I have to use a server side script instead? I'll try to find some place where I can call that function, let's hope I don't mess it up.

Thanks again.

Edit: Do you know if there is any way to make this value to be the critter id?

if (cr.Stat[ST_GENDER] == 1) RunServerScriptUnsafe("debug@unsafe_specialdeath",0,296,0,null,null);

JovankaB:
yes if you want client to cause server to do something, then you must RunServerScriptUnsafe
it runs a function from server module: "debug@unsafe_specialdeat" - debug is module, unsafe_... is function

...if I remember correctly...

maybe someone else can explain it in more details I dont really like AS and avoid it...

Karpov:
It finally works, thanks a lot!
I'm running the unsafe script, only that I made it point to the right critter instead of myself, copy/paste from other command that was already there.
Check it out. www.youtube.com/watch?v=RIij8ii6Qhw

 ;)

Navigation

[0] Message Index

[#] Next page

Go to full version