View previous topic :: View next topic |
Author |
Message |
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Mon Aug 23, 2021 4:01 am Post subject: if string == then |
|
|
I wanted to make a function with table were Code: | if string == powerupname then |
But when i type string, writeInteger applies for all powerup amount
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Mon Aug 23, 2021 4:09 am Post subject: |
|
|
You have to elaborate a little more. It's a little vague what it is you're exactly asking.
|
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Mon Aug 23, 2021 4:16 am Post subject: |
|
|
LeFiXER wrote: | You have to elaborate a little more. It's a little vague what it is you're exactly asking. |
The table is Code: | PowerupItems = {
Brocoli='+0x0',
Dumbell='+0x4',
Jetpack='+0x8',
OJ='+0xC',
PB='+0x10',
BP='+0x14',
RP='+0x18',
Sneaker='+0x1C',
RHH='+0x20',
SB='+0x24',
Bulldozer='+0x28',
Horseshoe='+0x2C',
DM='+0x30',
Piggybank='+0x34',
CD='+0x38',
Dracula='+0x3C',
JF='+0x40',
Juice='+0x44',
Adrenaline='+0x48',
Berserk='+0x4C',
CS='+0x50',
SS='+0x54',
KH='+0x58',
WOG='+0x5C',
Enforcer='+0x60',
}
|
Which includes all powerup name and offsets
Code: | PowerupItem = '[PowerInventory + 0x18] + 0x20' --Base address to table |
I setted function: Code: | setPowerupAmount(id,number)
for i,v in pairs(PowerupItems) do
if tostring(id) == tostring(i) then
writeInteger(PowerupItem+v,number)
else
print(i)
end
end
end
| [/code]
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
Birdi Expert Cheater Reputation: 0
Joined: 08 Jun 2020 Posts: 122 Location: Migrating
|
Posted: Mon Aug 23, 2021 4:48 am Post subject: |
|
|
What exactly is the error? It's applying the number to all of the powerups, instead of the one denoted by id?
_________________
Trying to learn!
Add me on Discord if you want hands-on help: Birdi#0007 |
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Mon Aug 23, 2021 4:55 am Post subject: |
|
|
Birdi wrote: | What exactly is the error? It's applying the number to all of the powerups, instead of the one denoted by id? |
Yeah
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
Birdi Expert Cheater Reputation: 0
Joined: 08 Jun 2020 Posts: 122 Location: Migrating
|
Posted: Mon Aug 23, 2021 4:57 am Post subject: |
|
|
Can't really see an issue, try properly debugging it:
Code: |
function setPowerupAmount(id,number)
for i,v in pairs(PowerupItems) do
if tostring(id) == tostring(i) then
writeInteger(PowerupItem+v,number)
print("Called ID: "..id.."\nRequested Number: "..number.."\nKey: "..i.."\nValue: "..v.."\n\nPowerupItem: "..PowerupItem)
end
end
end
setPowerupAmount('Juice',1) --Even with tostring(id) you need to call the key as a string
|
_________________
Trying to learn!
Add me on Discord if you want hands-on help: Birdi#0007 |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Mon Aug 23, 2021 5:19 am Post subject: |
|
|
This is the correct syntax for a table with keys/values
Code: |
PowerupItems = {
["Brocolli"] = "+0x0",
["Dumbell"] = "+0x4",
["Jetpack"] = "+0x8",
}
|
You can access the table by its key name like so
Code: |
tablename["keyname"]
|
Code: |
function findInTable(itemToFind)
for k,v in pairs(PowerupItems) do
if k == itemToFind then
print("I found " .. k .. " and its value is " .. v)
end
end
end
findInTable("Jetpack")
|
|
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Mon Aug 23, 2021 5:26 am Post subject: |
|
|
Birdi wrote: | Can't really see an issue, try properly debugging it:
Code: |
function setPowerupAmount(id,number)
for i,v in pairs(PowerupItems) do
if tostring(id) == tostring(i) then
writeInteger(PowerupItem+v,number)
print("Called ID: "..id.."\nRequested Number: "..number.."\nKey: "..i.."\nValue: "..v.."\n\nPowerupItem: "..PowerupItem)
end
end
end
setPowerupAmount('Juice',1) --Even with tostring(id) you need to call the key as a string
|
|
thx my mistake was that i'm wasn't correctly calling a function
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
|