Page 1 of 1

Player class check

Posted: Fri Dec 28, 2012 6:53 am
by kenzu38
Hi guyz, need help with two things:

1.) Code for checking if you're currently on your secondary class or tertiary class.

2.) Code for checking if you are currently playing a mage class.

Thanks.

Re: Player class check

Posted: Fri Dec 28, 2012 8:24 am
by rock5
kenzu38 wrote:1.) Code for checking if you're currently on your secondary class or tertiary class.
Hm... What makes a particular class your primary, secondary or tertiary class? If your primary class has the highest level then you can check the class levels. The values to check are

Code: Select all

player.Level      -- It's not a typo. There is no '1'.
player.Level2
player.Level3
kenzu38 wrote:2.) Code for checking if you are currently playing a mage class.
To check what exactly the classes are you would check

Code: Select all

player.Class1
player.Class2
player.Class3
Class is saved as numbers. You would use the class static variables for making comparisons eg.

Code: Select all

if player.Class1 == CLASS_MAGE then
    etc.
I hope that helps.

Re: Player class check

Posted: Fri Dec 28, 2012 9:48 am
by kenzu38
rock5 wrote:Hm... What makes a particular class your primary, secondary or tertiary class? If your primary class has the highest level then you can check the class levels.
I see, yea it would be hard to distinguish between them. Yes, I see, I could just check levels, good thing all my chars have their primary classes are at way higher levels than their secondary. Or else checking levels wouldn't work.
rock5 wrote:

Code: Select all

if player.Class1 == CLASS_MAGE then
    etc.

I hope that helps.
It sure does. Thanks a lot!

Re: Player class check

Posted: Fri Dec 28, 2012 11:41 am
by kenzu38
Ok so, I got the class check to work but I'm having problems with checking for levels. How exactly should I code it?

I have this right now:

Code: Select all

		if player.Level < player.Level2 or player.Level < player.Level3 then
			-- Wait for user to change class
			cprintf(cli.yellow,"You are not playing your highest level class, are you sure you want to continue\n")
			player:sleep()
			end	
It always errors. Can someone point out what I am doing wrong? Thanks.

Re: Player class check

Posted: Fri Dec 28, 2012 11:54 am
by rock5
If you are reporting an error you should include it to help us figure out what's wrong, otherwise we would have to guess. :)

So I'll guess, you got an "invalid token" error. This is because you used the code in an xml file and it assumed the < is a beginning of a 'token', ie. <waypoint, <onload etc. You can use '>' so just switch them around.

Code: Select all

      if player.Level2 > player.Level or player.Level3 < player.Level then

Re: Player class check

Posted: Fri Dec 28, 2012 2:08 pm
by kenzu38
Lol well, I had a hunch it was just some elementary syntax mistake that a newbie can easily overlook and an experienced coder would spot right away so I didn't bother posting what the error was. :D

But yes, you were right on the mark, it was an invalid token error. And I guess I was right on the mark that it was a basic mistake haha.

But yes, I admit it's not a good habit to post questions without the error messages so I'll try to keep this in mind next time.

Anyway, the check works fine now. Thanks a lot.

Though, I got a new code I need checked. Will this line work?

Code: Select all

sendMacro("ExchangeClass("..(CLASS_MAGE + 1)..", EXCHANGECLASS_SUBCLASS)");
It's because I want my code to be universal for all my mage chars with different subclasses. So I'm thinking of doing it like the above. So is it valid?

Thanks.

Edit: Ok, tried the above code just now and it didn't work, it only changed to Mage primary with no subclass.

Also tried this code:

Code: Select all

		local class1 = player.Class1
		sendMacro("ExchangeClass("..(CLASS_MAGE + 1)..","..class1..")");
Same thing, only changed to Mage with no subclass. So can anyone tell me how to do this properly? Thanks.

Re: Player class check

Posted: Fri Dec 28, 2012 3:33 pm
by rock5
kenzu38 wrote:sendMacro("ExchangeClass("..(CLASS_MAGE + 1)..", EXCHANGECLASS_SUBCLASS)");
Assuming the current main class is not Mage then I think what you want to do is move the main class into the sub class.

Code: Select all

sendMacro("ExchangeClass("..(CLASS_MAGE + 1)..", EXCHANGECLASS_MAINCLASS)");
That might work.
kenzu38 wrote: local class1 = player.Class1
sendMacro("ExchangeClass("..(CLASS_MAGE + 1)..","..class1..")");
You are forgetting the + 1.

Code: Select all

      local class1 = player.Class1
      sendMacro("ExchangeClass("..(CLASS_MAGE + 1)..","..(class1+1)..")");

Re: Player class check

Posted: Fri Dec 28, 2012 4:37 pm
by kenzu38
Hehe yea, figured the first one out earlier when I was testing. Just changed to MAINCLASS and the code worked. Though, I was really puzzled by the second one until you reminded me of the +1.

Anyway, both codes working fine now. As always, thanks a lot, rock!