Jump to content
  • 0
bWolfie

Question regarding NPC variables

Question

Hi,

I'm trying to make an NPC which players can donate zeny to, and the zeny count is for every player - as in when one player donates, it updates a tally for everyone else (stored in NPC).

If I use .server_donate (as shown in example below), will it disappear when I restart my server?

 

Thank you in advance.

 

 

prontera,150,150,3    script    Server Donation NPC   4_F_TELEPORTER,{
 
mes "Players have donated " + .server_donate + " zeny.";
mes "How much zeny do you want to donate?";
next;
input .@donate;
if (Zeny < .@donate) {
mes "You need more zeny";
close;
}
else {
Zeny -= .@donate;
.server_donate += .@donate;
mes "You donated " + .@donate + " z.";
close;
}
}
Edited by True Zeal

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Yes, NPC variables are not stored for long-keeping, so they are reset on reload. You'll be better off using $variables. Those do get saved inside SQL (mapreg table).

 

Also, you do know that int variables have cap at INT_MAX(2,147,483,647) ? With zeny donations, high enough rates and enough time, you can hit that limit. Just a fair warning.

Share this post


Link to post
Share on other sites
  • 0

Thanks for the reply. So to sum it up, I need to use $ and if I'm using straight up zeny as a variable it can only go to 2.147.. billion?

Share this post


Link to post
Share on other sites
  • 0

I suggest using SQL only, and whenever you want to update the tally, do addition in SQL query itself, so you don't have to be bounded with 2bil limit, if you want to show the tally, use SQL query and save it on string variable

Share this post


Link to post
Share on other sites
  • 0

I have no idea about SQL, still a beginner at scripting. I think it's beyond me.

 

Decided just to create artificial zeroes at the end of the tally by

- Dividing total donation by 100.

- Limiting the donation amounts to over 100z and multiples of 100.

- Adding zeroes using text...

 

Seems to do the job in a limited fashion. I'll figure out sql one day.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.