//Id enjoy help.. :/ Im out of ideas.. i dont know what im doing wrong
// (In the source its a different void wich inserts the data.. not int main Since its a plugin loaded into a programm)
//I located the position where it crashes see: ZData::Find @ the second printf
// .cpp
PData **PDatas = 0; // I dont know this 1 either.. (Seems to create PDatas, but of what/to what.. 0..?
void ZData::Startup() //I Init. on start
{
PDatas = (PData **)malloc(sizeof(PData) * 128);
memset((void *)PDatas, 0, sizeof(PData) * 128);
printf("zdata Startup\n");
}
void ZData::Shutdown() //And this on Quit
{
for (int i = 0; i < 128; ++i)
{
if (PDatas[i] != 0)
{
free((void *)PDatas[i]);
}
}
PDatas = 0;
printf("zdata shutdown\n");
}
PData *ZData::Find(int ID) //tbh i dunno whats this for (Some1 told me i need this.. idk whats it for (
{
printf("Do you crash!?\n"); //If this message shows up.. i atleast know it crashes after this
if(!PDatas)
{
printf("Do you get PDatas at all?\n"); //doesnt show up.
return 0;
}
if(!PDatas[ID])
{
printf("Do you get PDatas ID?\n"); //Crashes here.. this message shows up
return 0;
}
return PDatas[ID];
printf("Well crash?\n");
}
int main(int ID,constchar *Nick) {
PData *p = ZData::Find(ID);
p[ID].SomeDistance=1;
p[ID].SomeNumber=1;
p[ID].ID=ID;
p[ID].Name=Nick;
}
//.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct PData
{
int SomeDistance;
int SomeNumber;
int ID;
constchar *Name;
cPlayer *data;
};
class ZData
{
public:
staticvoid Startup();
staticvoid Shutdown();
static PData *Find(int ID);
};
but if i change it in the int i also have to change it in the struct.. ? If im right.. and if i do that.. whats the reason why ive done that?
You have to change it because main(...) takes an int and an array of char* (char**) as arguments.
You do not have to modify the struct. Instead do something like: