Page 1 of 3

On coding using if command with races...

PostPosted: Thu Jul 30, 2015 1:05 am
by DrStrange
Identifying the race do you use:

player.Race == (int)eRace. etc
player.Race == # or name
eRace. # or name
both?


This is driving me crazy.

I'm looking to lock out all but certain races for use of a NPC.

Re: On coding using if command with races...

PostPosted: Thu Jul 30, 2015 7:46 am
by Graveen
player.Race == (int)eRace.xxx

Re: On coding using if command with races...

PostPosted: Thu Jul 30, 2015 8:38 am
by DrStrange
Yea I tried that it didn't work. =/

Re: On coding using if command with races...

PostPosted: Thu Jul 30, 2015 9:03 am
by HunabKu
Can you put a piece of code ?

Re: On coding using if command with races...

PostPosted: Thu Jul 30, 2015 12:54 pm
by elcotek
test this:
Code: Select all
if (player.Race == (int)eRace.Rogue == false)
Code: Select all
player.race = (int)eRace.Rogue;
i have not test, but this work only if the race directly writealble

Re: On coding using if command with races...

PostPosted: Thu Jul 30, 2015 2:15 pm
by HunabKu
@elcotek :
Code: Select all
if (player.Race == (int)eRace.Rogue == false)
- Rogue is player class, not player race
- why using == false after already comparaison ?


@DrStrange :
If you want to set player race, set it by database.
If you want to compare, use like this :
Code: Select all
string PlayerRace = ""; if (player.Race == (short)eRace.Briton) { PlayerRace = "Briton"; } else { PlayerRace = "Unknow"; }
If you tell to go to player.Race definition, you can see his type is short.

Re: On coding using if command with races...

PostPosted: Thu Jul 30, 2015 8:17 pm
by Neira
@elcotek :
Code: Select all
if (player.Race == (int)eRace.Rogue == false)
- Rogue is player class, not player race
- why using == false after already comparaison ?


@DrStrange :
If you want to set player race, set it by database.
If you want to compare, use like this :
Code: Select all
string PlayerRace = ""; if (player.Race == (short)eRace.Briton) { PlayerRace = "Briton"; } else { PlayerRace = "Unknow"; }
If you tell to go to player.Race definition, you can see his type is short.



Like this?



string PlayerRace = "Inconnu";
if (player.Race == (short)eRace.Inconnu) { PlayerRace = "Inconnu"; }
else { PlayerRace = "Theurgist"; } or Elementalist

Re: On coding using if command with races...

PostPosted: Fri Jul 31, 2015 6:50 am
by HunabKu
Theurgist and Elementalist are Classes, not Race 8)

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 7:46 pm
by DrStrange
The object was to take a class/combo npc that can make any race into any class and convert it to lock out all races except the one we want to be able to make w/e class.

Editing the classes was easy however there is no code that checks the race wanting to change to said class:

So it's just allowing all races to be w/e .

Tolk made this NPC code
Code: Select all
namespace DOL.GS.Scripts { public class AlbionClassSelector : GameNPC { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private enum eCharacterClass : byte { //alb classes Armsman = 2, Cabalist = 13, Cleric = 6, Friar = 10, Heretic = 33, Infiltrator = 9, Mercenary = 11, Minstrel = 4, Necromancer = 12, Paladin = 1, Reaver = 19, Scout = 3, Sorcerer = 8, Theurgist = 5, Wizard = 7, MaulerAlb = 60, } public override eQuestIndicator GetQuestIndicator(GamePlayer player) { if (player.Level == 5) return eQuestIndicator.Available; return eQuestIndicator.None; } public override bool Interact(GamePlayer p) { GamePlayer player = p as GamePlayer; if (p == null) return false;
There is no eRace check to lock out using the npc. For instance we would just delete said classes down to a Thuerg and would like to place a eRace check on the NPC so only a Inconnu can use it instead of everybody.

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 8:49 pm
by rdsandersjr
Here is a snipplet of what you want todo... of course you can use if elseif ect.. or select case.

Races:
Code: Select all
if (player.Race == (int)eRace.AlbionMinotaur) { player.Out.SendMessage("Sorry Minotaur, HalfOgre, Frostalf, and Shar's are disabled on this server.\n\nPlease see the race changer to my right.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); return false; }
Classes:
Code: Select all
if (player.CharacterClass.ID == (int) eCharacterClass.Bainshee) { player.Out.SendMessage("Sorry but Bainshee, Heretic, Maulers, Valkyrie, and Vampiir is disabled on this server. Please see the class change to my right", eChatType.CT_Say, eChatLoc.CL_PopupWindow); return false; }
dont forget to update the player ect.. or else you will only get the physical results, aka no stat changes ect..

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 9:23 pm
by DrStrange
The code Im looking for is more like "Sorry this feature is for Inconnu only" so instead of blocking xx races it just allows JUST the inconnu to use the NPC. The classes are already correct it's just narrowing it to the race using the NPC.

The NPC does level check make sure you 5th level why can't it just do a Inconnu eRace check like the level one. I tried every kind of way to code this in and it wouldnt work.

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 10:50 pm
by rdsandersjr
This is basic c# nothing todo with DOL

I told you how todo it you just got to change the operator
Code: Select all
if (player.Race != (int)eRace.Inconnu) { player.Out.SendMessage("Sorry Inconnu only!.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); return false; }

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 11:36 pm
by DrStrange
Error every time.

code path didn't return a value.I don't think this can actually be done at this point.

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 11:41 pm
by rdsandersjr
Sure it can... Analyze the trainers it clearly shows a working example.

Re: On coding using if command with races...

PostPosted: Mon Aug 03, 2015 11:42 pm
by rdsandersjr
Post your full code and I will help point out the issue. Not just a snippet the full class please