Jump to content

[Help] GetTimer For Colored GridList


raynner

Recommended Posts

Hello good friends I'm already more than 6 hours puzzling over this and tried in many ways and could not carry out the repair :(. For this reason I have come to ask for help from you, good is simple I'm doing a pizzaboy work for my rpg server ... and wanted some deliveries is without available in just a few hours ..

see the code is easy to understand .. I will comment on the problems below.

local screenW,screenH = guiGetScreenSize()
local resW, resH = 1280,720
local x, y = (screenW/resW), (screenH/resH)
--===================================================================[[Basicos]]===================================================================--
GridListPizzaBoyLS = guiCreateGridList(x*313, y*272, x*559, y*273, false)
guiGridListAddColumn(GridListPizzaBoyLS, "ID", x*0.07)
guiGridListAddColumn(GridListPizzaBoyLS, "Local", x*0.30)
guiGridListAddColumn(GridListPizzaBoyLS, "Disponível em", x*0.28)
guiGridListAddColumn(GridListPizzaBoyLS, "Disponibilidade das", x*0.20)
guiGridListAddColumn(GridListPizzaBoyLS, "Lucro", x*0.09)
guiGridListSetSortingEnabled(GridListPizzaBoyLS,false)
guiSetVisible(GridListPizzaBoyLS,false)
for i = 1, 30 do
	guiGridListAddRow(GridListPizzaBoyLS)
end

function VerificHourID1()
-----------------------------------------------[[ 1 ]]-----------------------------------------------
	----- ID 1
	if (getTime() >= 00.00) and not (getTime() >= 02.00) then
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 1, "1", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 2, "Pershing Square (DP) (LS)", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 4, "00:00 às 02:00", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 3, "Pizzaria De Los Santos", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 5, "60", false,false)
	--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 1, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 2, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 3, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 4, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 5, 0, 255, 0, 255, false, false)
	end
	if (getTime() >= 02.00) then
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 1, "1", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 2, "Pershing Square (DP) (LS)", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 4, "00:00 às 02:00", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 3, "Pizzaria De Los Santos", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 0, 5, "60", true,false)
	--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 1, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 2, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 3, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 4, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 0, 5, 255, 255, 0, 255, false, false)
	end
end
addEventHandler("OnClientPreRender",root,VerificHourID1)
---
function VerificHourID2()
-----------------------------------------------[[ 2 ]]-----------------------------------------------
	if (getTime() >= 01.00) and not (getTime() >= 02.30) then
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 1, "3", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 2, "Hospital Jefferson (LS", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 4, "01:00 às 02:30", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 3, "Pizzaria De Los Santos", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 5, "80", false,false)
	--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 1, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 2, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 3, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 4, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 5, 0, 255, 0, 255, false, false)
	
	elseif (getTime() >= 02.30) then
	
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 1, "3", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 2, "Hospital Jefferson (LS)", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 4, "01:00 às 02:30", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 3, "Pizzaria De Los Santos", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 2, 5, "80", true,false)
	--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 1, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 2, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 3, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 4, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 2, 5, 255, 255, 0, 255, false, false)
	end
end
addEventHandler("OnClientPreRender",root,VerificHourID2)
setTimer(VerificHourID2,50,0)

Note: I know I should not use "onClientPreRender" GUI .. more as you may have noticed it also contains a SetTimer result of tests ..

Well my problem this ID 1 item works perfectly but the other (when all are 10) do not work correctly, or they just do not create yellow and green just ... it was probably some my mistake (or why not reviewed and redid these lines more than 5 times), and the biggest mistake he demonstrates one hour of delay that is elseif (getTime ()> = 30.2) then

then it is only yellow 03:00 ...

Note: I tried to use tb onClientRender and SetTimer and had the same result.

Edited by raynner
Repair Script Code
Link to comment

Try this:

