Jump to content

Sending a message only to player who has turned on message send.


Pirulax

Recommended Posts

  • Discord Moderators

So, i wrote a little script(okey, its mutch bigger, but, this is the part what i cant solve..), so basically if the player not turned off the message receive function, then he will receive this message:

function displayMessage(player)
	outputChatBox("====================" .. rovid .. "====================", player, 121, 121, 121, true)
	outputChatBox("#D24D57Szia kedves játékos!", player, 121, 121, 121, true)
	outputChatBox("Ha téged meghivtak erre a szerverre, akkor kérlek ird be a következő parancsot a ", player, 121, 121, 121, true)
	outputChatBox("Chat-be: #D24D57/invite <Meghivókód>#7a7a7a, ha a kódot sikeresen beaktiváltad, akkor ", player, 121, 121, 121, true)
	outputChatBox("#D24D57500 000 dollárt#7a7a7a, és #D24D5730 000PP-t#7a7a7a kapsz ajádnékba!Ha valaki felhasználja a te invite kódodat akkor kapsz #D24D5750 000 dollárt#7a7a7a, és #D24D575000 PP-t #7a7a7aminden emberért aki a te kódodat aktiválja be!", player, 121, 121, 121, true)
	outputChatBox("Ha pedig nem hivtak meg, és kódod sincs, akkor ha szeretnéd, a #D24D57/toginvite #7a7a7aparanccsal tudod kikapcsolni ennek a szövegnek a kiirását!", player, 121, 121, 121, true)
	outputChatBox("Több infóért ird be,hogy #D24D57/invite help", player, 121, 121, 121, true)
	outputChatBox("=================================================================", player, 121, 121, 121, true)	
end

and this is the script what checks that the player have turned on, or off the function:

addEvent("toDisplayMessage", true)
function toDisplayMessage(player1)
local getPoll = dbPoll(dbQuery(con, "SELECT * FROM accounts WHERE id = ?", getElementData(player1, "acc:id")), -1)
	if #getPoll > 0 then
		for _, row in ipairs(getPoll) do
			if (row["sendMessage"] == 1) then
				displayMessage(player1)
			end
		end	
	--else
		--displayMessage(player1)
	end
end
addEventHandler("toDisplayMessage", getRootElement(), toDisplayMessage)

And this is the timer what sends the message every 15 minutes to the players who have turned on the recieve message function:

 


addEventHandler("onResourceStart", root, function()
setTimer(function()
	for k, player in ipairs(getElementsByType("player")) do
		toDisplayMessage(player) 
	end
end,1000*60*15, 1)
end)

And my problem is the following:

It sends the message sometimes 10 or more times to one player, i dont have any idea to solve it.

Link to comment
  • Discord Moderators
14 hours ago, TheMOG said:

@NeXuS™ its going to be another ExternalGaming server, with starting 5000000 premium point and 500000000000000 million dollars? :D:D

Maybe?I just asked a question, its not that important where i need it. :D But, if you really want to know: Not for an EG mod based server :D 

 

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...