• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Vocation with different corpses (script that indentifies sex)

Kakaher

Member
Joined
Nov 2, 2009
Messages
129
Reaction score
7
Hello everybody!

So I'm trying to make different corpses for each vocation..
I used the script by Doggynub, wich works flawlessly, but the problem is that it can't "see" the sex of the player... So I tried a lot of ways to make it work with sex but I couldn't...

Here is the script:

it is in player.cpp

Code:
uint16_t malehuman, femalehuman, dwarf, elf, orc, defaultt = 0;

    /*Config */

    malehuman = 6080;  // copse for sorcerer

    femalehuman = 6081;  // copse for sorcerer

    dwarf = 6007;    // copse for druid

    elf = 6003;    // copse for paladin

    orc = 5966;    // copse for knight
        
    defaultt = 6080;    // copse for vocations not mentioned up, like if he has no vocation

    /*End */

    if (getVocationId() == 1 and Sex % 2 || getVocationId() == 7 and Sex % 2 )
                return malehuman;
  return femalehuman;

    else if (getVocationId() == 2 || getVocationId() == 8)
        return dwarf; 

    else if (getVocationId() == 3 || getVocationId() == 9) 
        return  elf;  

    else if (getVocationId() == 4 || getVocationId() == 5 || getVocationId() == 6 || getVocationId() == 10 || getVocationId() == 11 || getVocationId() == 12) 
        return orc;   

    return defaultt;  
}

I also tried getPlayerSex() == 0 but also didnt work, this is the error I get when I try to comp:

Code:
 E:\player.cpp In member function `virtual uint16_t Player::getLookCorpse() const':
776 E:\player.cpp `Sex' was not declared in this scope 
780 E:\player.cpp expected primary-expression before "else"
780 E:\player.cpp expected `;' before "else"  
783 E:\player.cpp expected primary-expression before "else"  
783 E:\player.cpp expected `;' before "else" 
786 E:\player.cpp expected primary-expression before "else" 
786 E:\player.cpp expected `;' before "else"
 E:\\dev-cpp\Makefile.win [Build Error]  [obj//player.o] Error 1

Could anyone help me please ? =p

Thanks already A LOT!!!
 
Use [code][/code] tags, then you can post as much as you want.

Nevermind, it is too long, I didn't think the character capacity would matter.
 
This can be done through lua i think... (onDeath)

I´m thinking exactly this

So, I did this:

on creaturescripts I create a corpse.lua
Code:
function onDeath(cid, corpse)
local array = {
   [1] = 6080,
   [0] = 6081,
}

for vocation, itemid in pairs(array) do
if getPlayerVocation(cid) == 1 or getPlayerVocation (cid) == 7 then
doTransformItem(corpse.uid, array[getPlayerSex(cid)],1)
doDecayItem(corpse.uid)
break
end
end
return true
end

on login.lua
Code:
registerCreatureEvent(cid, "SetPlayerCorpseOut")

and on creaturescripts.xml
Code:
<event type="death" name="SetPlayerCorpseOut" event="script" value="corpse.lua"/>

but it doesn't work, no errors on console or on the server, or anywhere it just doesn't work...

If you have any idea on how to help me out, I'd be really thankfull =DD
 
Try this:
[CPP]
uint16_t Player::getLookCorpse(uint16_t sex) const
{ /* Config */
uint16_t malehuman = 6080; // corpse for sorcerer
uint16_t femalehuman = 6081; // corpse for sorcerer
uint16_t dwarf = 6007; // corpse for druid
uint16_t elf = 6003; // corpse for paladin
uint16_t orc = 5966; // corpse for knight
uint16_t defaultcorpse = 6080; // corpse for vocations not mentioned up, like if he has no vocation /* End */
switch(getVocationId())
{
case 1: case 7:
if(sex % 2 == 0)
return malehuman;
else
return femalehuman;
case 2: case 8:
return dwarf;
case 3: case 9:
return elf;
case 4: case 5: case 6: case 10: case 11: case 12:
return orc;
default:
return defaultcorpse;
}
}[/CPP]

But anyways...how are you planning to use the getLookCorpse(sex) function?

EDIT: Looking better at it...a LUA script would be better in this case.
 
Last edited:
Try this:
[CPP]
uint16_t Player::getLookCorpse(uint16_t sex) const
{ /* Config */
uint16_t malehuman = 6080; // corpse for sorcerer
uint16_t femalehuman = 6081; // corpse for sorcerer
uint16_t dwarf = 6007; // corpse for druid
uint16_t elf = 6003; // corpse for paladin
uint16_t orc = 5966; // corpse for knight
uint16_t defaultcorpse = 6080; // corpse for vocations not mentioned up, like if he has no vocation /* End */
switch(getVocationId())
{
case 1: case 7:
if(sex % 2 == 0)
return malehuman;
else
return femalehuman;
case 2: case 8:
return dwarf;
case 3: case 9:
return elf;
case 4: case 5: case 6: case 10: case 11: case 12:
return orc;
default:
return defaultcorpse;
}
}[/CPP]

But anyways...how are you planning to use the getLookCorpse(sex) function?

EDIT: Looking better at it...a LUA script would be better in this case.


Didn't work =(
got this:
Code:
756 E:\player.cpp prototype for `uint16_t Player::getLookCorpse(uint16_t) const' does not match any in class `Player'
805 E:\player.h virtual uint16_t Player::getLookCorpse() const 
 E:\dev-cpp\Makefile.win [Build Error]  [obj//player.o] Error 1

Do you know what is it ?
 
Yeah, sorry forgot about that part. You have to declare it in player.h.
Shorter:
[CPP]
uint16_t Player::getLookCorpse() const
{
uint16_t corpse;
switch(getVocationId())
{
case 1: case 7:
if(sex % 2 == 0)
corpse = 6080; // corpse for sorcerer (male)
else
corpse = 6081; // corpse for sorcerer (female)
break;
case 2: case 8:
corpse = 6007; // corpse for druid (dwarf)
break;
case 3: case 9:
corpse = 6003; // corpse for paladin (elf)
break;
case 4: case 5: case 6: case 10: case 11: case 12:
corpse = 5966; // corpse for knight (orc)
break;
default:
corpse = 6080; // corpse for vocations not mentioned up, like if he has no vocation
}
return corpse;
}[/CPP]

EDIT: Don't do this vvv
In player.h below:
[CPP]class Player : public Creature, public Cylinder
{
public:[/CPP]
paste:
[CPP]uint16_t Player::getLookCorpse(uint16_t sex) const;[/CPP]
 
Last edited:
Yeah, sorry forgot about that part. You have to declare it in player.h.
Shorter:
[CPP]
uint16_t Player::getLookCorpse(uint16_t sex) const
{
uint16_t corpse;
switch(getVocationId())
{
case 1: case 7:
if(sex % 2 == 0)
corpse = 6080; // corpse for sorcerer (male)
else
corpse = 6081; // corpse for sorcerer (female)
break;
case 2: case 8:
corpse = 6007; // corpse for druid (dwarf)
break;
case 3: case 9:
corpse = 6003; // corpse for paladin (elf)
break;
case 4: case 5: case 6: case 10: case 11: case 12:
corpse = 5966; // corpse for knight (orc)
break;
default:
corpse = 6080; // corpse for vocations not mentioned up, like if he has no vocation
}
return corpse;
}[/CPP]

In player.h below:
[CPP]class Player : public Creature, public Cylinder
{
public:[/CPP]
paste:
[CPP]uint16_t Player::getLookCorpse(uint16_t sex) const[/CPP]

I don't know why, but it bugged the actions.cpp

Code:
23 E:\actions.cpp In file included from ../actions.cpp 
144 E:\player.h expected `;' before "static" 
 E:\dev-cpp\Makefile.win [Build Error]  [obj//actions.o] Error 1

Dude, I'm sorry if I'm boring you... Even if it doesn't work I'll give you REP+ just because of your effort!
But it WILL work! haha =p

---EDIT
BTW, my player.h was like this
Code:
class Player : public Creature, public Cylinder
{
	public:
		
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
		static uint32_t playerCount;
#endif

Player(const std::string& name, ProtocolGame* p);
		virtual ~Player();

and now it is like this:

Code:
class Player : public Creature, public Cylinder
{
	public:
		
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
		static uint32_t playerCount;
#endif
		uint16_t Player::getLookCorpse(uint16_t sex) const

Player(const std::string& name, ProtocolGame* p);
		virtual ~Player();

		virtual Player* getPlayer() {return this;}
		virtual const Player* getPlayer() const {return this;}

		static MuteCountMap muteCountMap;

Perhaps I did something wrong ?
 
Missing ";" lol

LOL
That was stupid!

but, still isn´t working = /

now the error is this one:
Code:
  [Linker error] undefined reference to `Player::getLookCorpse() const' 
 E:\dev-cpp\Makefile.win [Build Error]  [TheForgottenServer.exe] Error 1
 
Last edited:
Oh wow I never thought this was about you wanting to modify a function that already existed in TFS...I thought this was something new.

Anyways then...
Use this:
[CPP]
uint16_t Player::getLookCorpse() const
{
uint16_t corpse;
switch(getVocationId())
{
case 1: case 7:
if(sex % 2 == 0)
corpse = 6080; // corpse for sorcerer (male)
else
corpse = 6081; // corpse for sorcerer (female)
break;
case 2: case 8:
corpse = 6007; // corpse for druid (dwarf)
break;
case 3: case 9:
corpse = 6003; // corpse for paladin (elf)
break;
case 4: case 5: case 6: case 10: case 11: case 12:
corpse = 5966; // corpse for knight (orc)
break;
default:
corpse = 6080; // corpse for vocations not mentioned up, like if he has no vocation
}
return corpse;
}[/CPP]
and delete what I told you to put in player.h.
 
Man, it is working perfectly!! You are amazing!!!
Thank you sooo much for the help!!
REP+

The only thing though is that the bodies were changed male was diyng female and vice-versa, just changed
Code:
if(sex % 2 == 0)
to
Code:
if(sex % 2 == 1)
 
Well, that's a way of fixing it although you just had to change the corpse id :p.
Like this:
[CPP]
if(sex % 2 == 0)
corpse = 6081; // corpse for sorcerer (female)
else
corpse = 6080; // corpse for sorcerer (male)
break;[/CPP]
 
Back
Top