Zenarchist 40 Share Posted September 29, 2018 Hey guys! I just implemented this into my scripts and figured I'd share it for anyone who likes this sort of thing. This small bit of code will add EXP Popups to your script: Source: // EXP Popup variables private boolean expShow = true; // If true, EXP popups are enabled private boolean expPaint = false; // If true, the EXP popup draws to the screen private long expStart = 0L; // This is used to determine when the last EXP gain happened private int expGained = 0; // This tracks the EXP gain to display private int expTotal = 0; // This tracks our last total exp so that we can detect when our new total exp changes private double expX = 270; // This is the X coordinate of the EXP popup (horizontal alignment - never changes) private double expY = 160; // This is the Y coordinate of the EXP popup (by decrementing, we can make the popup float vertically) // Returns total EXP gained public int getTotalExp() { Skill[] skills = Skill.values(); int exp = 0; for (Skill skill : skills) exp += getSkills().getExperience(skill); return exp; } @Override // Draw script info to the screen public void onPaint(Graphics g) { super.onPaint(g); // Display EXP popups if they are enabled if(expShow) { // If this is the first iteration of Paint (ie. script just started), set EXP total to current total. if(expTotal == 0) expTotal = getTotalExp(); // Show EXP Popup if (expPaint) { // If it has been less than 3 seconds since our last EXP gain, display the popup if (System.currentTimeMillis() - expStart <= 3000 && expGained != 0) { String gained = "+" + expGained + " EXP"; g.setColor(Color.black); g.drawString(gained, (int)expX + 1, (int)expY + 1); g.setColor(Color.green); g.drawString(gained, (int)expX, (int)expY); expY -= 0.5; } else { // Otherwise reset the popup expY = 160; expPaint = false; } } // New exp gain detected if (getTotalExp() != expTotal) { expPaint = true; expStart = System.currentTimeMillis(); expGained = getTotalExp() - expTotal; expTotal = getTotalExp(); expY = 160; } } } Link to comment Share on other sites More sharing options...
Zenarchist 40 Author Share Posted September 29, 2018 Thanks bro, that's a great idea Link to comment Share on other sites More sharing options...
Eclipseop 194 Share Posted September 29, 2018 why do you need this when there r xp drops built into the game...? Link to comment Share on other sites More sharing options...
Zenarchist 40 Author Share Posted October 1, 2018 On 9/30/2018 at 2:34 AM, Infidel said: Customization. Can be used for way more than just experience. Get creative. =D ^ this with a few edits you can display whatever your heart desires Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.