Loading Problem
#1

Hello, I created actors system, But they are not getting loaded.
Can someone tell me what is the problem ?

Code:
forward LoadActor_data(name[],value[]);
public LoadActor_data(name[],value[])
{
	new ActorInfo[2],Float:Pos[4];
	INI_Int("Skin",ActorInfo[0]);
	INI_Float("PosX",Pos[0]);
	INI_Float("PosY",Pos[1]);
	INI_Float("PosZ",Pos[2]);
	INI_Float("Angle",Pos[3]);
	INI_Int("VirtualWorld",ActorInfo[1]);
	new Actor = CreateActor(ActorInfo[0], Pos[0], Pos[1], Pos[2], Pos[3]);
	SetActorVirtualWorld(Actor, ActorInfo[1]);
 	return 1;
}

OnGameModeInit()
{
	for(new actorid=0; actorid < MAX_ACTORS; actorid++)
	{
		INI_ParseFile(ActorPath(actorid), "LoadActor_%s");
	}
        return 1;
}
Reply
#2

Code:
#define ACTOR_DATA "Actors/%d.ini"
forward LoadActors();
public LoadActors()
{
	new actor[64];
	for(new idx = 0; idx < sizeof(ActorInfo); idx++)
	{
		format(actor, 64, ACTOR_DATA, idx);
		INI_ParseFile(actor, "LoadActor_data", .bExtra = true, .extra = idx );
	}
	print("*Actors loaded correctly.");
	return 1;
}
change ActorInfo to your enum information
and OnGameModeInIt
write LoadActors();
Reply
#3

Quote:
Originally Posted by Antoniohl
View Post
Code:
forward LoadActors();
public LoadActors()
{
	new actor[64];
	for(new idx = 0; idx < sizeof(ActorInfo); idx++)
	{
		format(actor, 64, MAX_ACTORS, idx);
		INI_ParseFile(Actor, "LoadActor_data", .bExtra = true, .extra = idx );
	}
	print("*Actors loaded correctly.");
	return 1;
}
change ActorInfo to your enum information
I'm not so good at scripting, Can you just do it for me ?
I think there's something wrong below:
Code:
enum ActorInfo
{
	Skin,
	PosX,
	PosY,
	PosZ,
	PosFA,
	World
}

forward LoadActor_data(name[],value[]);
public LoadActor_data(name[],value[])
{
	new Actor;
	INI_Int("Skin",acData[Actor][Skin]);
	INI_Float("PosX",acData[Actor][PosX]);
	INI_Float("PosY",acData[Actor][PosY]);
	INI_Float("PosZ",acData[Actor][PosZ]);
	INI_Float("Angle",acData[Actor][PosFA]);
	INI_Int("VirtualWorld",acData[Actor][World]);
	Actor = CreateActor(acData[Actor][Skin], acData[Actor][PosX], acData[Actor][PosY], acData[Actor][PosZ], acData[Actor][PosFA]);
	SetActorVirtualWorld(Actor, acData[Actor][World]);
 	return 1;
}

public LoadActors()
{
	new actor[64];
	for(new idx = 0; idx < sizeof(ActorInfo); idx++)
	{
		format(actor, 64, MAX_ACTORS, idx);
		INI_ParseFile(actor, "LoadActor_data", .bExtra = true, .extra = idx );
	}
	print("*Actors loaded correctly.");
	return 1;
}
Reply
#4

Alright be patient i will post the codes after 10minute's or less

EDIT

Create directory in your scriptfiles "Actors"

Code:
#define ACTOR_DATA         "Actors/%d.ini"
#define MAX_ACTORSS       (100)
Code:
enum aInfo
{
	aSkin,
	Float:aPosX,
	Float:aPosY,
	Float:aPosZ,
	Float:aPosA,
	aVW
}
new ActorInfo[MAX_ACTORSS][aInfo];

forward LoadActors();
public LoadActors()
{
	new Actor[64];
	for(new idx = 0; idx < sizeof(ActorInfo); idx++)
	{
		format(Actor, 64, ACTOR_DATA, idx);
		INI_ParseFile(Actor, "LoadActor_data", .bExtra = true, .extra = idx );
		if(ActorInfo[idx][aPosX] > 0.0)
		{
			CreateActorInformation(idx);
		}
	}
	print("*Actors loaded correctly.");
	return 1;
}

