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 May 23, 2022 12:46 pm Post subject: string index |
|
|
So i want to make this thing:
but it won't instead it giving me
Code: | tp
tp-0
tp-01
tp-010 |
code is:
Code: | button[8].OnClick = function(sender)
local name = inputQuery("Add teleport place","Name your place",nil)
if type(name) == nil or name == "" then
name = "undefined-0"
end
for i,v in pairs(Trainer.Names.Places) do
if name == tostring(v) then
if string.find(v,"%d") then
name = name..tonumber(string.gsub(v,"%a",""))+1
elseif not string.find(v,"%d") then
name = name.."-0"
end
end
end
Trainer.Places[#Trainer.Places+1] = Vector.new(Car.GetCoord()[1],Car.GetCoord()[2],Car.GetCoord()[3])
Trainer.Names.Places[#Trainer.Names.Places+1] = name
comboBoxUpdate3()
end |
typing must be like:
Code: | tp
tp --0
tp --1
tp --2 |
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Mon May 23, 2022 1:34 pm Post subject: |
|
|
It looks like you are intentionally adding an extra "0" with the line:
Try removing the 0.
|
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Mon May 23, 2022 2:04 pm Post subject: |
|
|
did not helped, just shows same string that was typed
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Mon May 23, 2022 3:51 pm Post subject: |
|
|
Code: | local num = 0
button[8].OnClick = function(sender)
local name = inputQuery("Add teleport place","Name your place",nil)
if type(name) == nil or name == "" then
name = "undefined-0"
end
for i,v in pairs(Trainer.Names.Places) do
if name == tostring(v) then
if string.find(v,"%d") then
name = name..tonumber(string.gsub(v,"%a",""))+1
elseif not string.find(v,"%d") then
name = name.."-"..num
num = tonumber(num) + 1
end
end
end |
_________________
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4297
|
Posted: Mon May 23, 2022 3:55 pm Post subject: |
|
|
It looks like `Trainer.Names.Places` is a Lua array. You should be using `ipairs` to iterate over it instead of `pairs`.
I don't know what exactly you're trying to do, so I can't offer much help.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue May 24, 2022 12:05 am Post subject: |
|
|
AylinCE wrote: | Code: | local num = 0
button[8].OnClick = function(sender)
local name = inputQuery("Add teleport place","Name your place",nil)
if type(name) == nil or name == "" then
name = "undefined-0"
end
for i,v in pairs(Trainer.Names.Places) do
if name == tostring(v) then
if string.find(v,"%d") then
name = name..tonumber(string.gsub(v,"%a",""))+1
elseif not string.find(v,"%d") then
name = name.."-"..num
num = tonumber(num) + 1
end
end
end |
|
it works but doesn't index string in a right way
Code: | why
why-0
why-1
test
test-2 |
need to do smth with num variable
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Wed May 25, 2022 12:16 am Post subject: |
|
|
any1?
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25291 Location: The netherlands
|
Posted: Wed May 25, 2022 2:12 am Post subject: |
|
|
don't use pairs, use an indexed table that contains other tables
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Wed May 25, 2022 10:35 am Post subject: |
|
|
Code: | name = "name"
name = name.."-"..0
print(1,name) --> name-0
num=string.match(name,"%d") + 1
name = (name):gsub("%d","")..math.floor(num)
print(2,name) --> name-1
num=string.match(name,"%d") + 1
name = (name):gsub("%d","")..math.floor(num)
print(3,name) --> name-2 |
_________________
|
|
Back to top |
|
|
|