Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-07-2002, 02:40 AM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Dilema...

I seem to be having a problem with my mineral mining scripts.

The NPC weapon is fine for the most part...it retrieves the player's ID and then sends it through triggeraction.

NPC Code:
//#CLIENTSIDE
// NPC made by GregoryYoshi
if (playerenters) {
setshape 1,32,32;
this.axepower = 2;
setcharprop #c,Level 1 Pickaxe;
}
if (playertouchsme) {
toweapons Pickaxe L1;
hide;
sleep 3;
show;
}

if (weaponfired) {
this.axepower = 2;
this.playerid = playerid;
freezeplayer .75;
setani jaxe,pickaxemetal.png;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+1.75+vecy(pl ayerdir)*2,mining,#v(this.axepower),#v(this.player id);
showimg 210,dk_hitpointer.png,playerx+1.5+vecx(playerdir)* 2,playery+1.75+vecy(playerdir)*2;
sleep .75;
setani idle,;
hideimg 210;
}



The problem is the mineral NPC (which is a class NPC script) is not accepting the playerid parameter sent through triggeraction

NPC Code:
if (created) {
setshape 1,32,32;
this.mined = 0;
}

if (actionmining && !this.mined==100) {
this.mined = this.mined + strtofloat(#p(0));
this.hitterid = strtofloat(#p(2));
gethitter();
setcharprop #c,#v(this.mined) | #v(this.hitter);
} else
if (actionmining && this.mined==100) {
this.hitterid = strtofloat(#p(1));
gethitter();
setimg explosion.gif;
play2 bomb.wav,x-1,y-1,1;
if (hitter>0) {
with (players[hitter]) {
freezeplayer 1;
setani dk_mined,this.type*10;
if (this.type==4) {
setstring uncraftedgold,#v(strtofloat(#s(uncraftedgold))+1);
} else if (this.type==3) {
setstring uncraftedred,#v(strtofloat(#s(uncraftedred))+1);
} else if (this.type==2) {
setstring uncraftedblue,#v(strtofloat(#s(uncraftedblue))+1);
} else if (this.type==1) {
setstring uncraftedgreen,#v(strtofloat(#s(uncraftedgreen))+1 );
}
}
}
hide;
sleep 5;
this.type = int(random(1,5);
this.mined = 0;
show;
}

function gethitter() {
hitter = -1;
for (i=0; i<playerscount; i++)
if (players[i].id==this.hitterid) {
hitter = i;
break;
}
}



Neither of these are confidentail scripts, so I don't mind showing them

There's probably something wrong that I'm doing...hopefully I can get this fixed fast
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #2  
Old 02-07-2002, 03:06 AM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
this.hitterid = strtofloat(#p(2));

u had this line in it and there is NO #p(2) it's #p(1) like u used it later if I am not totaly wrong ^_^
__________________
No Webhost at the moment
Reply With Quote
  #3  
Old 02-07-2002, 04:29 AM
TDK_RC6 TDK_RC6 is offline
Registered User
TDK_RC6's Avatar
Join Date: Jan 2002
Location: Earth
Posts: 0
TDK_RC6 is on a distinguished road
you would be correct
__________________
Staff on Renegade


email: [email protected]
aim: papivicente
Reply With Quote
  #4  
Old 02-07-2002, 11:10 AM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by TDO2000
this.hitterid = strtofloat(#p(2));

u had this line in it and there is NO #p(2) it's #p(1) like u used it later if I am not totaly wrong ^_^
triggeraction can send more than one parameter

#p(index) gets the parameters from the specified index in triggeraction.

The reason I had it #p(2) was because I was testing other indexes...even #p(1) returned a value of 0.
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #5  
Old 02-07-2002, 11:23 AM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
hmm...I take back what I said about it not returning a value for
#p(1). However, it still fails to identify the player's ID for later parts of the script.

I suppose it'll work fine if I use this.hitterid instead of hitter since the gethitter function does not seem to work like it should :/
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #6  
Old 02-07-2002, 01:35 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu
I'm gonna stop looking at scripts that contain all the irrelevant stuff in them. If you wanna post here asking about a problem then remove all the stuff that doesn't affect the problem, otherwise I have to trawl through it all looking for the parts that matter.
Sorry :/ All I asked for was some assitstance...that is the service you provide here, correct
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #7  
Old 02-07-2002, 01:56 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu


My job here is to moderate the forums, not provide unconditional help, just like it's not your job to interject into every debate in the NGR forum. And if you want my help, which I'm happy to give, then please do a little work yourself beforehand.

Hmm, would the fact that've spent nearly half an hour trying to get it to work right, count? The NPC weapon works fine, just that the class script does not...but as I said, I could probably do without that function...just there will be less security.
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #8  
Old 02-07-2002, 02:04 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu


No, my point is that you should take out all the stuff that doesn't affect the problem and post a basic script with the basic fundamentals of the problem so that I don't need to look though the frosting on the cake just to get to the thing I need to fix.
thing is, I don't know what exactly the problem is
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #9  
Old 02-07-2002, 02:10 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu


If I was working on my 3D thing and found that there was a problem with the transformation matrix, would I post the whole script and just say "Fix it"? No, I would take out the relevant parts and post those. If you can't identify what the relevant part is then you need to spend longer than half an hour.
Sorry...I figured if I posted the whole script it would help.

All I know is that:
NPC Code:
function gethitter() {
hitter = -1;
for (i=0; i<playerscount; i++)
if (players[i].id==this.hitterid) {
hitter = i;
break;
}
}


is not working for whatever reason
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #10  
Old 02-07-2002, 02:15 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu


Have you tried making it output the result via some sort of message statement or something? Just to check what it's throwing up.
Yep, I do that often when I want the value of anything I'm working on

I've made it check i...returns 0
I've made it check hitter...returns 0

The only value that returns correctly is this.hitterid
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #11  
Old 02-07-2002, 02:35 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu


Wait a second... That loop looks mighty strange.

NPC Code:
function gethitter() {
hitter = -1;
for (i=0; i<playerscount; i++)
if (players[i].id==this.hitterid) {
hitter = i;
break;
}
}



Look at the brackets. If I were you, I'd try it like this:

NPC Code:
function gethitter() {
hitter = -1;
for (i=0; i<playerscount; i++){
if (players[i].id==this.hitterid) {
hitter = i;
break;
}
}
}

Sometimes I hate myself Figures I'd miss a bracket
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #12  
Old 02-07-2002, 02:41 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Kaimetsu


Does it work now?
unfortunately, no

It still does not properly save the player's ID to the variable hitter.
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #13  
Old 02-07-2002, 02:44 PM
Frolic_RC2 Frolic_RC2 is offline
Banned
Join Date: Jan 2002
Posts: 960
Frolic_RC2 is on a distinguished road
G Yoshi, simply use the actionplayer variable.
Reply With Quote
  #14  
Old 02-07-2002, 02:45 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
If you like, you can log onto my PW and I'll warp you to the Mineral Mines so you can see it.
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #15  
Old 02-07-2002, 02:50 PM
Frolic_RC2 Frolic_RC2 is offline
Banned
Join Date: Jan 2002
Posts: 960
Frolic_RC2 is on a distinguished road
Quote:
Originally posted by GregoryYoshi
If you like, you can log onto my PW and I'll warp you to the Mineral Mines so you can see it.
Eh? Its 11:45, I am going to go to sleep soon (need to wake up at 5:00 X_X). If that was to Kaimetsu, then nevermind.
Reply With Quote
  #16  
Old 02-07-2002, 03:02 PM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Frolic_RC2
G Yoshi, simply use the actionplayer variable.
eh? *confused*

Something new to learn
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #17  
Old 02-07-2002, 09:41 PM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
Quote:
Originally posted by GregoryYoshi


triggeraction can send more than one parameter

#p(index) gets the parameters from the specified index in triggeraction.

The reason I had it #p(2) was because I was testing other indexes...even #p(1) returned a value of 0.
I know that u can use more then only one param but I thought in that case #p(2) would be wrong....
and u missed a bracket here:
NPC Code:

this.type = int(random(1,5);



and this part:
NPC Code:

setcharprop #c,#v(this.mined) | #v(this.hitter);
} else



needs another bracket too
NPC Code:

setcharprop #c,#v(this.mined) | #v(this.hitter);
} else {

__________________
No Webhost at the moment

Last edited by TDO2000; 02-07-2002 at 09:52 PM..
Reply With Quote
  #18  
Old 02-08-2002, 01:27 AM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by TDO2000


I know that u can use more then only one param but I thought in that case #p(2) would be wrong....
and u missed a bracket here:
NPC Code:

this.type = int(random(1,5);



and this part:
NPC Code:

setcharprop #c,#v(this.mined) | #v(this.hitter);
} else



needs another bracket too
NPC Code:

setcharprop #c,#v(this.mined) | #v(this.hitter);
} else {

If you look again, I did 'else if (arguments) { which is perfectly legal in GScript I just had the If statement down a line so the script would look nice

As for not closing the parenthesis...I would have caught that eventually, but thank you just the same
__________________
Zayjee uses this account now. OK?
Reply With Quote
  #19  
Old 02-08-2002, 02:14 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Well if that is the only part that returns correctly, than that must mean that there is some sort of problem in the returning process. Maybe you sould (if all else fails) try using different function/variable names, because many times I have been haing the same problem and i have found that i accidently stumbled onto a keyword (reserved). Also you could do multiple things to test it, every time you go to the nest stage of something, have it add 1 to this.breakingpoint, and wherever it stops, post that and maybe we can help more.
If you are not sure what is wrong with your script, instead of posting the entire thing without any definition, you could do something like saying, "The problem seems to be ing the hitterid area", and you could put that part of the script in bold. If you do not do this, when it is posted people get frustrated as seen here by Kaimetsu and they refuse to help. For example when i first came here, I looked for what you said was happening, since you gave no definition of what was going wrong, I ignored the script and looked at the next posts to see if they had any clue. If there was a bold part, or a bold comment line in the script that said something like "Its somewhere in here" than i would be more attracted to help. Or even tell us what IS working so we can look at what is not. Just information for future reference.
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #20  
Old 02-08-2002, 02:16 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Quote:
Originally posted by TDO2000


I know that u can use more then only one param but I thought in that case #p(2) would be wrong....
and u missed a bracket here:
NPC Code:

this.type = int(random(1,5);


When you tested that in the scrpter, didn't it say "Variables cannot contain spaces"? Thats what it has always done for me.
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #21  
Old 02-08-2002, 04:17 AM
GregoryYoshi GregoryYoshi is offline
Registered User
Join Date: Jan 2002
Location: Wherever I am right now
Posts: 227
GregoryYoshi is on a distinguished road
Send a message via AIM to GregoryYoshi Send a message via Yahoo to GregoryYoshi
Quote:
Originally posted by Saga2001


When you tested that in the scrpter, didn't it say "Variables cannot contain spaces"? Thats what it has always done for me.
Nope...simply because it stops at the with (players i) since it doesn't recognize it
__________________
Zayjee uses this account now. OK?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:50 PM.


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