-- LUA Script - precede every function and global member with lowercase name of script function chat_init(e) textlines = {} textlines[0] = { name = "Hello, how are you today?", description = "Fine, thank you." } textlines[1] = { name = "Nice weather, is not it?", description = "Only if you like rain." } textlines[2] = { name = "You are standing in my way.", description = "That is your problem." } textlines[3] = { name = "Anything new?", description = "Nope" } textlines[4] = { name = "See you later.", description = "... Aligator." } time1 = 0 time2 = g_Time timepassed = time2 - time1 delay = 2; selected_line = 0 chosen_line = nil textsize = 2 pressed = 0 chat_on = 0 end function chat_main(e) if g_Entity[e]['plrinzone']==1 then TextCenterOnXColor(50,50,4,"Use 'B' to select and use 'N' or 'M' key to move trough options.",255,100,100) --TextCenterOnX(70,70,4,GetScancode()) --PromptDuration("Use 'B' to select and use 'N' and 'M' keys to move trough options.",1500) if chosen_line == nil then offset = 100 - ((#textlines*2)+1+10) for showline = 0,#textlines,1 do PromptTextSize(2) textsize = 2 R,G,B = 255,255,255 if showline == math.floor(selected_line) then PromptTextSize(3) textsize = 3 R,G,B = 255,100,100 end offset = offset + textsize TextCenterOnXColor(50,offset, textsize, textlines[showline].name,R,G,B) --[[ if textsize == 3 then TextCenterOnXColor(50,offset, textsize, textlines[showline].name,255,100,100) else TextCenterOnX(50,offset, textsize, textlines[showline].name .. ":" .. textsize) end ]]-- end key = GetScancode(); if key == 0 then pressed = 0; elseif key == 48 and pressed == 0 then chosen_line = math.floor(selected_line) chat_on = 1 pressed = 1 elseif key == 49 and (pressed == 0 and selected_line < #textlines) then selected_line = selected_line + 1 pressed = 1 elseif key == 50 and (pressed == 0 and selected_line > 0) then selected_line = selected_line - 1 pressed = 1 end --PromptTextSize(5) --Prompt("selected_line: " .. math.floor(selected_line,10) .. " ") else PromptTextSize(5) Prompt("Reply: " .. textlines[chosen_line].description .." " ) end else time1 = 0 chat_on = 0 selected_line = 0 chosen_line = nil textsize = 2 PromptTextSize(3) end if g_Entity[e]['plrinzone']==1 and chat_on == 1 then if time1 == 0 then time1 = g_Time end time2 = g_Time timepassed = (time2 - time1) / 1000 if timepassed >= delay then time1 = 0 chat_on = 0 selected_line = 0 chosen_line = nil textsize = 2 PromptTextSize(3) end end end