local screenW,screenH = guiGetScreenSize()
local resW, resH = 1280,720
local x, y = (screenW/resW), (screenH/resH)
--===================================================================[[Basicos]]===================================================================--
addEventHandler( "onClientResourceStart", resourceRoot,
	function()
		GridListPizzaBoyLS = guiCreateGridList(x*313, y*272, x*559, y*273, false)
		guiGridListAddColumn(GridListPizzaBoyLS, "ID", x*0.07)
		guiGridListAddColumn(GridListPizzaBoyLS, "Local", x*0.30)
		guiGridListAddColumn(GridListPizzaBoyLS, "Disponível em", x*0.28)
		guiGridListAddColumn(GridListPizzaBoyLS, "Disponibilidade das", x*0.20)
		guiGridListAddColumn(GridListPizzaBoyLS, "Lucro", x*0.09)
		guiGridListSetSortingEnabled(GridListPizzaBoyLS,false)
		guiSetVisible(GridListPizzaBoyLS,false)
		for i = 1, 30 do
			guiGridListAddRow(GridListPizzaBoyLS)
		end
	end
)

function VerificHourID1()
-----------------------------------------------[[ 1 ]]-----------------------------------------------
	local h,m = getTime()
	if (h >= 0) and (h < 3) then
		if (m > 0 and h ~= 2) then
			guiGridListSetItemText(GridListPizzaBoyLS, 0, 1, "1", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 0, 2, "Pershing Square (DP) (LS)", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 0, 4, "00:00 às 02:00", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 0, 3, "Pizzaria De Los Santos", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 0, 5, "60", false,false)
	--------------------------------------------------------------------------------------
			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 1, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 2, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 3, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 4, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 5, 0, 255, 0, 255, false, false)
		end
	end
end
function VerificHourID2()
	local h,m = getTime()
	if (h >= 1 and h < 3) then
		if (h == 2 and m <= 30) then
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 1, "3", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 2, "Hospital Jefferson (LS", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 4, "01:00 às 02:30", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 3, "Pizzaria De Los Santos", false,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 5, "80", false,false)
	--------------------------------------------------------------------------------------
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 1, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 2, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 3, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 4, 0, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 5, 0, 255, 0, 255, false, false)
		end
	end
	if (h >= 2) then
		if (h == 2 and m > 30) then
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 1, "3", true,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 2, "Hospital Jefferson (LS)", true,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 4, "01:00 às 02:30", true,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 3, "Pizzaria De Los Santos", true,false)
			guiGridListSetItemText(GridListPizzaBoyLS, 2, 5, "80", true,false)
	--------------------------------------------------------------------------------------
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 1, 255, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 2, 255, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 3, 255, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 4, 255, 255, 0, 255, false, false)
			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 5, 255, 255, 0, 255, false, false)
		end
	end
end
setTimer( VerificHourID1, 1000, 0 )
setTimer( VerificHourID2, 1000, 0 )

 

Link to comment
3 hours ago, DNL291 said:

Try this:


local screenW,screenH = guiGetScreenSize()local resW, resH = 1280,720local x, y = (screenW/resW), (screenH/resH)--===================================================================[[Basicos]]===================================================================--addEventHandler( "onClientResourceStart", resourceRoot,	function()		GridListPizzaBoyLS = guiCreateGridList(x*313, y*272, x*559, y*273, false)		guiGridListAddColumn(GridListPizzaBoyLS, "ID", x*0.07)		guiGridListAddColumn(GridListPizzaBoyLS, "Local", x*0.30)		guiGridListAddColumn(GridListPizzaBoyLS, "Disponível em", x*0.28)		guiGridListAddColumn(GridListPizzaBoyLS, "Disponibilidade das", x*0.20)		guiGridListAddColumn(GridListPizzaBoyLS, "Lucro", x*0.09)		guiGridListSetSortingEnabled(GridListPizzaBoyLS,false)		guiSetVisible(GridListPizzaBoyLS,false)		for i = 1, 30 do			guiGridListAddRow(GridListPizzaBoyLS)		end	end)function VerificHourID1()-----------------------------------------------[[ 1 ]]-----------------------------------------------	local h,m = getTime()	if (h >= 0) and (h < 3) then		if (m > 0 and h ~= 2) then			guiGridListSetItemText(GridListPizzaBoyLS, 0, 1, "1", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 0, 2, "Pershing Square (DP) (LS)", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 0, 4, "00:00 às 02:00", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 0, 3, "Pizzaria De Los Santos", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 0, 5, "60", false,false)	--------------------------------------------------------------------------------------			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 1, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 2, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 3, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 4, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 0, 5, 0, 255, 0, 255, false, false)		end	endendfunction VerificHourID2()	local h,m = getTime()	if (h >= 1 and h < 3) then		if (h == 2 and m <= 30) then			guiGridListSetItemText(GridListPizzaBoyLS, 2, 1, "3", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 2, "Hospital Jefferson (LS", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 4, "01:00 às 02:30", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 3, "Pizzaria De Los Santos", false,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 5, "80", false,false)	--------------------------------------------------------------------------------------			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 1, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 2, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 3, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 4, 0, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 5, 0, 255, 0, 255, false, false)		end	end	if (h >= 2) then		if (h == 2 and m > 30) then			guiGridListSetItemText(GridListPizzaBoyLS, 2, 1, "3", true,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 2, "Hospital Jefferson (LS)", true,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 4, "01:00 às 02:30", true,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 3, "Pizzaria De Los Santos", true,false)			guiGridListSetItemText(GridListPizzaBoyLS, 2, 5, "80", true,false)	--------------------------------------------------------------------------------------			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 1, 255, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 2, 255, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 3, 255, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 4, 255, 255, 0, 255, false, false)			guiGridListSetItemColor(GridListPizzaBoyLS, 2, 5, 255, 255, 0, 255, false, false)		end	endendsetTimer( VerificHourID1, 1000, 0 )setTimer( VerificHourID2, 1000, 0 )

 

