• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Function] checkFirstByTime

Erexo

Kage
Premium User
Joined
Mar 27, 2010
Messages
741
Solutions
5
Reaction score
193
Location
Pr0land
GitHub
Erexo
Hello everyone,
ive created a function that you can check if player (login for example) first time "for some time".

So, here is the code:
Lua:
function checkFirstByTime(cid,storage,value,year,month,day,times)
local funcDate = day.." "..month.." "..times.." "..year
	if getPlayerStorageValue(cid, storage) ~= value then 
		if funcDate < os.date("%d %b %X %Y", os.time()) then
			setPlayerStorageValue(cid, storage, value)
			return true
		end
	end
	return false
end

And here is an example:
Lua:
function onLogin(cid)
if checkFirstByTime(cid,6546,1,2013,Apr,30,21:30:00) then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Hello, you have login for the first time durning the event! You have recived an dildo and a bucket!")
   doPlayerAddItem(cid, dildo)
   doPlayerAddItem(cid, bucket)
end
   return true
end


Not tested :)
 
It is very unlikely that this works, you are trying to compare strings with < / >, Apr is a nil value and parameters like times and value do not really make sense to me.
Why can't you just test it? If the script is 5 min work then it can't be wrong to test it for 2 min..
 
Back
Top