RSPS Hobo
RSPS Hobo

Reputation: 1

How to call upon a switch statements return type

Alright, so i had this error with my game. the error is in detail over here: https://www.rune-server.ee/runescape-development/rs2-server/help/668521-very-weird-backdoor-dupe.html

But to simply put it, the error was due to a user inputting a value which exceeded the int data type value, and it caused it to cheat the system.

so explain the bug to you, the user would go to the ingame store, and purchase something, when choosing the quantity of the item, he could input a value higher than the int value I'm assuming because of this, the price becomes negative and it allows the player to purchase an unlimited amount of the item, while also removing this negative amount that it costs from the players point which actually results in it being added (+) - (-) -> +.

The prices of those items where declared using a switch statement.

public int getSpecialItemValue14(int id) {// member points shop
    switch (id) {

    case 1038:
    case 1040:
    case 1042:
    case 1044:
    case 1046:
    case 1048:
        return 45000;

Now what im trying to do to prevent the server from accepting that value is create an IF STATEMENT, so that if the value exceeds the int value to block that request, and not forward it.

how would i do this?

Upvotes: 0

Views: 54

Answers (2)

Oleksandr
Oleksandr

Reputation: 818

Why not just check if price is negative or not? If it is, than you can display a message like "Error. Too many items".

Upvotes: 1

Sergio
Sergio

Reputation: 19

just convert the value to INTEGER before sending to the server, if it goes over the max value set it to 0 and launch the alert.

Upvotes: 1

Related Questions