• 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!

Compiling get current player

Milice

Nutjob
Joined
Oct 4, 2008
Messages
954
Solutions
2
Reaction score
157
Location
Sverige ;D
Hey there OTLanders, i'm having this issue... i'm not sure if it's me overthinking it or if it just isn't possible..

Any help or tips would be greatly appreciated ^_^

[[ This is TFS 0.2.15 btw ]]

Whenever i call the function " player->getStorageValue " my tfs crashes u.u
 
Last edited:
You must post more of your code, otherwise we can just guess what you're doing wrong.

Most likely the variable "player" is either 0 at this location or the player object was already deleted.

Whatever you are trying to achieve, you should try to do it in LUA.
 
You must post more of your code, otherwise we can just guess what you're doing wrong.

Most likely the variable "player" is either 0 at this location or the player object was already deleted.

Whatever you are trying to achieve, you should try to do it in LUA.

Shit, forgot to attach the code, however other player functions works..
When the "key" is a const uin32_t it works, if it's nor a const, crash
 
Shit, forgot to attach the code, however other player functions works..
When the "key" is a const uin32_t it works, if it's nor a const, crash
That parameter is made const because you're supposed to pass a numeric constant.
Need to see code before saying an appropriate solution, though.
 
That parameter is made const because you're supposed to pass a numeric constant.
Need to see code before saying an appropriate solution, though.

But there's no error or even warnings when compiling, that's what is kinda f*cking me over right now

Guess this is the relevant part:
Includes:
Code:
#include "otpch.h"

#include "definitions.h"
#include "outfit.h"
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include "creature.h"
#include "player.h"
#include "tools.h"
#include "game.h"
extern Game g_game;
Code:
Code:
Outfit outfit;
						std::string outfitName;
						bool outfitEnabled = true;
						uint32_t outfitStorage;
						int32_t storageValue;
						Player* player;

						readXMLString(p, "name", outfitName);
						if(readXMLInteger(p, "looktype", intVal))
						{
							outfit.looktype = intVal;
							if(readXMLInteger(p, "addons", intVal))
								outfit.addons = intVal;
							else
								outfit.addons = 0;

							if(readXMLInteger(p, "premium", intVal))
								outfit.premium = (intVal == 1);
							else
								outfit.premium = false;

							if(readXMLInteger(p, "enabled", intVal))
								outfitEnabled = (intVal == 1);

							if(readXMLInteger(p, "storage", intVal))
								outfitStorage = intVal;
							else
								outfitStorage = 0;

							outfitNamesMap[outfit.looktype] = outfitName;
							if(outfitEnabled)
							{
								if(outfitStorage != 0){
									player->getStorageValue(outfitStorage, storageValue);
									if(storageValue == 1)
										list->addOutfit(outfit);
								}
								else
									list->addOutfit(outfit);
							}
 
uhm...

  1. You declared a variable player but didn't assign anything to it. Thus it points to some random location in memory which causes a crash when you try to use the variable.
  2. You cannot change any players in outfits.cpp while loading the outfits.

What are you trying to achieve?
 
uhm...

  1. You declared a variable player but didn't assign anything to it. Thus it points to some random location in memory which causes a crash when you try to use the variable.
  2. You cannot change any players in outfits.cpp while loading the outfits.

What are you trying to achieve?

Yeah, i haven't been programming a lot in C++ lately lol..
But what i'm trying to achieve is storage based outfits OR as they might be called " quest " oufits, if player have the storage value then he can wear it.. It's in there by default in Crying Damson, but i was forced to use Mystic Spirit u.u
 
Yeah, i haven't been programming a lot in C++ lately lol..
But what i'm trying to achieve is storage based outfits OR as they might be called " quest " oufits, if player have the storage value then he can wear it.. It's in there by default in Crying Damson, but i was forced to use Mystic Spirit u.u
Then store the storage value in Outfit and check if he has it in ProtocolGame::sendCreatureOutfit, like so:

[cpp]const Player* player = creature->getPlayer();
if (player) {
outfit = player->getOutfit();
....
}[/cpp]
 
Then store the storage value in Outfit and check if he has it in ProtocolGame::sendCreatureOutfit, like so:

[cpp]const Player* player = creature->getPlayer();
if (player) {
outfit = player->getOutfit();
....
}[/cpp]

That's a nice idea ^^ i can just not let the player use it :3
 
Back
Top