hi everyone
I have this script in my game were I want the player to go to an atm and deposit or draw money.
the script first check if the player has money , and when he does , I want to have an input from the player , his name and also the amount of money he would like to deposit, problem is I don't know how to get an input from the player and how to save it for later use. I have attach my script so far. its not much but its all I have. ( still learning )
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Default script - does nothing.
money = 0
start_bank = 0
bank_p = 0
acct = 0
bankaccount = 0
function bank_init(e)
end
function bank_main(e)
pl = GetPlayerDistance(e)
--if pl < 32 then
if PlayerLooking(e,90,1) == 1 then
if start_bank == 0 then
Prompt("Press B to start banking") -- start banking
if GetScancode() == 48 then
bank_p = 1
FreezePlayer()
start_bank = 1
end
end
if bank_p == 1 then
Panel(20,8,72,70)
end
if money == 0 and bank_p == 1 then -- check if player has money
TextColor(22,31,4,"You have no money ",255,0,0)
TextColor(22,37,4,"Press E to exit banking",255,0,0)
end
if money > 0 and bank_p == 1 and acct == 0 then -- player has money
TextColor(22,31,4,"To open account Prees O",255,0,0)
TextColor(22,37,4,"Press E to exit banking",255,0,0)
end
if GetScancode() == 24 then
acct = 1
end
-- here is the part were i display the players name and amout on the screen
-- on this panel want to have the players name as an input and the money he wants to bank
-- but i dont have a clue how to get an input from the player and how to safe it
if acct == 1 and start_bank == 1 and bankaccount == 0 then
TextColor(22,31,3,"Name",255,0,0)
TextColor(22,35,3,"Amount",255,0,0)
TextColor(22,50,3,"Enter to Activate",255,0,0)
TextColor(22,53,3,"Press E to exit banking",255,0,0)
TextColor(22,67,3,"Enter Name",255,255,0)
end
if GetScancode() == 18 then
--Prompt("het e gedruk")
UnFreezePlayer()
bank_p = 0
start_bank = 0
acct = 0
end
end
end
-- thanks to smallg his script
function PlayerLooking(e,dis,v)
if g_Entity[e] ~= nil then
if dis == nil then
dis = 3000
end
if v == nil then
v = 0.5
end
if GetPlayerDistance(e) <= dis then
local destx = g_Entity[e]['x'] - g_PlayerPosX
local destz = g_Entity[e]['z'] - g_PlayerPosZ
local angle = math.atan2(destx,destz)
angle = angle * (180.0 / math.pi)
if angle <= 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
while g_PlayerAngY < 0 or g_PlayerAngY > 360 do
if g_PlayerAngY <= 0 then
g_PlayerAngY = 360 + g_PlayerAngY
elseif g_PlayerAngY > 360 then
g_PlayerAngY = g_PlayerAngY - 360
end
end
local L = angle - v
local R = angle + v
if L <= 0 then
L = 360 + L
elseif L > 360 then
L = L - 360
end
if R <= 0 then
R = 360 + R
elseif R > 360 then
R = R - 360
end
if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then
return 1
elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then
return 1
else
return 0
end
else
return 0
end
end
end
Thanks for any help
Windows 7 Professional 64-bit
Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz (4 CPUs), ~2.7GHz RAM 4GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11