I must admit that you thought too much using your code and still making several changes still had errors with delay by checking the 'm' in (45 or 30 etc ...) (if I do it this way when time and lower it n checks properly ..) I have to check the two together as hour: minute unseparated as hour and minute. I use "^" might work ...

6 minutes ago, raynner said:

I must admit that you thought too much using your code and still making several changes still had errors with delay by checking the 'm' in (45 or 30 etc ...) (if I do it this way when time and lower it n checks properly ..) I have to check the two together as hour: minute unseparated as hour and minute. I use "^" might work ...

It has to be something like

if (h.m >= 08.45) and (h.m <= 11.10) then

more that says ..

attempt to index local 'h' (a number value)

you know any way to measure the entire time without separating them?

Link to comment

more tests done and this was what came closest to success having just as the failure tonumber starts counting from 1 and not the 0 that is with the lack of just 0 occurring error does anyone have a light? :/

local h,m = getTime()
	local hour = ''..h..'.'..m..''
	if (tonumber(hour) >= 8.45) and (tonumber(hour) <= 11.11) then
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 1, "7", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 2, "Banco Rodeo (LS)", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 4, "08:45 às 11:10", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 3, "Pizzaria De Los Santos", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 5, "100", false,false)
		--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 1, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 2, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 3, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 4, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 5, 0, 255, 0, 255, false, false)
	end

 

Link to comment

Resolved will share if others will need ...

function VerificHoraID4()
	h,m = getTime()
	if (h >= 0) and (h <= 9.59) then
		h = '0'..h..''
	end
	if (m >= 0) and (m <= 9) then
		m = '0'..m..''
	end
	hour = ''..h..'.'..m..''
	if (tonumber(hour) >= 08.45) and (tonumber(hour) <= 11.10) then
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 1, "7", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 2, "Banco Rodeo (LS)", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 4, "08:45 às 11:10", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 3, "Pizzaria De Los Santos", false,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 5, "100", false,false)
		--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 1, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 2, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 3, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 4, 0, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 5, 0, 255, 0, 255, false, false)
	else
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 1, "7", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 2, "Hospital Market (LS)", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 4, "08:45 às 11:10", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 3, "Pizzaria De Los Santos", true,false)
		guiGridListSetItemText(GridListPizzaBoyLS, 6, 5, "73", true,false)
		--------------------------------------------------------------------------------------
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 1, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 2, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 3, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 4, 255, 255, 0, 255, false, false)
		guiGridListSetItemColor(GridListPizzaBoyLS, 6, 5, 255, 255, 0, 255, false, false)
	end
end
setTimer(VerificHoraID4,50,0)

 

Edited by raynner
Update code
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...