Hey, I have a ATM, but I dont know how to make the input box only accept numbers. I tried this, but it didn't work.
[code] if(amt == "a","b") then
DarkRP.notify(ply, 0, 4, "Invalid Number!")
return false
end[/code]
Also, How would I go about making an entity go away once the player who spawwned it DC'd or changed jobs?
I also get this error from a model:
[code]KeyValues Error: RecursiveLoadFromBuffer: got EOF instead of keyname in file models/mic.mdl mdlkeyvalue, (*prop_data*), K[/code]
For the ATM, what input box?
For the model you can find a way to use:
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index92d2.html"]Ent:Remove[/URL]
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbdc5.html"]Gamemode.PlayerDeath[/URL]
and for the last one, it's a .mdl error.
There is a box where you put how much money you want to deposit, withdraw.
bump please
The only way I think you could do this would be to use [URL="http://wiki.garrysmod.com/page/string/match"]string.match[/URL] and [URL="http://www.lua.org/pil/20.2.html"]patterns[/URL] (not regex)
[code]
string.match(str,"%d+")
[/code]
Examples:
[code]
test_123 becomes 123
test159test123 becomes 159
[/code]
Or, you can do a simple check with tonumber() to see if it returns nil
[lua]
if tonumber(str) then
// code
end
[/lua]
Hmm, allright. I still cant figure out the entity removes on job change :/
[editline]29th January 2014[/editline]
It gives me this error (The ATM)
[lua]
[ERROR] addons/darkrp_bankz/lua/autorun/cl_bankz.lua:177: bad argument #1 to 'WriteInt' (number expected, got nil)
1. WriteInt - [C]:-1
2. DoClick - addons/darkrp_bankz/lua/autorun/cl_bankz.lua:177
3. unknown - lua/vgui/dlabel.lua:206
[/lua]
The code is
[lua]
local Amtz = vgui.Create("DTextEntry", frame)
Amtz:SetPos(10,130)
Amtz:SetSize(frame:GetWide() - 20, 20)
Amtz:SetText("")
Amtz.OnTextChanged = function()
amt = tonumber(Amtz:GetValue())
if tonumber(str) then
DarkRP.notify(ply, 0, 4, "Enter a valid Number.")
return false
end
end
local Withdraw = vgui.Create("DButton", frame)
Withdraw:SetPos(10,160)
Withdraw:SetSize(100, 20)
Withdraw:SetText("Withdraw")
Withdraw.DoClick = function()
net.Start("DarkRP_SS_BankCash")
net.WriteString("Withdraw")
net.WriteInt(amt,32)
net.SendToServer()
end
local Deposit = vgui.Create("DButton", frame)
Deposit:SetPos(frame:GetWide() - 110,160)
Deposit:SetSize(100, 20)
Deposit:SetText("Deposit")
Deposit.DoClick = function()
net.Start("DarkRP_SS_BankCash")
net.WriteString("Deposit")
net.WriteInt(amt,32)
net.SendToServer()
end
[/lua]
Panel:SetNumeric to make it number-only.
[editline]30th January 2014[/editline]
Also, wrong forums. Go to [url]http://facepunch.com/forums/65[/url]
That spit out errors.
[lua] local Amtz = vgui.Create("DTextEntry", frame)
Amtz:SetPos(10,130)
Amtz:SetSize(frame:GetWide() - 20, 20)
Amtz:SetText("")
Amtz.OnTextChanged = function()
amt = tonumber(Amtz:GetValue())
end[/lua]
Would I put it here?
Amtz:SetNumeric( true )
Thanks so much, any ideas on how to make the entity disappear on jobchange/dc?
[editline]29th January 2014[/editline]
I tried putting brackets in it:
[lua]it
[ERROR] lua/vgui/dtextentry.lua:325: malformed pattern (missing ']')
1. find - [C]:-1
2. CheckNumeric - lua/vgui/dtextentry.lua:325
3. unknown - lua/vgui/dtextentry.lua:343
[/lua]
bump
Sorry, you need to Log In to post a reply to this thread.