Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 14:09

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# Calculating sp/min&hour

Discussion on C# Calculating sp/min&hour within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2009
Posts: 986
Received Thanks: 193
C# Calculating sp/min&hour

Hey guys,

I've been trying to figure out for some days already why my code isn't working. I still can't figurue out why it isn't working ...

Here is the formula i use and also the source


Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ReadMemory_GUI_
{
    public partial class Form1 : Form
    {
        int currentsp;
        int startingsp;
        int sptotal;
        int sec = 0;



        public Form1()
        {
            InitializeComponent();





        }


        private void timer1_Tick(object sender, EventArgs e)
        {

            Memory mem = new Memory("sro_client");


            string charactername = mem.ReadString(0xF9E9B8);
            string servername = mem.ReadString(0xF9E8B8);
            string[] lines = System.IO.File.ReadAllLines("exp.txt");
            int maxhp = mem.ReadOffset(0xFB970C, 0x460);
            int curhp = mem.ReadOffset(0xFB970C, 0x468);
            currentsp = mem.ReadOffset(0xFB970C, 0x888);
            int maxmp = mem.ReadOffset(0xFB970C, 0x464);
            int curmp = mem.ReadOffset(0xFB970C, 0x45C);
            int currentexp = mem.ReadOffset(0xFB970C, 0x878);
            int lv = mem.ReadOffset(0xFB970C, 0x874);
            decimal lving = (((decimal)currentexp / decimal.Parse(lines[lv - 1])) * 100);


            label1.Text = "CharacterName:" + charactername;
            label2.Text = "Maximum HP:" + maxhp;
            label3.Text = "Current HP:" + curhp;
            label4.Text = "Maximum MP:" + maxmp;
            label5.Text = "Minimum MP:" + curmp;
            label6.Text = "Skill Points:" + currentsp;
            label7.Text = "Exp:" + lving.ToString("f2") + "%";
            label8.Text = "Level:" + lv;
            label9.Text = "Server:" + servername;

        }
        public void Main()
        {
            startingsp = currentsp;
        }

        public void timer2_Tick(object sender, EventArgs e)
        {

            sptotal = currentsp - startingsp;
            sec++;
            int spmin = ((60 * sptotal) / sec);
            int sphour = ((3600 * sptotal) / sec);
            label10.Text = "SP/min:" + spmin;
            label11.Text = "SP/hour:" + sphour;
            label12.Text = "Value:" + sec;
        }
    }
}

I've tried tons of things already. I hope anyone can help me out..
Janick_ is offline  
Old 04/11/2011, 08:56   #2
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
Oke well I don't know how C# exactly works I can read the code but I don't know the details but i'll try to help you.

This is how I should create this tool:

Well uuhm idk how exactly memory reading works but I suppose that your way works

Uuhm well I should create some kind of timer which checks the sp like every 5 seconds(you could also create a trigger but an timer is easier I guess).

well like you already did you got an starting sp and the current sp so the way you're doing it might work but you need to have some timer which updates the sp every 5 seconds and also updates the labels on your form. Idk if this is the whole code cause you're not using any of the "timer" functions but I guess that's just cause you were testing stuff
kevin_owner is offline  
Old 04/11/2011, 13:20   #3
 
elite*gold: 0
Join Date: Jul 2009
Posts: 986
Received Thanks: 193
It gets updated every 0.3 sec already, i only took startingsp = currentsp; out of the timer becuase the starting sp dont need to be updated.
Janick_ is offline  
Old 04/11/2011, 13:41   #4
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
Oke so if it updates every 0.3 sec you increase the integer sec also every 0.3 seconds am I correct?

btw what doesn't work about this code? is it the output or is it just the whole code? also try to set some breakpoints to see where things gets messed up:P
kevin_owner is offline  
Old 04/11/2011, 14:53   #5
 
elite*gold: 0
Join Date: Jul 2009
Posts: 986
Received Thanks: 193
I've got 2 timers, for MP,HP, current sp and exp it gets updated every 0.3 sec, the other timer updates every 1 sec , every 1 sec the value gets increased.

