function beingfollowed help

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Uniden65
Posts: 151
Joined: Thu Aug 20, 2009 5:17 pm

function beingfollowed help

#1 Post by Uniden65 » Mon Oct 15, 2012 5:54 pm

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
Last edited by Uniden65 on Mon Oct 22, 2012 12:00 pm, edited 1 time in total.

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: help please

#2 Post by BillDoorNZ » Mon Oct 15, 2012 10:13 pm

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

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: help please

#3 Post by BillDoorNZ » Mon Oct 15, 2012 10:14 pm

that code will do something once the 4th detection. I assume the calling function is incrementing the alarmnumber variable??

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: help please

#4 Post by botje » Tue Oct 16, 2012 6:58 am

thats not a bad function mate, very nice :)

Uniden65
Posts: 151
Joined: Thu Aug 20, 2009 5:17 pm

Re: help please

#5 Post by Uniden65 » Tue Oct 16, 2012 1:08 pm

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

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: help please

#6 Post by BillDoorNZ » Wed Oct 17, 2012 3:39 pm

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?

Uniden65
Posts: 151
Joined: Thu Aug 20, 2009 5:17 pm

Re: help please

#7 Post by Uniden65 » Thu Oct 18, 2012 11:21 am

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

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: help please

#8 Post by BillDoorNZ » Thu Oct 18, 2012 3:44 pm

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

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: help please

#9 Post by lisa » Thu Oct 18, 2012 7:00 pm

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)
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Uniden65
Posts: 151
Joined: Thu Aug 20, 2009 5:17 pm

Re: help please

#10 Post by Uniden65 » Sat Oct 20, 2012 7:47 am

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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 48 guests