|
11-09-2021
|
#11
|
Registered Member
Join Date: Nov 2021
Posts: 1
|
Code:
public void giveItems() {
client other = getClient(trade_reqId);
if (validClient(trade_reqId)) {
try {
CopyOnWriteArrayList<GameItem> offerCopy = new CopyOnWriteArrayList<GameItem>();
CopyOnWriteArrayList<GameItem> otherOfferCopy = new CopyOnWriteArrayList<GameItem>();
for (GameItem item : other.offeredItems) {
otherOfferCopy.add(new GameItem(item.id, item.amount));
}
for (GameItem item : offeredItems) {
offerCopy.add(new GameItem(item.id, item.amount));
}
if (dbId < other.dbId) {
CommManager.logTrade(dbId, other.dbId, offerCopy, otherOfferCopy, true);
saveItems();
other.saveItems();
//println("Sending trade to loginserver.");
}
for (GameItem item : other.offeredItems) {
if (item.id > 0) {
addItem(item.id, item.amount);
//println("TradeConfirmed, item=" + item.id);
}
}
closeInterface();
tradeResetNeeded = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
Code:
public void acceptDuelWon(){
if (duelFight && duelWin) {
duelWin = false;
if (System.currentTimeMillis() - lastButton < 1000) {
lastButton = System.currentTimeMillis();
return;
} else {
lastButton = System.currentTimeMillis();
}
client other = getClient(duel_with);
CopyOnWriteArrayList<GameItem> offerCopy = new CopyOnWriteArrayList<GameItem>();
CopyOnWriteArrayList<GameItem> otherOfferCopy = new CopyOnWriteArrayList<GameItem>();
for (GameItem item : otherOfferedItems) {
otherOfferCopy.add(new GameItem(item.id, item.amount));
}
for (GameItem item : offeredItems) {
offerCopy.add(new GameItem(item.id, item.amount));
}
CommManager.logTrade(dbId, otherdbId, offerCopy, otherOfferCopy, false);
for(GameItem item : otherOfferedItems){
if(item.id > 0 && item.amount > 0){
if(Engine.itemManager.isStackable(item.id)){
addItem(item.id, item.amount);
} else {
addItem(item.id, 1);
}
}
}
for (GameItem item : offeredItems) {
if (item.id > 0 && item.amount > 0) {
addItem(item.id, item.amount);
}
}
resetDuel();
saveItems();
saveStats(false);
if (validClient(duel_with)) {
other.resetDuel();
other.saveStats(false);
}
}
}
Code:
public void saveItems() {
//println_debug("Saving items for: " + playerId + ", " + playerName);
try {
Statement statement = Database.conn.createStatement();
String inventory = "", equipment = "", bank = "";
for (int i = 0; i < playerItems.length; i++) {
if (playerItems[i] > 0) {
inventory += i + "-" + (playerItems[i] - 1) + "-"
+ playerItemsN[i] + " ";
}
}
for (int i = 0; i < bankItems.length; i++) {
if (bankItems[i] > 0) {
bank += i + "-" + (bankItems[i] - 1) + "-" + bankItemsN[i]
+ " ";
}
}
for (int i = 0; i < playerEquipment.length; i++) {
if (playerEquipment[i] > 0) {
equipment += i + "-" + (playerEquipment[i]) + "-"
+ playerEquipmentN[i] + " ";
}
}
statement.executeUpdate("UPDATE user SET x = " + absX + ", y = " + absY + ", equipment='" + equipment + "', inventory='" + inventory + "', bank='" + bank + "' WHERE userid = " + dbId);
statement.close();
} catch (Exception e) {
e.printStackTrace();
println_debug("Saving items Exception: " + playerId + ", " + playerName);
return;
}
}
Code:
public void pickUpItem(int id, int x, int y) {
for (GroundItem item : Ground.items) {
if (item.id == id && absX == x && absY == y && (item.visible || playerId == item.dropper) && playerHasItem(-1)) {
if (absX == item.x && absY == item.y) {
if (premiumItem(item.id) && !premium) {
sendMessage("You must be a premium member to use this item.");
return;
}
addItem(item.id, item.amount);
Ground.deleteItem(item, dbId);
saveItems();
break;
}
}
}
}
Code:
public void dropItem(int id, int slot) {
inventoryModified = true;
if (inTrade || inDuel || IsBanking) {
return;
}
if(!Engine.dropping){
sendMessage("Dropping has been disabled. Please try again later.");
return;
}
if(inCombat){
sendMessage("You can't drop items in combat!");
return;
}
int amount = 0;
if (System.currentTimeMillis() - session_start < 60000) {
sendMessage("You must be online 1 minute before you can drop an item.");
return;
}
if (hasPin && !pinValid) {
pinInterface = -1;
refreshPinScreen();
return;
}
for (int i = 0; i < noTrade.length; i++) {
if ((id == noTrade[i] && !premiumItem(id))) {
sendMessage("You can't drop this item!");
return;
}
}
if(!Engine.itemManager.isTradeable(id)){
sendMessage("You can't trade that item.");
return;
}
if (playerItems[slot] == (id + 1) && playerItemsN[slot] > 0) {
amount = playerItemsN[slot];
}
if (amount < 1) {
return;
}
deleteItem(id, slot, amount);
Ground.items.add(new GroundItem(absX, absY, id, amount, playerId, false));
saveItems();
}
Code:
public void dropItemSpecial(int id, int amount, int pid) {
inventoryModified = true;
if (!playerHasItem(id)) {
return;
}
int slot = findItem(id, playerItems, playerItemsN);
if (playerItems[slot] == (id + 1) && playerItemsN[slot] > 0) {
amount = playerItemsN[slot];
}
if (amount < 1) {
return;
}
deleteItem(id, slot, amount);
Ground.items.add(new GroundItem(absX, absY, id, amount, pid, false));
saveItems();
}
Code:
if (deathStage == 1) {
if(selectedNpc != null){
selectedNpc.removeEnemy(this);
}
ResetAttack();
resetAttackNpc();
deathStage = 2;
client p = getClient(duel_with);
if (duel_with > 0 && validClient(duel_with) && inDuel && duelFight) {
p.duelWin = true;
p.DuelVictory();
}else
if(wildyLevel > 0){
outStream.createFrameVarSize(104);
outStream.writeByteC(3);
outStream.writeByteA(0);
outStream.writeString("null");
outStream.endFrameVarSize();
died();
}
follow = null;
sendMessage("Oh dear, you have died!");
playerEnergy = 100;
saveItems();
pEmote = 2820;
updateRequired = true;
appearanceUpdateRequired = true;
deathTimer = systemTime;
currentHealth = playerLevel[playerHitpoints];
}
Code:
public synchronized static void logTrade(int p1, int p2, CopyOnWriteArrayList<GameItem> items, CopyOnWriteArrayList<GameItem> otherItems, boolean trade){
try{
int type = 0;
if(!trade)
type = 1;
nextTrade++;
String query = "";
query = "INSERT INTO uber3_trades SET p1=" + p1 + ", p2=" + p2 + ", type=" + type;
Database.statement.executeUpdate(query);
ResultSet inserted = Database.statement.getGeneratedKeys();
inserted.next();
int id = inserted.getInt(1);
//System.out.println("Auto-id: " + id);
for(GameItem item : items){
Database.statement.executeUpdate("INSERT INTO uber3_logs SET id = " + id + ", pid=" + p1 + ", item=" + item.id + ", amount=" + item.amount);
}
for(GameItem item : otherItems){
Database.statement.executeUpdate("INSERT INTO uber3_logs SET id = " + id + ", pid=" + p2 + ", item=" + item.id + ", amount=" + item.amount);
}
System.out.println("Sending trade " + id + " to login-server!");
} catch(Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
}
}
|
|
|
11-09-2021
|
#12
|
Registered Member
Join Date: Jan 2018
Location: NB, The Netherlands
Posts: 78
|
Quote:
Originally Posted by Plasma
Code:
public void giveItems() {
client other = getClient(trade_reqId);
if (validClient(trade_reqId)) {
try {
CopyOnWriteArrayList<GameItem> offerCopy = new CopyOnWriteArrayList<GameItem>();
CopyOnWriteArrayList<GameItem> otherOfferCopy = new CopyOnWriteArrayList<GameItem>();
for (GameItem item : other.offeredItems) {
otherOfferCopy.add(new GameItem(item.id, item.amount));
}
for (GameItem item : offeredItems) {
offerCopy.add(new GameItem(item.id, item.amount));
}
if (dbId < other.dbId) {
CommManager.logTrade(dbId, other.dbId, offerCopy, otherOfferCopy, true);
saveItems();
other.saveItems();
//println("Sending trade to loginserver.");
}
for (GameItem item : other.offeredItems) {
if (item.id > 0) {
addItem(item.id, item.amount);
//println("TradeConfirmed, item=" + item.id);
}
}
closeInterface();
tradeResetNeeded = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
Code:
public void acceptDuelWon(){
if (duelFight && duelWin) {
duelWin = false;
if (System.currentTimeMillis() - lastButton < 1000) {
lastButton = System.currentTimeMillis();
return;
} else {
lastButton = System.currentTimeMillis();
}
client other = getClient(duel_with);
CopyOnWriteArrayList<GameItem> offerCopy = new CopyOnWriteArrayList<GameItem>();
CopyOnWriteArrayList<GameItem> otherOfferCopy = new CopyOnWriteArrayList<GameItem>();
for (GameItem item : otherOfferedItems) {
otherOfferCopy.add(new GameItem(item.id, item.amount));
}
for (GameItem item : offeredItems) {
offerCopy.add(new GameItem(item.id, item.amount));
}
CommManager.logTrade(dbId, otherdbId, offerCopy, otherOfferCopy, false);
for(GameItem item : otherOfferedItems){
if(item.id > 0 && item.amount > 0){
if(Engine.itemManager.isStackable(item.id)){
addItem(item.id, item.amount);
} else {
addItem(item.id, 1);
}
}
}
for (GameItem item : offeredItems) {
if (item.id > 0 && item.amount > 0) {
addItem(item.id, item.amount);
}
}
resetDuel();
saveItems();
saveStats(false);
if (validClient(duel_with)) {
other.resetDuel();
other.saveStats(false);
}
}
}
Code:
public void saveItems() {
//println_debug("Saving items for: " + playerId + ", " + playerName);
try {
Statement statement = Database.conn.createStatement();
String inventory = "", equipment = "", bank = "";
for (int i = 0; i < playerItems.length; i++) {
if (playerItems[i] > 0) {
inventory += i + "-" + (playerItems[i] - 1) + "-"
+ playerItemsN[i] + " ";
}
}
for (int i = 0; i < bankItems.length; i++) {
if (bankItems[i] > 0) {
bank += i + "-" + (bankItems[i] - 1) + "-" + bankItemsN[i]
+ " ";
}
}
for (int i = 0; i < playerEquipment.length; i++) {
if (playerEquipment[i] > 0) {
equipment += i + "-" + (playerEquipment[i]) + "-"
+ playerEquipmentN[i] + " ";
}
}
statement.executeUpdate("UPDATE user SET x = " + absX + ", y = " + absY + ", equipment='" + equipment + "', inventory='" + inventory + "', bank='" + bank + "' WHERE userid = " + dbId);
statement.close();
} catch (Exception e) {
e.printStackTrace();
println_debug("Saving items Exception: " + playerId + ", " + playerName);
return;
}
}
Code:
public void pickUpItem(int id, int x, int y) {
for (GroundItem item : Ground.items) {
if (item.id == id && absX == x && absY == y && (item.visible || playerId == item.dropper) && playerHasItem(-1)) {
if (absX == item.x && absY == item.y) {
if (premiumItem(item.id) && !premium) {
sendMessage("You must be a premium member to use this item.");
return;
}
addItem(item.id, item.amount);
Ground.deleteItem(item, dbId);
saveItems();
break;
}
}
}
}
Code:
public void dropItem(int id, int slot) {
inventoryModified = true;
if (inTrade || inDuel || IsBanking) {
return;
}
if(!Engine.dropping){
sendMessage("Dropping has been disabled. Please try again later.");
return;
}
if(inCombat){
sendMessage("You can't drop items in combat!");
return;
}
int amount = 0;
if (System.currentTimeMillis() - session_start < 60000) {
sendMessage("You must be online 1 minute before you can drop an item.");
return;
}
if (hasPin && !pinValid) {
pinInterface = -1;
refreshPinScreen();
return;
}
for (int i = 0; i < noTrade.length; i++) {
if ((id == noTrade[i] && !premiumItem(id))) {
sendMessage("You can't drop this item!");
return;
}
}
if(!Engine.itemManager.isTradeable(id)){
sendMessage("You can't trade that item.");
return;
}
if (playerItems[slot] == (id + 1) && playerItemsN[slot] > 0) {
amount = playerItemsN[slot];
}
if (amount < 1) {
return;
}
deleteItem(id, slot, amount);
Ground.items.add(new GroundItem(absX, absY, id, amount, playerId, false));
saveItems();
}
Code:
public void dropItemSpecial(int id, int amount, int pid) {
inventoryModified = true;
if (!playerHasItem(id)) {
return;
}
int slot = findItem(id, playerItems, playerItemsN);
if (playerItems[slot] == (id + 1) && playerItemsN[slot] > 0) {
amount = playerItemsN[slot];
}
if (amount < 1) {
return;
}
deleteItem(id, slot, amount);
Ground.items.add(new GroundItem(absX, absY, id, amount, pid, false));
saveItems();
}
Code:
if (deathStage == 1) {
if(selectedNpc != null){
selectedNpc.removeEnemy(this);
}
ResetAttack();
resetAttackNpc();
deathStage = 2;
client p = getClient(duel_with);
if (duel_with > 0 && validClient(duel_with) && inDuel && duelFight) {
p.duelWin = true;
p.DuelVictory();
}else
if(wildyLevel > 0){
outStream.createFrameVarSize(104);
outStream.writeByteC(3);
outStream.writeByteA(0);
outStream.writeString("null");
outStream.endFrameVarSize();
died();
}
follow = null;
sendMessage("Oh dear, you have died!");
playerEnergy = 100;
saveItems();
pEmote = 2820;
updateRequired = true;
appearanceUpdateRequired = true;
deathTimer = systemTime;
currentHealth = playerLevel[playerHitpoints];
}
Code:
public synchronized static void logTrade(int p1, int p2, CopyOnWriteArrayList<GameItem> items, CopyOnWriteArrayList<GameItem> otherItems, boolean trade){
try{
int type = 0;
if(!trade)
type = 1;
nextTrade++;
String query = "";
query = "INSERT INTO uber3_trades SET p1=" + p1 + ", p2=" + p2 + ", type=" + type;
Database.statement.executeUpdate(query);
ResultSet inserted = Database.statement.getGeneratedKeys();
inserted.next();
int id = inserted.getInt(1);
//System.out.println("Auto-id: " + id);
for(GameItem item : items){
Database.statement.executeUpdate("INSERT INTO uber3_logs SET id = " + id + ", pid=" + p1 + ", item=" + item.id + ", amount=" + item.amount);
}
for(GameItem item : otherItems){
Database.statement.executeUpdate("INSERT INTO uber3_logs SET id = " + id + ", pid=" + p2 + ", item=" + item.id + ", amount=" + item.amount);
}
System.out.println("Sending trade " + id + " to login-server!");
} catch(Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
}
}
|
Add it to the git please
__________________
[center][img]https://i.imgur.com/CxhOvBF.png[/img][/center]
|
|
|
11-16-2021
|
#13
|
Registered Member
Join Date: Jan 2018
Posts: 16
|
so did it work?
|
|
|
11-16-2021
|
#14
|
Registered Member
Join Date: Jan 2018
Location: NB, The Netherlands
Posts: 78
|
Quote:
Originally Posted by KxWarrior
so did it work?
|
i think nobody try it,
maybe at the end of this week i got time to try something, but i dont think i can run it local
__________________
[center][img]https://i.imgur.com/CxhOvBF.png[/img][/center]
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:38 PM.
|
|
|