Page 1 of 1

function beingfollowed help

Posted: Mon Oct 15, 2012 5:54 pm
by Uniden65
iam useing this code

Code: Select all

function beingfollowed(pawn,alarmnumber)
         cprintf(cli.lightblue,"Being Followed by someone \n");
	  sendMacro("CastSpellByName(\"Hide\");");
 		player:rest(120);
	if alarmnumber == 2 then
	  sendMacro("CastSpellByName(\"Hide\");");
	  cprintf(cli.pink, "Being Followed by someone still \n")
	  RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
	  logInfo(pawn.Name,"Was following you ", pawn.Name); 
		player:rest(180)
   	local tnames = {"Somechar","Anotherchar"}
   	if 3 >= alarmnumber then return end -- ignore the first couple and do the code on 3rd alarm
   	  for k,v in pairs(tnames) do
        if v == pawn.Name then
          SetChannelForLogin("next")
          RoMScript("ChangeChar('current')")
          loadProfile()
          return
        end
      end
   end
end
it works for the first 2 steps but after the 1 and second options are triggered it will not change channels ...and yes this is a sniplet from lisa .... i was trying

Code: Select all

function beingfollowed(pawn,alarmnumber)
         cprintf(cli.lightblue,"Being Followed by someone \n");
	  sendMacro("CastSpellByName(\"Hide\");");
 		player:rest(120);
	if alarmnumber == 2 then
	  sendMacro("CastSpellByName(\"Hide\");");
	  cprintf(cli.pink, "Being Followed by someone still \n")
	  RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
	  logInfo(pawn.Name,"Was following you ", pawn.Name); 
		player:rest(180)
   	if 3 >= alarmnumber then return end -- ignore the first couple and do the code on 3rd alarm
 	repeat parallelID = RoMScript("GetCurrentParallelID()"); yrest(500) until parallelID
         if (3 > parallelID) then
         sendMacro("ChangeParallelID(" .. parallelID+1 .. ");");
      else
         sendMacro("ChangeParallelID(1);");
      end
      player:rest(30);	
        end
      end
   end
end
or some form of this ...any ideas would be great

Re: help please

Posted: Mon Oct 15, 2012 10:13 pm
by BillDoorNZ
try

Code: Select all

function beingfollowed(pawn,alarmnumber)
	cprintf(cli.lightblue,"Being Followed by someone \n");
	sendMacro("CastSpellByName(\"Hide\");");
	player:rest(120);

	if alarmnumber == 2 then
		sendMacro("CastSpellByName(\"Hide\");");
		cprintf(cli.pink, "Being Followed by someone still \n")
		RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
		logInfo(pawn.Name,"Was following you ", pawn.Name); 
		player:rest(180)
		local tnames = {"Somechar","Anotherchar"}
	end;
	
	if 3 >= alarmnumber then return end -- ignore the first couple and do the code on 3rd alarm
	
	for k,v in pairs(tnames) do
		if v == pawn.Name then
			SetChannelForLogin("next")
			RoMScript("ChangeChar('current')")
			loadProfile()
			return
		end
	end
end

Re: help please

Posted: Mon Oct 15, 2012 10:14 pm
by BillDoorNZ
that code will do something once the 4th detection. I assume the calling function is incrementing the alarmnumber variable??

Re: help please

Posted: Tue Oct 16, 2012 6:58 am
by botje
thats not a bad function mate, very nice :)

Re: help please

Posted: Tue Oct 16, 2012 1:08 pm
by Uniden65
would be great if i could get it to work right .... BillDoorNZ thank you for the effert but it still does the same as my orginal code ...it will report that someone is there and go into hide (1) then it will whisper the person following the word WHAT (2) after that it repeats 1 again then ends does nothing after even if the person is still following.

and thanks botje your welcome to use it ...is why i posted mine here. i added mine to the file userfunction_gmmonitor.lua right like this ..

Code: Select all

local clearplayertime = 60 
-- time in seconds for players to be removed from table

-- when the ignoreplayertime time is reached it will play the alarm sound
-- if you want your own code performed then create a function named beingfollowed() and that code will be done instead.


function beingfollowed(pawn,alarmnumber)


rest of code follows

Re: help please

Posted: Wed Oct 17, 2012 3:39 pm
by BillDoorNZ
oops...just noticed the problem (after wandering off and looking at other places where it could have been occurring):

at the second check, you set a variable called tnames:

Code: Select all

      local tnames = {"Somechar","Anotherchar"}
the function then exits from the 3 >= alarmnumber check. At this point tnames no longer exits, it is disposed of.

Later, the function is called again and alarmnumber is 3, so it gets past the

alarmnumber==2

check, and hits the

Code: Select all

   if 3 >= alarmnumber then return end -- ignore the first couple and do the code on 3rd alarm