forward SaveActors(idx);
public SaveAcors(idx)
{
	new Actorfile[64];
	format(Actorfile, 64, ACTOR_DATA, idx);
	new INI:File = INI_Open(Actorfile);
	INI_SetTag(File,"Actor_Information");
	INI_WriteInt(File,"Skin", ActorInfo[idx][aSkin]);
	INI_WriteFloat(File,"PosX", ActorInfo[idx][aPosX]);
	INI_WriteFloat(File,"PosY", ActorInfo[idx][aPosY]);
	INI_WriteFloat(File,"PosZ", ActorInfo[idx][aPosZ]);
	INI_WriteFloat(File,"Angel", ActorInfo[idx][aPosA]);
	INI_WriteInt(File,"VirtualWorld", ActorInfo[idx][aVW]);
	INI_Close(File);
	return 1;
}

forward LoadActor_data(idx, name[], value[]);
public LoadActor_data(idx, name[], value[])
{
	INI_Int("Skin", ActorInfo[idx][aSkin]);
	INI_Float("PosX", ActorInfo[idx][aPosX]);
	INI_Float("PosY", ActorInfo[idx][aPosY]);
	INI_Float("PosZ", ActorInfo[idx][aPosZ]);
	INI_Float("Angel", ActorInfo[idx][aPosA]);
	INI_Int("VirtualWorld", ActorInfo[idx][aVW]);
	return 1;
}

forward CreateActorInformation(idx);
public CreateActorInformation(idx)
{
	CreateActor(ActorInfo[idx][aSkin], ActorInfo[idx][aPosX], ActorInfo[idx][aPosY], ActorInfo[idx][aPosZ], ActorInfo[idx][aPosA]);
	SetActorVirtualWorld(idx, ActorInfo[idx][aVW]);
	return 1;
}
Reply
#5

Quote:
Originally Posted by Antoniohl
View Post
Alright be patient i will post the codes after 10minute's or less

EDIT

Create directory in your scriptfiles "Actors"

Code:
#define ACTOR_DATA         "Actors/%d.ini"
#define MAX_ACTORSS       (100)
Code:
enum aInfo
{
	aSkin,
	Float:aPosX,
	Float:aPosY,
	Float:aPosZ,
	Float:aPosA,
	aVW
}
new ActorInfo[MAX_ACTORSS][aInfo];

forward LoadActors();
public LoadActors()
{
	new Actor[64];
	for(new idx = 0; idx < sizeof(ActorInfo); idx++)
	{
		format(Actor, 64, ACTOR_DATA, idx);
		INI_ParseFile(Actor, "LoadActor_data", .bExtra = true, .extra = idx );
		if(ActorInfo[idx][aPosX] > 0.0)
		{
			CreateActorInformation(idx);
		}
	}
	print("*Actors loaded correctly.");
	return 1;
}

forward SaveActors(idx);
public SaveAcors(idx)
{
	new Actorfile[64];
	format(Actorfile, 64, ACTOR_DATA, idx);
	new INI:File = INI_Open(Actorfile);
	INI_SetTag(File,"Actor_Information");
	INI_WriteInt(File,"Skin", ActorInfo[idx][aSkin]);
	INI_WriteFloat(File,"PosX", ActorInfo[idx][aPosX]);
	INI_WriteFloat(File,"PosY", ActorInfo[idx][aPosY]);
	INI_WriteFloat(File,"PosZ", ActorInfo[idx][aPosZ]);
	INI_WriteFloat(File,"Angel", ActorInfo[idx][aPosA]);
	INI_WriteInt(File,"VirtualWorld", ActorInfo[idx][aVW]);
	INI_Close(File);
	return 1;
}

forward LoadActor_data(idx, name[], value[]);
public LoadActor_data(idx, name[], value[])
{
	INI_Int("Skin", ActorInfo[idx][aSkin]);
	INI_Float("PosX", ActorInfo[idx][aPosX]);
	INI_Float("PosY", ActorInfo[idx][aPosY]);
	INI_Float("PosZ", ActorInfo[idx][aPosZ]);
	INI_Float("Angel", ActorInfo[idx][aPosA]);
	INI_Int("VirtualWorld", ActorInfo[idx][aVW]);
	return 1;
}

