Jump to content

Useful Source Codes


RSBDavid

Recommended Posts

I remember before the rollback that there was a thread where users posted various sourcecodes. I am going to remake a thread simular to it. If you have a sourcecode you would like to share post it here.

 

 

 

I read throught the first 10 pages and didn't find so I am sure it was lost in the rollback.

 

 

 

Use this format:

 

 

 

 

 

 

Title:

 

Language:

 

Difficulty to Understand:

 

What it does:

 

The code:

 




 

 

 

 

 

 

 

 

[hide=My Contribution]Here is mine:

 

Title: Ballers Combat stat retrieving function

 

Language: vb.net

 

Difficulty to Understand [1/10]: 5

 

What it does: It retrieves the combat stats of a player from the highscores.

 

 

 


Function getCombatStats(ByVal username As String)

       Dim x As New System.Net.WebClient

       Dim rawData As String



       Try

           rawData = x.DownloadString("http://hiscore.runescape.com/index_lite.ws?player=" _

                                      & username) ' download the raw stat data for the user



       Catch ex As Exception

       End Try



       Dim statParse() As String



       statParse = rawData.Split(",") ' splits the data based on commas since that is what you see if you were to view the raw data

       Me.txtAttack.Text = statParse(3) ' get attack level

       Me.txtDef.Text = statParse(5) ' get defence level

       Me.txtStr.Text = statParse(7) ' get strength level

       Me.txtHp.Text = statParse(9) ' get hp level

       Me.txtRange.Text = statParse(11) ' get range level

       Me.txtPrayer.Text = statParse(13) ' get prayer level

       Me.txtMagic.Text = statParse(15) ' get magic level

       Me.txtSumm.Text = statParse(49) ' get summoning level



       'if any of the values return -1, replaces and sets it to level 1



       If Me.txtSumm.Text = "-1" Then Me.txtSumm.Text = "1"

       If Me.txtHp.Text = "-1" Then Me.txtHp.Text = "1"

       If Me.txtAttack.Text = "-1" Then Me.txtAttack.Text = "1"

       If Me.txtStr.Text = "-1" Then Me.txtStr.Text = "1"

       If Me.txtDef.Text = "-1" Then Me.txtDef.Text = "1"

       If Me.txtPrayer.Text = "-1" Then Me.txtPrayer.Text = "1"

       If Me.txtMagic.Text = "-1" Then Me.txtMagic.Text = "1"

       If Me.txtRange.Text = "-1" Then Me.txtRange.Text = "1"

       Return Nothing







   End Function

 

 

 

usage: You need to have textboxes with corresponding names to those above.

 

 

 

getCombatStats("username")

 

 

 

You can use the same method to get non-combat stats as well as levels and ranks.

 

 

 

Here is a picture of it in use. (Ignore the stuff outside of the green box)

 

2zpowva.jpg

 

 

 

It is useful if you want to look up the stats of someone you are going to fight in a pvp world or anywhere else.[/hide]

wii_wheaton.png

[software Engineer] -

[Ability Bar Suggestion] - [Gaming Enthusiast]

Link to comment
Share on other sites

Title: Random number generator

 

Language: Written here in PHP, but it's easy to write in other languages.

 

Difficulty to Understand: Pretty difficult

 

What it does: Returns a random number.

 

The code:

 

[hide=]

<?
function randomNumGen()
{
    return 4; //Chosen by fair dice roll
              //guaranteed to be random
}
?>

[/hide]

C2b6gs7.png

Link to comment
Share on other sites

Title: Random number generator

 

Language: Written here in PHP, but it's easy to write in other languages.

 

Difficulty to Understand: Pretty difficult

 

What it does: Returns a random number.

 

The code:

 

[hide=]

<?
function randomNumGen()
{
    return 4; //Chosen by fair dice roll
              //guaranteed to be random
}
?>

[/hide]

 

 

 

That won't generate a random number....

 

Edit: I don't get the joke :(

Link to comment
Share on other sites

I got the joke dsavi_x4. You read xkcd too, eh? :P

 

 

 

Here's my contribution.

 

 

 

Title: MTK Calculator (Miscellania)

 

Language: Java

 

Difficulty to Understand: Relatively straightforward

 

What it does: It calculates how long (in days) it would take to reduce your stockpile of cash in Miscellania to around 100gp (the point of no concern).

 

The code:

 

http://pastebin.com/m17e2bfa2

 

 

 

If it disappears and you're interested, PM me so I can put it back up.

Linux User/Enthusiast Full-Stack Software Engineer | Stack Overflow Member | GIMP User
s1L0U.jpg
...Alright, the Elf City update lured me back to RS over a year ago.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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