which causes it to exit the function again.

next time around, when alarmnumber is 4 so it passes the last check and goes to this code:

Code: Select all

   for k,v in pairs(tnames) do
      if v == pawn.Name then
         SetChannelForLogin("next")
         RoMScript("ChangeChar('current')")
         loadProfile()
         return
      end
   end
at this point, tnames does not exist, so this logic does absolutely nothing for you. I'm not sure what it is your trying to achieve with that part of the code, specifically, what are you trying to check? You have a table of names (well, you dont, but you are supposed to) that you are checking the followers name against, and if it matches you switch channel?

Re: help please

Posted: Thu Oct 18, 2012 11:21 am
by Uniden65
BillDoorNZ as i said in the first post its a sniplet from lisa ..but what iam trying to to is have it change channels after the 3 check or 4 or 5 really does not matter as long as it does it ....

the beggining of the code works great it hides the first time then clears target and continues on then it whispers on the second ....after this is what i am trying to get here ...

as always thanks for your help

Re: help please

Posted: Thu Oct 18, 2012 3:44 pm
by BillDoorNZ

Code: Select all

function beingfollowed(pawn,alarmnumber)
	cprintf(cli.lightblue,"Being Followed by someone \n");
	sendMacro("CastSpellByName(\"Hide\");");
	player:rest(120);

	if (2 > alarmnumber) then return;
	
	sendMacro("CastSpellByName(\"Hide\");");
	cprintf(cli.pink, "Being Followed by someone still \n")
	RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
	logInfo(pawn.Name,"Was following you ", pawn.Name); 
	player:rest(180)
   
	if (3 > alarmnumber) then return;
   
	SetChannelForLogin("next")
	RoMScript("ChangeChar('current')")
	loadProfile()
end

Re: help please

Posted: Thu Oct 18, 2012 7:00 pm
by lisa
BillDoorNZ wrote:

Code: Select all

function beingfollowed(pawn,alarmnumber)
	cprintf(cli.lightblue,"Being Followed by someone \n");
	sendMacro("CastSpellByName(\"Hide\");");
	player:rest(120);

	if (2 > alarmnumber) then return;
	
	sendMacro("CastSpellByName(\"Hide\");");
	cprintf(cli.pink, "Being Followed by someone still \n")
	RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
	logInfo(pawn.Name,"Was following you ", pawn.Name); 
	player:rest(180)
   
	if (3 > alarmnumber) then return;
   
	SetChannelForLogin("next")
	RoMScript("ChangeChar('current')")
	loadProfile()
end
sorry bill but I think you were half asleep when you wrote that lol
it will error because of the incorrect number of "end" and the first print and cast hide will be done every time the function is called.

maybe something like this?

Code: Select all

function beingfollowed(pawn,alarmnumber)
	if alarmnumber == 1 then
		cprintf(cli.lightblue,"Being Followed by someone \n");
		sendMacro("CastSpellByName(\"Hide\");");
		player:rest(120);
	end
	if alarmnumber == 2 then 
		sendMacro("CastSpellByName(\"Hide\");");
		cprintf(cli.pink, "Being Followed by someone still \n")
		RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
		logInfo(pawn.Name,"Was following you ", true); 
		player:rest(180)
	end
	if alarmnumber >= 3 then
		SetChannelForLogin("next")
		RoMScript("ChangeChar('current')")
		loadProfile()
	end
end
Also

logInfo(_filename,_msg,_logtime,_subfolder,_logtype)

Re: help please

Posted: Sat Oct 20, 2012 7:47 am
by Uniden65
thanks both of you .... after testing...

lisa it gives a error attempt to call global 'SetChannelForLogin' <a nil value>


so i changed it to this

Code: Select all

function beingfollowed(pawn,alarmnumber)
   if alarmnumber == 1 then
      cprintf(cli.lightblue,"Being Followed by someone \n");
      sendMacro("CastSpellByName(\"Hide\");");
      player:rest(120);
   end
   if alarmnumber == 2 then 
      sendMacro("CastSpellByName(\"Hide\");");
      cprintf(cli.pink, "Being Followed by someone still. Whisper \n")
      RoMScript('SendChatMessage("What", "WHISPER", 0, "'..pawn.Name..'")')
      logInfo(pawn.Name,"Was following you and i whispered them.", true); 
      player:rest(180)
   end
   if alarmnumber >= 3 then
      cprintf(cli.pink, "Changing channels \n")
	repeat parallelID = RoMScript("GetCurrentParallelID()"); yrest(500) until parallelID
         if (3 > parallelID) then
         sendMacro("ChangeParallelID(" .. parallelID+1 .. ");");
      else
         sendMacro("ChangeParallelID(1);");
      end
      player:rest(30);
   end
end
works great