forward CreateActorInformation(idx);
public CreateActorInformation(idx)
{
	CreateActor(ActorInfo[idx][aSkin], ActorInfo[idx][aPosX], ActorInfo[idx][aPosY], ActorInfo[idx][aPosZ], ActorInfo[idx][aPosA]);
	SetActorVirtualWorld(idx, ActorInfo[idx][aVW]);
	return 1;
}
Added "LoadActors" to OnGameModeInit and no shit happens.
Why is that ?
Reply
#6

Wait, /createactor doesn't make files on the "Actors" folder anymore..

Code:
CMD:createactor(playerid, params[])
{
	new skin;
	if(AdminLevel[playerid] < 5) SCM(playerid, COLOR_WHITE, ""WORD_NADMIN"");
	else if(IsPlayerInAnyVehicle(playerid)) SCM(playerid, COLOR_WHITE, ""WORD_ERROR"You cannot create actors while inside a vehicle.");
	else if(sscanf(params, "i", skin)) SCM(playerid, COLOR_WHITE, ""WORD_USAGE"/createactor [SKIN_ID]");
	else if(!(0 <= skin < 312) || skin == 74) SCM(playerid, COLOR_WHITE, ""WORD_ERROR"Invalid skin ID.");
	else{
		new Float:X, Float:Y, Float:Z, Float:fa, world = GetPlayerVirtualWorld(playerid), Actor;
		GetPlayerPos(playerid, X, Y, Z);
		GetPlayerFacingAngle(playerid, fa);
		Actor = CreateActor(skin, X, Y, Z, fa);
		if(AddActor(Actor, skin, X, Y, Z, fa, world))
		{
			SetActorVirtualWorld(Actor, world);
			ClearActorAnimations(Actor);
			SetActorInvulnerable(Actor, true);
			new string[128];
			format(string, sizeof(string), ""WORD_SERVER"You have created a new actor with skin: %d", skin);
			SCM(playerid, COLOR_WHITE, string);
		}
	}
	return 1;

AddActor(actorid, skinid, Float:X, Float:Y, Float:Z, Float:A, VirtualWorld)
{
	if(actorid == INVALID_ACTOR_ID) return 0;

	new INI:File = INI_Open(ActorPath(actorid));
	if(File != INI_NO_FILE)
	{
		INI_SetTag(File,"data");
		INI_WriteInt(File,"Skin",skinid);
		INI_WriteFloat(File,"PosX",X);
		INI_WriteFloat(File,"PosY",Y);
		INI_WriteFloat(File,"PosZ",Z);
		INI_WriteFloat(File,"Angle",A);
		INI_WriteInt(File,"VirtualWorld",VirtualWorld);
		INI_Close(File);
		return 1;
	}
	return 0;
}

ActorPath(actorid)
{
	new string[32];
	format(string,sizeof(string),ACTOR_DATA,actorid);
	return string;
}
}
Reply
#7

Quote:
Originally Posted by aCloudy
View Post
Added "LoadActors" to OnGameModeInit and no shit happens.
Why is that ?
You've added LoadActors under OnGameModeInIt it will work if the actor is created but you've 0 i guess?, make a command to create actors

show me your /createactor command
Reply
#8

Quote:
Originally Posted by Antoniohl
View Post
You've added LoadActors under OnGameModeInIt it will work if the actor is created but you've 0 i guess?, make a command to create actors

show me your /createactor command
Look above (^).
Reply
#9

Huh.. lol delete those codes i will just make another one, be patient.

EDIT: i've made it but there's something missing i can't figure it out, actually it creates the actor, but if you've created another one it will replace with the same id.. lol i will share it when it's done anyway i've made it with 3dTextLabel too, so you can name the actor
Reply
#10

Quote:
Originally Posted by Antoniohl
View Post
Huh.. lol delete those codes i will just make another one, be patient.

EDIT: i've made it but there's something missing i can't figure it out, actually it creates the actor, but if you've created another one it will replace with the same id.. lol i will share it when it's done anyway i've made it with 3dTextLabel too, so you can name the actor
Okay thank you, Take your time!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)