And it shows, well the number are way to big , it shows like something 250213sp/min or so.
Janick_ is offline  
Old 04/11/2011, 15:20   #6
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
hmm. Well I don't know about timers ect in C# so I assume that those are correct. Did you also check the startingsp if those values are correct and the currentsp which gets udpated every second? mabye log them into an file to check if they increase properly.

But just a little notice which doesn't affect the code but it looks cleaner if you write the calculations like this.

(sptotal / sec) * 60

this way you can easly see what you're doing cause now i had to look what you were doing cause i was like hmm oke 60 well those are the seconds and then he divides them with the sec so it was a littel confusing

So you could try to take a look at the values of the startingsp and the currentsp to see if those are correct cause I assume that those values aren't correct.
kevin_owner is offline  
Thanks
1 User
Old 04/11/2011, 15:40   #7
 
elite*gold: 0
Join Date: Jul 2009
Posts: 986
Received Thanks: 193
Hmm, ye i think it was the startingsp.. anyway another problem

Why do i sometimes get this, sometimes i don't get it and sometimes i do and bleh its annoying and i dunno what is causing it. :



EDIT: its the Level: not showing the right value for some reason ..
Janick_ is offline  
Old 04/11/2011, 16:02   #8
 
kevin_owner's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,484
Received Thanks: 809
Well it's caused by bad reading of the exp file

mabye you could add a check to vervy that the number of lines are correct I guess that it has to be 140 so if it fails reading the file you get and out of index error

So just check if the numer of lines are equal or larger than 140. But If i were you I would read the file into an list with some objects at the main_load so you only read it it once and then you're done. now you read it everytime you launch the timer1_tick.
kevin_owner is offline  
Old 04/12/2011, 09:57   #9
 
lesderid's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 2,400
Received Thanks: 1,517
lv-1 is too low/high.
lesderid is offline  
Reply


Similar Threads Similar Threads
Calculating player skill
10/29/2010 - CO2 Private Server - 2 Replies
Ok so I've had a rather interesting debate going on on official tq forums last few days basically dealing with WHAT leads to our actions in pvp (from a cognitive aspect). Through this I've come to a mini conclusion for how I want to write my new version of my companions/duelist bots. Basically in my theory of how players attack (this is NOT related to anything other than where a player will aim/their accuracy) is that there are stages of targeting which influence A: Where we will...
Calculating Height, Z axis
06/07/2010 - Kal Online - 36 Replies
Yo yo, Any of you got experiences with implementing correct moving system in Kal by packets? What is the best way to calculate it correctly? I am doing like that. Calculating step in X axis and Y axis. Then calculate Z step like that. MoveZ = CurrentPlayerZ - GetHeight(CurrentPlayerX+MoveX, CurrentPlayerY+MoveY); Ofcourse its not complete thinking as every step must be reversed by multiplying it by -1. Calculated CoordZ must be multiplyed by 10. Given X and Y arguments to GetHeight...
Calculating damage
05/11/2009 - Silkroad Online - 10 Replies
How do you can calculate silkroad damage? not average damage. but every factor like how accesory change that damage? how other buff attack buff change it? how the damage change when it hits more that 1 target?
Calculating Atack or MAtack
05/04/2007 - CO2 Guides & Templates - 4 Replies
Sometimes you wanted know the atack of an trojan and him dont told you? with thats easy guide, you just need open him equipaments window! "JUST 1 percent error" TROJAN ATACK: The follow instructions is both used to lower and higher atack:
Calculating Hours of Pkp
11/23/2006 - CO2 Guides & Templates - 15 Replies
Ever have a black name or more than 30 pk points? This is how to calculate The total time u will have to wait for those 'awful' pk points to get off. 1. Multiply # of pk points by 6. (EX- 100pkp X 6 =600) 2. Divide that number by 60. (EX- 600 / 60) 3. The end number will be the # of hours it will take to get your pkp off.



All times are GMT +1. The time now is 14:09.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.