Author Topic: Scripting: Need help  (Read 5488 times)

Offline Karpov

  • Moderator
  • Come Together
Scripting: Need help
« on: June 04, 2012, 06:15:59 pm »
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: [Select]
                        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);

This is the line I need to change.

Code: [Select]
if (cr.Stat[ST_GENDER] == 0) RunServerScriptUnsafe("debug@unsafe_specialdeath",0,293,0,null,null);
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: [Select]
player.ChangeCrType(param1)
What I need to do is this.

Code: [Select]
if (cr.Stat[ST_GENDER] == 0) cr.ChangeCrType(293)
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.
« Last Edit: June 04, 2012, 06:18:32 pm by Karpov »

JovankaB

  • Guest
Re: Scripting: Need help
« Reply #1 on: June 04, 2012, 06:35:42 pm »
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.
« Last Edit: June 04, 2012, 06:47:58 pm by JovankaB »

Offline Karpov

  • Moderator
  • Come Together
Re: Scripting: Need help
« Reply #2 on: June 04, 2012, 08:17:19 pm »
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);
« Last Edit: June 04, 2012, 08:27:02 pm by Karpov »

JovankaB

  • Guest
Re: Scripting: Need help
« Reply #3 on: June 04, 2012, 08:25:30 pm »
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...
« Last Edit: June 04, 2012, 08:27:58 pm by JovankaB »

Offline Karpov

  • Moderator
  • Come Together
Re: Scripting: Need help
« Reply #4 on: June 04, 2012, 08:58:39 pm »
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

 ;)

Offline Luther Blissett

  • Moderator
Re: Scripting: Need help
« Reply #5 on: June 05, 2012, 04:23:17 pm »
That's excellent.

Re: Scripting: Need help
« Reply #6 on: June 07, 2012, 05:14:40 pm »
Looks like fo tactics :D For me it is too smoothy, i mean animation ;)

Let the Force be with You.