Karasu Posted September 20, 2013 Posted September 20, 2013 (edited) lame topic xD Edited September 22, 2013 by Karasu Quote
0 Tryskell Posted September 20, 2013 Posted September 20, 2013 (edited) I don't really understand the thing you try to do, tbh. Such "event kill" already exists on basic engine, as it's an event launched by many (if not all) events. If you want to make a rank system, which is a list of players based on the total numbers of killed/whatever in a given event, then I invite you to drop previous code entirely and to read event engine methods in depth. If I didn't understand, then rework your post because you say one thing and you post code for another thing. As a rank system, you should keep stuff in a imbricated Map<EventType, Map<int playerObjectId, int score>> probably, but it fully depends of what you want to do exactly. The save on db is kinda useless, personally. You have to feed the map at the end of event itself. I notably invite you to search how events are supposed to end. Edited September 20, 2013 by Tryskell Quote
0 Karasu Posted September 20, 2013 Author Posted September 20, 2013 (edited) I don't really understand the thing you try to do, tbh. Such "event kill" already exists on basic engine, as it's an event launched by many (if not all) events. If you want to make a rank system, which is a list of players based on the total numbers of killed/whatever in a given event, then I invite you to drop previous code entirely and to read event engine methods in depth. If I didn't understand, then rework your post because you say one thing and you post code for another thing. As a rank system, you should keep stuff in a imbricated Map<EventType, Map<int playerObjectId, int score>> probably, but it fully depends of what you want to do exactly. The save on db is kinda useless, personally. You have to feed the map at the end of event itself. I notably invite you to search how events are supposed to end. You didnt quite understand ;p ,im not trying to make a score, i could copy and adapt codes from l2p russian events (they have score but im not interested in them ,i have my own score style) This is what i want to do: This is from l2dreams ,im trying to make a total rank system that works just like pvp system from l2 (not just all events ,but separately ,tvt/dm/lms etc ,ranking for each) and as you can see ,this is obviously stored in database (aka characters table) AND the easiest way for you to understand ,is to check l2 phoenix event engine freya codes and l2 freya rev pack, what i did there is completely random/nonsense ,the point is that i dont even know with what to start ^^, but would u rly bother to do that? hm ,at least try to explain me what to do if u cant do that ,its better than nothing and i think i could handle these with some explanation (start point -> middle -> ending point) ,something like that Edited September 20, 2013 by Karasu Quote
0 xdem Posted September 20, 2013 Posted September 20, 2013 easy as hell dude work on L2PcInstance instead of L2Character doDie if isInEvent { eventDeaths++; killer.eventKills++; } and store it into your db the simpliest and best efficient way to do it Quote
0 Tryskell Posted September 20, 2013 Posted September 20, 2013 (edited) My answer matches with your first idea, which is what I also described under list of players based on the total numbers of killed/whatever in a given event You can't store in characters table because you can't know which events they were participating on. All will be mixed. The imbricated Map is a legit solution. The save isn't useful, but can be made even with an imbricated map. As I said, the save has to be made on event finish. The SQL save can be made on server shutdown, or after X events cycle (if you use a timed event engine). About how to increase individual timers, either the event engine got particular class for players, either it added many stuff in L2PcInstance. If you don't find a lot of new variables in L2PcInstance, you have to seek for new classes linked to L2PcInstance, holding events variables. You still have to search how an events ends (player condition reached, like 50 kills or whatever). This is the event where you will increase individual stats. --------------- xdem solution works if you cleanup stats everytime an event ends. But the use of SQL is bad. One query should be made on event end, stored in a map, and then when player calls the npc it reads the map instead of sql connection. @xdem : the easiest isn't the most maintainable :P. Edited September 20, 2013 by Tryskell Quote
0 ^Wyatt Posted September 20, 2013 Posted September 20, 2013 U can store it in DB as xdem said and then when server starts you get all player values and you store it in a map. Then, every time a player checks the rank you just need to check the map, instead of sql injection as Tryskell says. You can also make an update-task to update the map every 30 minutes or 1 hour plus the startup load. Quote
0 Karasu Posted September 20, 2013 Author Posted September 20, 2013 (edited) /* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General private License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General private License for more * details. * * You should have received a copy of the GNU General private License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ package net.phoenixengine.event; import javolution.text.TextBuilder; import net.phoenixengine.AbstractEvent; import net.phoenixengine.Config; import net.phoenixengine.io.Out; import net.phoenixengine.model.EventPlayer; import net.phoenixengine.model.SingleEventStatus; /** * @author Rizel * */ public class DM extends AbstractEvent { public static boolean enabled = true; private class Core implements Runnable { @Override public void run() { try { switch (eventState) { case START: divideIntoTeams(1); teleportToTeamPos(); preparePlayers(); forceSitAll(); setStatus(EventState.FIGHT); schedule(30000); break; case FIGHT: forceStandAll(); setStatus(EventState.END); clock.start(); break; case END: clock.stop(); EventPlayer winner = getPlayerWithMaxScore(); giveReward(winner); setStatus(EventState.INACTIVE); announce(": Congratulation! " + winner.getName() + " won the event with " + winner.getScore() + " kills!"); eventEnded(); break; } } catch (Throwable e) { e.printStackTrace(); announce("Error! Event ended."); eventEnded(); } } } private enum EventState { START, FIGHT, END, INACTIVE } private EventState eventState; private Core task; public DM(Integer containerId) { super(containerId); eventId = 1; createNewTeam(1, "All", Config.getInstance().getColor(getId(), "All"), Config.getInstance().getPosition(getId(), "All", 1)); task = new Core(); clock = new EventClock(Config.getInstance().getInt(getId(), "matchTime")); } /** * @see com.l2jserver.gameserver.event.Event#endEvent() */ @Override protected void endEvent() { setStatus(EventState.END); clock.stop(); } @Override protected String getScorebar() { return "Kills: " + getPlayerWithMaxScore().getScore() + " Time: " + clock.getTimeInString() + ""; } /* (non-Javadoc) * @see net.phoenixengine.AbstractEvent#onClockZero() */ @Override protected void onClockZero() { setStatus(EventState.END); schedule(1); } @Override public void onDie(EventPlayer victim, EventPlayer killer) { super.onDie(victim, killer); addToResurrector(victim); } @Override public void onKill(EventPlayer victim, EventPlayer killer) { super.onKill(victim, killer); killer.increaseScore(); } @Override protected void schedule(int time) { Out.tpmScheduleGeneral(task, time); } private void setStatus(EventState s) { eventState = s; } @Override public void start() { setStatus(EventState.START); schedule(1); } /* (non-Javadoc) * @see net.phoenixengine.AbstractEvent#createStatus() */ @Override public void createStatus() { status = new SingleEventStatus(containerId); } } This is deathmatch from event engine (as you can see ,its not related to any map or i am blind) so idk Edited September 20, 2013 by Karasu Quote
0 ^Wyatt Posted September 20, 2013 Posted September 20, 2013 you just need this method @Override public void onKill(EventPlayer victim, EventPlayer killer) { super.onKill(victim, killer); killer.increaseScore(); } to create what u want Quote
0 Karasu Posted September 20, 2013 Author Posted September 20, 2013 so where this killer.increaseScore(); will go ? L2PcInstance or L2Character + i still dont get the part with the map (i only heard about map integer from abstractevent but thats for CONFIG store) Quote
0 ^Wyatt Posted September 20, 2013 Posted September 20, 2013 L2Character contains L2PcInstance m8... just work with L2PcInstance that's player values Quote
0 Karasu Posted September 20, 2013 Author Posted September 20, 2013 (edited) public void onKill(EventPlayer victim, EventPlayer killer) { super.onKill(victim, killer); killer.increaseScore(); } well this already exists in code so what should i do now? as i said before ,atm java is completely strange unknown language for me (i still manage some things though) but this is beyond of what i can comprehend cuz i dont have any source to rely on (mostly copy-paste and modify ,im good only on that lol) ,there are lot of codes inside but there are so many similar one s on l2pcinstance that just blows my mind so idk what to do about doDie if isInEvent { eventDeaths++; killer.eventKills++; } not sure if this would work ,but i want to do ranking for each event not for all at once ;p Edited September 20, 2013 by Karasu Quote
0 ^Wyatt Posted September 20, 2013 Posted September 20, 2013 You should be smart enough to start with what you can afford, and not try to jump steps, since, as you said, "java is completely strange unknown language for me". So don't try to make a ranking for each event if u don't even know how to do it for all together. Quote
0 Karasu Posted September 21, 2013 Author Posted September 21, 2013 (edited) You should be smart enough to start with what you can afford, and not try to jump steps, since, as you said, "java is completely strange unknown language for me". So don't try to make a ranking for each event if u don't even know how to do it for all together. So first step would be in doing all events at once then see if it works that mean as xdem says but if isInEvent is incorrect (i only found something like if atEvent && pk != null) and if (atEvent || killer == null) return; but needs changed to IDK WHat lol...) ,perhaps if (isInEvent); should work.? or " boolean isInEvent = true; if (isInEvent); { eventDeaths = 0; eventDeaths++; killer.eventKills++; } " ok how about this?... (not sure, just random ,i bet 300% it wont work hehe) the real problem is: 1 = LETS SAY THAT DATABASE ITS GOING ON MAP (which i dont even know whats that map) ... 2 = HOW IM GOING TO CHECK RANKING if it will work?... 3 = IM SO STUPID ,I CANT SOLVE A SIMPLE MATTER, I ADMIT, but i got time to learn, no problem but atm i want to focus on this last issue on my server then i have nothing left to do for server except fixing bugs ,basic stuff... ,if i have learned at least some basics of java maybe i could handle this ,its not a matter of being dumb or smart but i lack curiosity and no time for now Edited September 21, 2013 by Karasu Quote
0 Karasu Posted September 21, 2013 Author Posted September 21, 2013 (edited) wyatt any answer? ;pp boolean isInEvent = true; if isInEvent{eventDeaths++;killer.eventKills++;} would this work? even if it works, how could i store it into DB Edited September 21, 2013 by Karasu Quote
0 xdem Posted September 21, 2013 Posted September 21, 2013 if you want to make it like every event it's own record you should firsly create a manager so: EventRecondsManager.java public static void updateRecords(L2PcInstance victim, L2PcInstance killer) { //make checks, in which event he is ?? switch (getEvent .... ) { case Deathmatch: DeathmatchKills(killer, Deathmatchkills(killer)++); Deathmatchdeaths(victim, Deathmatchdeaths(victim)++); break; and so on, and so on So, you play with maps here, I suggest objectId as KeySet On server startup you load the records from the db, into your RAM, and on server shutdown you save from ram to your hd (database) via the classical db read/write code gl Quote
0 Karasu Posted September 21, 2013 Author Posted September 21, 2013 (edited) hmm i got it except the part with " switch (getEvent .... ) " (getEvent to???) perhaps getEventDM or getEvent DM ??? and you saying about objectid as keyset ,object id where? on updaterecords? or... im sorry for sucking this bad xD Edited September 21, 2013 by Karasu Quote
Question
Karasu
lame topic xD
Edited by Karasu17 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.