Question regarding NPC variables

bWolfie

I'm the man
Messages
850
Points
0
Location
Alberta, Midgard
Github
bWolfie
Emulator
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.

Code:
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;
}
}
 
Last edited by a moderator:
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.

 
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?

 
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

 
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.

 
Back
Top