• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] help with function

Status
Not open for further replies.

mjafko

Epic Member
Hellou.

Well look's like I am totaly newb, or something but would need some help, cant get working this one. What I'm trying to do is spawn this after this for complete. In Messages table there is 7 rows.


Code:
for index, message in ipairs(messages) do
			player:RegisterEvent(function(_, _, _, player)
				player:SendNotification( message )
			end, DELAY * index, 1);
			
				if ( HERE ?? ) then
				
					local x,y,z,o = player:GetLocation()
					player:SpawnCreature(Wave1Entry1, x+10, y, z+5, o, 1, 18000)
					player:SpawnCreature(Wave1Entry2, x+15, y-5, z+5, o, 1, 18000)
					player:SpawnCreature(Wave1Entry2, x+15, y+5, z+5, o, 1, 18000)
					
				end 
			
		end
 

Rochet2

Moderator / Eluna Dev
What is the problem?
The code looks correct otherwise except I have no idea what you try to do here:
if ( HERE ?? ) then

Also your description is hard to understand. Not sure what this means:
What I'm trying to do is spawn this after this for complete.
Your code seems to send notifications to player after a delay, but the spawns are done instantly within the the for loop.
Your descriptions seems to say you want to delay the spawns to be after the for loop. Is this correct?

If you do want the spawns to happen when the notification is sent, then you should do the spawning and the notification sending within the timed event.
 

mjafko

Epic Member
What is the problem?
The code looks correct otherwise except I have no idea what you try to do here:


Also your description is hard to understand. Not sure what this means:

Your code seems to send notifications to player after a delay, but the spawns are done instantly within the the for loop.
Your descriptions seems to say you want to delay the spawns to be after the for loop. Is this correct?

If you do want the spawns to happen when the notification is sent, then you should do the spawning and the notification sending within the timed event.

Yes that's correct, I want spawns happen after notification's end since there are 7 messeges each 1 sec of delay. But can't get this work. Always do same spawn and then notification.

So if you can help me a bit I would be glad :)

Greeting's,
Marko!
 
Last edited:

mjafko

Epic Member
@ Rochet2 was kind enough to answear me how to do it. I will just post it here, if anyone else will need it.

Thank you very much @ Rochet2!

Code:
for index, message in ipairs(messages) do
	player:RegisterEvent(function(_, _, _, player)
	player:SendNotification( message )
	end, DELAY * index, 1);		
end
   local x,y,z,o = player:GetLocation()
   unit:RegisterEvent(function(_, _, _, unit)
   unit:SpawnCreature(71011, x+10, y, z+5, o, 1, 18000)
   end, DELAY * #messages, 1);
 
Status
Not open for further replies.
Top