logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Simple math question.

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
futts



Joined: 24 Jan 2008
Posts: 12

PostPosted: Wed Mar 12, 2008 6:53    Post subject: Simple math question. Reply with quote

Pardon my simple manners and newb-like question, but I am trying to help myself and a friend with a simple mathematics ordeal. What we want to accomplish is to GetPersistentInt, add or subtract a number (either one) from the acquired GetPersistentInt, and then replace the old Int with the new product.

In simpler terms, we pull an Int from the database - take two for example, then subtract one from it. We get one. Well, then we would put the product (the number one) into the database to replace two.

Of course we could do this all by ourselves and keep testing, but does anyone have any clean suggestions for us as someone more experienced?

I know this may be simple to you guys but not so much to me. I have a hard time with numbers but I'm steadily figuring things out. Embarassed We all have to start somewhere.
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Wed Mar 12, 2008 9:27    Post subject: Reply with quote

int iValue = GetPersistantInt(myObj, "DatabaseValue");
iValue = iValue - 1; //or some other maths
SetPersistantInt(myObj, "DatabaseValue", iValue);

The Set... functions will do a database INSERT or UPDATE the value
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group