Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gman's questions thread (https://forums.graalonline.com/forums/showthread.php?t=50856)

xManiamaNx 02-04-2004 02:51 AM

NPC-Servers have minds of their own :)

There will be times I'lls cript somethign and it wont work, I come back a few days later, and the exact code will work. It's really quite odd.

Stefan, does showtext work serverside?

Gman4pwnu 02-04-2004 03:28 AM

When I try to triggeraction from clientside to serverside and write the mineral count to clientr's, it does not work. I do it as I would do it with client strings.

Gman4pwnu 02-04-2004 03:40 AM

Clientr's
 
Theres something wrong with this script, when uploaded, it never adds the clientr's. It never adds +1 to the clientr's. Everytime i type Show Minerals it shows 0 0 0 0 for the clientr's. I've never used clientr's. What is wrong with the script?
NPC Code:

if (created){
setstring clientr.lead,0;
setstring clientr.silver,0;
setstring clientr.gold,0;
setstring clientr.diamond,0;
}

if (playerchats && strequals(#c,Show Minerals)){
this.lead = clientr.lead;
this.silver = clientr.silver;
this.gold = clientr.gold;
this.diamond = clientr.diamond;
}

if (actionmined){
if (int(this.minechoice) > 25 && int(this.minechoice) <= 100){
setstring clientr.lead,#v(strtofloat(#s(clientr.lead)) + 1);
}
if (int(this.minechoice) > 100 && int(this.minechoice) <= 150){
setstring clientr.silver,#v(strtofloat(#s(clientr.silver)) + 1);
}
if (int(this.minechoice) > 150 && int(this.minechoice) <= 230){
setstring clientr.gold,#v(strtofloat(#s(clientr.gold)) + 1);
}
if (int(this.minechoice) > 230 && int(this.minechoice) <= 256){
setstring clientr.diamond,#v(strtofloat(#s(clientr.diamond)) + 1);
}
}
//#CLIENTSIDE
if (weaponfired){
this.posx = playerx + 1.5 + vecx(playerdir) * 2;
this.posy = playery + 1.5 + vecy(playerdir) * 2;
this.tile=tiles[this.posx,this.posy];
if (tiles[this.posx,this.posy] == 2055 || tiles[this.posx,this.posy] == 2056 || tiles[this.posx,this.posy] == 2073 || tiles[this.posx,this.posy] == 2074 || tiles[this.posx,this.posy] == 2070 || tiles[this.posx,this.posy] == 2086 || tiles[this.posx,this.posy] == 2076 || tiles[this.posx,this.posy] == 2060){
//setplayerprop #c, Omg you just mined a rock!;
freezeplayer .4;
setani dyn-pickaxe,;
this.minechoice = random(0,256);
triggeraction playerx+.5,playery+.5,mined,;
if (int(this.minechoice) >= 0 && int(this.minechoice) <= 25){
setplayerprop #c, Got Nothing!;
}
if (int(this.minechoice) > 25 && int(this.minechoice) <= 100){
setplayerprop #c, Got Lead!;
}
if (int(this.minechoice) > 100 && int(this.minechoice) <= 150){
setplayerprop #c, Got Silver!;
}
if (int(this.minechoice) > 150 && int(this.minechoice) <= 230){
setplayerprop #c, Got Gold!;
}
if (int(this.minechoice) > 230 && int(this.minechoice) <= 256){
setplayerprop #c, Got Diamond!;
}
}
//setplayerprop #c, #v(this.tile) = Current Tile;
}

if (playerchats && strequals(#c,Show Minerals)){
setplayerprop #c, Lead:#v(this.lead) Silver:#v(this.silver) Gold:#v(this.gold) Diamond:#v(this.diamond);
}


Duwul 02-04-2004 03:55 AM

For one, this. vars set on the server can not be read from the client. It is the same the other way around. This. vars set on the client can not be read on the server.

Second, to set the value of a string to a var, you do

NPC Code:

this.myvar = strtofloat(#s(stringname));



Just doing it without strtofloat won't work, nor will just the name of the string.

Third. For the triggeraction, just do

NPC Code:

triggeraction 0,0,serverside,#w,mined,extra params for the amount/type of rocks;



Then, in the serverside part, you can pick it up with actionserverside, and check #p(0) for mined.

Also, why would you check each tile individually? And, you shouldn't have to use tiles[] anymore, you already set the tile in the this.tile var. Just make an array with all the tiles you want to check for, and do

NPC Code:

if (this.tile in tilearray)


Gman4pwnu 02-04-2004 04:25 AM

im not that advanced into scripting yet.

Termina_Owner 02-04-2004 04:31 AM

mineral's count?

NPC Code:

if (created){
setshape 1,32,32;
save[0] = 50; // Health
}
if (actionminded){
damage = strtofloat(#p(0));
save[0]-= damage;
message Arg... I only have #v(save[0]) life left! When shall you learn your mannres?;
if (save[0] <= 0){
message Damn Fool... YOU KILLED ME! WHYY!!!???;
save[0] = 50;
setstring clientr.mineralsachieved,#v(strtofloat(#s(clientr. mineralsachieved))+1);
}
}


Termina_Owner 02-04-2004 04:33 AM

I posted an easier solution in the Miner's thread that you added to spam the NPC Catagory..

Termina_Owner 02-04-2004 04:37 AM

BRILLIANT... Why didn't he think of it earlier.... Erm... Just hope he uses it... Hope he at least credit us for our patience with his spamming thread plans.

Python523 02-04-2004 04:41 AM

sorry for the messy merge, the system here for merging threads didn't work the way I had expected it to, but the fact of the matter is, don't do this again please =/ just post one large thread with all your questions or I shall delete them next time

R0bin 02-04-2004 06:11 AM

Quote:

Originally posted by Stefan
2. with (getplayer(#a)) is completely nonsense, please kill the one who teached you such stuff
Hi Projectshifter!!! :)


also, by "bored", stefan means either, when the npc server has nothing to do, or he means when it just sends everything to the clientside.

WanDaMan 02-04-2004 03:07 PM

Wait this is so confusing, I remember being the first person to reply and me and osrs got into a battle at the beggining about this, I can't remember stefan posting before me, nor do I remember me spamming, what is going on?

R0bin 02-04-2004 04:55 PM

All gman's threads were merged into one.

WanDaMan 02-04-2004 07:23 PM

Now it looks like I just spammed, great moving :)!

GoZelda 02-04-2004 08:20 PM

Yeah, it totally flipped.

Bad remix ...

R0bin 02-04-2004 09:43 PM

like the quantum leap remix i heard the other day! *shudders*


All times are GMT +2. The time now is 09:48 AM.

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