Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   It saves but will not send... (https://forums.graalonline.com/forums/showthread.php?t=37180)

G_yoshi 09-02-2002 11:42 PM

It saves but will not send...
 
For some inane reason, I can't get triggeraction to work for a particular NPC. For testing purposes, it saved the data I wanted to send out, but it does not send...either that or the Control-NPC doesn't want to recieve the triggeraction

NPC Code:
        triggeraction 0,0,servercheck,#s(client.expinc),#s(client.lastat  tacker);



That should send it to the Control-NPC which has:

NPC Code:
if (actionservercheck) {
this.exp = #p(0);
setstring lastattacker,#p(1);
with (getplayer(#s(lastattacker)) {
setstring client.player_exp,#v(strtofloat(#s(client.player_e xp))+#p(0));
setplayerprop #c,I now have #s(client.player_exp) EXP!;
}
}


But I keep checking the extras I have it set and it doesn't set them when I check the Control-NPC...this.exp does not show up as well as lastattacker.

I've been messing with it for the past hour at least...enjoying hitting my counterpart since I need to vent anyway :)

Python523 09-03-2002 12:11 AM

try triggering to a weapon
triggeraction 0,0,serverside,-actions,#s(client.expinc),#s(client.lastattacker);
then just make the weapon -actions and put the actionserverside in there

G_yoshi 09-03-2002 12:16 AM

Quote:

Originally posted by Python523
try triggering to a weapon
triggeraction 0,0,serverside,-actions,#s(client.expinc),#s(client.lastattacker);
then just make the weapon -actions and put the actionserverside in there

I already have one weapon triggering another when you attack a player...

Hop on AIM?

Falcor 09-03-2002 12:26 AM

Re: It saves but will not send...
 
Quote:

Originally posted by G_yoshi
For some inane reason, I can't get triggeraction to work for a particular NPC. For testing purposes, it saved the data I wanted to send out, but it does not send...either that or the Control-NPC doesn't want to recieve the triggeraction

NPC Code:
        triggeraction 0,0,servercheck,#s(client.expinc),#s(client.lastat  tacker);



That should send it to the Control-NPC which has:

NPC Code:
if (actionservercheck) {
this.exp = #p(0);
setstring lastattacker,#p(1);
with (getplayer(#s(lastattacker)) {
setstring client.player_exp,#v(strtofloat(#s(client.player_e xp))+#p(0));
setplayerprop #c,I now have #s(client.player_exp) EXP!;
}
}


But I keep checking the extras I have it set and it doesn't set them when I check the Control-NPC...this.exp does not show up as well as lastattacker.

I've been messing with it for the past hour at least...enjoying hitting my counterpart since I need to vent anyway :)

1) Parameters are sent as strings. (this.exp=#p(0) doesn't work, you are trying to store a string in a variable)
2) lastattacker isnt saved on the control NPC, however with a THIS. prefix...... (this.lastattacker)

These are pretty stupid mistakes I must say =\

G_yoshi 09-03-2002 12:36 AM

Re: Re: It saves but will not send...
 
Quote:

Originally posted by Falcor


1) Parameters are sent as strings. (this.exp=#p(0) doesn't work, you are trying to store a string in a variable)
2) lastattacker isnt saved on the control NPC, however with a THIS. prefix...... (this.lastattacker)

These are pretty stupid mistakes I must say =\

Sorry :/ I was trying to save it as a string to the control-NPC since variables are variables, not text :p

Doesn't matter anyway, still not sending...

Falcor 09-03-2002 12:41 AM

NPC Code:

if (actionservercheck) {
this.exp = #p(0); //should be this.exp = strtofloat(#p(0))
setstring lastattacker,#p(1); //should be this.lastattacker
with (getplayer(#s(this.lastattacker))) {
setstring client.player_exp,#v(strtofloat(#s(client.player_e xp)) +this.exp);
setplayerprop #c,I now have #s(client.player_exp) EXP!;
}
}



does this work at all? I havn't tested it but It should, unless I missed yet another bug.

G_yoshi 09-03-2002 12:56 AM

Quote:

Originally posted by Falcor
NPC Code:

if (actionservercheck) {
this.exp = #p(0); //should be this.exp = strtofloat(#p(0))
setstring lastattacker,#p(1); //should be this.lastattacker
with (getplayer(#s(this.lastattacker))) {
setstring client.player_exp,#v(strtofloat(#s(client.player_e xp)) +this.exp);
setplayerprop #c,I now have #s(client.player_exp) EXP!;
}
}



does this work at all? I havn't tested it but It should, unless I missed yet another bug.

WTF?!?!?!?! I changed that pie NPCW you had me create to trigger actionservercheck and everything went through...must be something in -Triggers...not sure what though :/

G_yoshi 09-03-2002 03:30 AM

I still cannot get it to send triggeraction to the control-NPC :/

NPC Code:
if (actionswordhit && !strtofloat(#p(1))==playerid) {
setarray this.attack,5;
setstring client.lastattacker,#p(2);
setstring client.lastexp,#p(3);
this.attack[0] = int(strtofloat(#p(0))%255);
this.attack[1] = int(strtofloat(#s(client.def))%255);
this.attack[2] = abs(this.attack[0]-this.attack[1]);
this.attack[3] = abs(int(random((this.attack[2]/15),this.attack[2])));
this.attack[4] = int(random(0,2));
if (!this.attack[4]==1) {
showimg 1,@FixedSys@MISS,playerx,playery+2;
showimg 2,@FixedSys@MISS,playerx+.1,playery+2+.1;
changeimgcolors 2,0,0,0,0;
//changeimgcolors 1,1,.34,.34,1;
changeimgvis 1,2;
changeimgvis 2,1;
sleep .25;
hideimg 1;
hideimg 2;
} else {
setani hurt,;
hurt 0;
showimg 1,@FixedSys@#v(this.attack[3]),playerx,playery+2;
showimg 2,@FixedSys@#v(this.attack[3]),playerx+.1,playery+2+.1;
changeimgcolors 2,0,0,0,0;
//changeimgcolors 1,1,.34,.34,1;
changeimgvis 1,2;
changeimgvis 2,1;
setstring client.player_hp,#v(strtofloat(#s(client.player_hp ))-this.attack[3]);
if (strtofloat(#s(client.player_hp))<=0) {
this.expinc = strtofloat(#s(client.player_exp))/8+int(random(4,10));
triggeraction 0,0,servercheck,#v(this.expinc),#s(client.lastatta cker);
setstring client.player_hp,0;
setplayerprop #c,Dead!;
sleep .1;
playerhearts = 0;
}
else {
playerhearts = 3;
}
sleep .25;
hideimg 1;
hideimg 2;
}
}



That is the entire section which basically controls player damage. I'm pretty sure its not as clean as what it could or should be, but complain about something else :/

G_yoshi 09-03-2002 03:33 AM

Quote:

Originally posted by Kaimetsu
It's also pretty darn insecure. The experience increase is calculated on the client?
I'll worry about that once I get it to send the triggered action.

G_yoshi 09-03-2002 03:37 AM

Quote:

Originally posted by Kaimetsu
Ack! Argh! Damage is also calculated on the client?!?!
You really have the intent of beating this into the ground :/

*edit*
Apparently, I can't call another triggeraction after just doing one...

Falcor 09-03-2002 04:48 AM

Quote:

Originally posted by G_yoshi

You really have the intent of beating this into the ground :/

Important calculations should be handle by the server to make it hack-proof, thats all he's trying to say... Am I to assume you don't see the logic in that?

G_yoshi 09-05-2002 01:52 PM

Quote:

Originally posted by Falcor


Important calculations should be handle by the server to make it hack-proof, thats all he's trying to say... Am I to assume you don't see the logic in that?

I see the logic :p

Sorry, I'm just too focused on getting from point A to point B :(

Anyway, I do now have the server handling it, but here's the problem I've found...if I do triggeraction to the player with params, it won't let me send those params if I've saved them to strings through another triggeraction to the Control-NPC...I checked. I can, however, send out 2 triggeractions to both player and the Control-NPC; problem there is things collide and cause problems from that point as well.

So I'm kind of stuck now...I was trying to do with (players[<vars>]) {...} inside a for loop to check for a string, but it wouldn't do it.

Any suggestions on how to get this working because it is vital to the RPing environment :/

emortylone 09-06-2002 04:09 AM

x.X I'm not even sure what is going ON anymore! Originally you were trying to save a NON variable to a this.var instead of a string. Then you changed it x.X
---Shifter

G_yoshi 09-10-2002 01:53 PM

Quote:

Originally posted by emortylone
x.X I'm not even sure what is going ON anymore! Originally you were trying to save a NON variable to a this.var instead of a string. Then you changed it x.X
---Shifter

Um, when saving stuff on the Control-NPC as far as strings and variables go...you have to use this.<vars/string>. 'setstring this.string' makes it a local string for the Control-NPC that only it can play with or for any other db NPC you have :p


All times are GMT +2. The time now is 02:12 PM.

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