Jump to content

Question

Posted

Hi, 

I am working on a script where i want to change the value to a negative value. I want the user to type in a value. The original value is based on a product u can buy in the game. 

Example:

The product costs 100

I search it with my script ( which ik how to do it )

I let the user type a value like 600, im using that value then to change it to -600 but idk how. Thx

 

 

10 answers to this question

Recommended Posts

  • 0
Posted (edited)

i made this sometime ago...see if it work in your case.

local gg = gg

function set()
local d = gg.prompt({"Enter a value :"},{0})
if d == nil then gg.toast("Canceled") os.exit() else

gg.searchNumber(d[1], 4)
gg.toast("Done")
gg.alert("Now increase the value and search again")

while true do
if gg.isVisible() then
gg.setVisible(false) 
break
end
gg.sleep(100)
end

local d = gg.prompt({"Enter a value :","Edit to :"},{0,0})
if d == nil then gg.toast("Canceled") gg.clearResults() else

gg.searchNumber(d[1], 4)
gg.toast("Done")
local t = gg.getResults(200)

for i,v in pairs(t) do
     if v.flags == 4 then
         v.value = -d[2]
    end
end
gg.setValues(t)
gg.clearResults()
gg.toast("Done")
end
end
end

while true do
if gg.isVisible() then
gg.setVisible(false)
set()
end
end

 

Edited by MonkeySAN
  • 0
Posted
local search = gg.prompt({"Value to search"}, {}, {"value"})
gg.searchNumber(search[1], 4)
-- [[Try shrink down your results here]]
local res = gg.getResults(gg.getResultsCount())
for key, value in pairs(res)do
    value['value'] = -value['value']
end

I don't think there is a need to use two prompt.. One prompt is fine.

By the way, if you ar esearching for a "shop" item, I believe the price is fixed, so there's no need to use prompt actually, just search for the price by storing every item's price into a table. Call them out when user want the particular item. That is more user-friendly.

  • 0
Posted

I dont get it. This what i have so far ( see code). I search the value and save it, after that i let the user choose how many coins (s)he wants ( which is a positive value). I use that value to change the saved values i searched in the beginning. But everything goes right except the "changing the value" part.

if gg.isVisible(true) then 
  gg.setVisible(false) 
end 
gg.clearResults() 
gg.setRanges(gg.REGION_JAVA_HEAP) 
gg.toast('Made by SAGEPAPI') 
gg.alert('thank you and have fun') 

gg.searchNumber('value',gg.TYPE_DWORD) 
local t = gg.getResults (100) 
C = gg.prompt({i='input coins'}, {i='Coins here'})  
if C == nil then 
gg.toast('canceled') 
gg.clearResults() 
os.exit() 
else 
for i,v in pairs(t) do 
t[i].value = -t[i].value 
end 
end

 

  • 0
Posted (edited)

hmm...im guess mine doesnt work in your case.

i do hope the second prompt will help you to get the idea.

and @ItsSC gave you the better one.

 

Edited by MonkeySAN
  • 0
Posted

The problem is i don't understand itsSc's one. Cuz im still a beginner in script making. But thx 

  • 0
Posted (edited)

Not sure which part you do not understand, I guess the second method i mentioned. Here is an example how to implement what I said there.

 

For example you are going to hack 3 items in the store. 

Item A 500 gold

Item B 1300 gold

Item C 2000 gold

local ITEM_PRICE = {{"Item A", 500}, {"Item B", 1300}, {"Item C", 2000}}
--[[Store your item here, Name with price. Or you can create more list according to their categories]]
local ITEM_NAME = {} --[[Let's store the name in here]]
for item, properties in pairs(ITEM_PRICE) do
    ITEM_NAME[#ITEM_NAME+1] = properties[1]
end
function buyItem(TYPE)
    gg.clearResults()
    local select = gg.choice(ITEM_NAME, nil, "ITSSC ITEM STORAGE")
    gg.searchNumber(ITEM_PRICE[select][2], TYPE)
    gg.getResults(gg.getResultsCount())
    gg.editAll(-ITEM_PRICE[select][2], TYPE)
end
buyItem(4)

 

Edited by ItsSC
  • 0
Posted

I used ur method but lil different thx 

14 hours ago, ItsSC said:

Not sure which part you do not understand, I guess the second method i mentioned. Here is an example how to implement what I said there.

 

For example you are going to hack 3 items in the store. 

Item A 500 gold

Item B 1300 gold

Item C 2000 gold


local ITEM_PRICE = {{"Item A", 500}, {"Item B", 1300}, {"Item C", 2000}}
--[[Store your item here, Name with price. Or you can create more list according to their categories]]
local ITEM_NAME = {} --[[Let's store the name in here]]
for item, properties in pairs(ITEM_PRICE) do
    ITEM_NAME[#ITEM_NAME+1] = properties[1]
end
function buyItem(TYPE)
    gg.clearResults()
    local select = gg.choice(ITEM_NAME, nil, "ITSSC ITEM STORAGE")
    gg.searchNumber(ITEM_PRICE[select][2], TYPE)
    gg.getResults(gg.getResultsCount())
    gg.editAll(-ITEM_PRICE[select][2], TYPE)
end
buyItem(4)

 

 

  • 0
Posted
1 hour ago, AKidWithMidgetFriend said:

Nice profile pic brother:D

Hahhah thx. U too my bro

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

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.