On coding using if command with races...

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

On coding using if command with races...

Postby DrStrange » Thu Jul 30, 2015 1:05 am

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.
DrStrange
 

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

Postby Graveen » Thu Jul 30, 2015 7:46 am

player.Race == (int)eRace.xxx
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

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

Postby DrStrange » Thu Jul 30, 2015 8:38 am

Yea I tried that it didn't work. =/
DrStrange
 

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

Postby HunabKu » Thu Jul 30, 2015 9:03 am

Can you put a piece of code ?
"C'est l'ignorance qui apporte le chaos, pas la connaissance."
Scarlett Johansson dans "Lucy" de Luc Besson
-------------------------------------------------------------------------------
"Ignorance brings chaos, not knowledge."
Scarlett Johansson on "Lucy" by Luc Besson
User avatar
HunabKu
Developer
 
Posts: 1905
Joined: Sat Jun 18, 2011 4:48 am

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

Postby elcotek » Thu Jul 30, 2015 12:54 pm

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
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 177
Joined: Mon May 12, 2008 9:28 pm
Website: http://brotherland-2.de
Location: Germany

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

Postby HunabKu » Thu Jul 30, 2015 2:15 pm

@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.
"C'est l'ignorance qui apporte le chaos, pas la connaissance."
Scarlett Johansson dans "Lucy" de Luc Besson
-------------------------------------------------------------------------------
"Ignorance brings chaos, not knowledge."
Scarlett Johansson on "Lucy" by Luc Besson
User avatar
HunabKu
Developer
 
Posts: 1905
Joined: Sat Jun 18, 2011 4:48 am

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

Postby Neira » Thu Jul 30, 2015 8:17 pm

@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
Neira
 

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

Postby HunabKu » Fri Jul 31, 2015 6:50 am

Theurgist and Elementalist are Classes, not Race 8)
"C'est l'ignorance qui apporte le chaos, pas la connaissance."
Scarlett Johansson dans "Lucy" de Luc Besson
-------------------------------------------------------------------------------
"Ignorance brings chaos, not knowledge."
Scarlett Johansson on "Lucy" by Luc Besson
User avatar
HunabKu
Developer
 
Posts: 1905
Joined: Sat Jun 18, 2011 4:48 am

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

Postby DrStrange » Mon Aug 03, 2015 7:46 pm

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.
DrStrange
 

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

Postby rdsandersjr » Mon Aug 03, 2015 8:49 pm

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..
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio

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

Postby DrStrange » Mon Aug 03, 2015 9:23 pm

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.
DrStrange
 

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

Postby rdsandersjr » Mon Aug 03, 2015 10:50 pm

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; }
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio

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

Postby DrStrange » Mon Aug 03, 2015 11:36 pm

Error every time.

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

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

Postby rdsandersjr » Mon Aug 03, 2015 11:41 pm

Sure it can... Analyze the trainers it clearly shows a working example.
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio

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

Postby rdsandersjr » Mon Aug 03, 2015 11:42 pm

Post your full code and I will help point out the issue. Not just a snippet the full class please
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest