Arithmetic help [read please]
#1

I need some help with arithmetic as im having some troubles coding my script.... lets start explain.
I want to do it

pawn Код:
new a1,a2;

a1 = 1;

a2= 1000;

a1 = (a1 +1); //input = 2

a2 = (a2 +500); // input = 1500
Ok... looks alright but look now my code

pawn Код:
vehicleinfo[carkey][Insurances] = (vehicleinfo[carkey][Insurances] +1);
vehicleinfo[carkey][IPrice] = (vehicleinfo[carkey][IPrice] +500);
Ok here is the bug when i try to increment the Insurances it decreases the insurances by one and if i try again it will increase and the bug stops so at first time of the use of the command will decrease.

Now the Iprice when i try to increment more 500 to the variable it does it it sets the Iprice to 500 and at the second time sets to 1000 them 1500 , 2000, 2500 etc, and the default value was 1000.

So something is wrong because at the first time of the use of the cmd it decreases the the value "1" and "500" sets to 500.

Hope someone is good with arithmetic because I'm needing of help to fix this out.
Reply
#2

Why don't you just use:

pawn Код:
new
    MyVar = 500; // Initializes MyVar with value 500

MyVar += 500;  // Adds 500 to MyVar
Similarly, with your script:

pawn Код:
vehicleinfo[carkey][Insurances] += 1;
vehicleinfo[carkey][IPrice] += 500;
Reply
#3

ok im going to try if it works now
Reply
#4

Your code works but i had some keys mixed because my script uses two variables to store vehicles keys

one is the ingame car id other is the mysql key id and i was using the ingame key so it make the system bug lol now all works perfect

Thanks for the help
Reply


Forum Jump:


Users browsing this thread: