07.05.2015, 09:45
(
Last edited by Antoniohl; 07/05/2015 at 10:52 AM.
)
I've just made it for someone in scripting help so i will share it here too..
First
now commands.. you'll have to use the first command in game to create the files in the directory so you'll be able to create actors
Here's a picture
Have fun.
First
Code:
#define ACTOR_DATA "Actors/%d" #define MAX_ACTORSS (200)
Code:
enum aInfo { aSkin, aName[32], Text3D:aText, 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 SaveActors(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_WriteString(File,"Name", ActorInfo[idx][aName]); 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_String("Name", ActorInfo[idx][aName], 32); 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); { new string[500]; DestroyDynamic3DTextLabel(ActorInfo[idx][aText]); format(string, sizeof(string), "{00A2FF}%s (%d)", ActorInfo[idx][aName], idx); ActorInfo[idx][aText] = CreateDynamic3DTextLabel(string,-1, ActorInfo[idx][aPosX], ActorInfo[idx][aPosY], ActorInfo[idx][aPosZ]+1,6.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1,0,0); CreateActor(ActorInfo[idx][aSkin], ActorInfo[idx][aPosX], ActorInfo[idx][aPosY], ActorInfo[idx][aPosZ], ActorInfo[idx][aPosA]); SetActorVirtualWorld(idx, ActorInfo[idx][aVW]); return 1; }
Code:
CMD:resetallactors(playerid, params[]) { if(IsPlayerAdmin(playerid)) { for(new id = 0; id < MAX_ACTORSS; id ++) { CreateActorInformation(id); SaveActors(id); } SendClientMessage(playerid, -1, "You've created the files."); } else SendClientMessage(playerid, -1, "You're not authorized to use this command"); return 1; }
Code:
CMD:createactor(playerid, params[]) { new skin, text[32], string[128]; if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You can't do that in a vehicle."); if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You're not authorized to use this command"); if(sscanf(params, "is[32]", skin, text)) { SendClientMessage(playerid, -1, "/createactor [skin] [name]"); return 1; } if(skin > 311 || skin < 0) return SendClientMessage(playerid, -1, "Skin ID is invalid(0-311)."); for(new idx=0; idx<MAX_ACTORSS; idx++) { if(ActorInfo[idx][aPosX] == 0.0) { GetPlayerPos(playerid, ActorInfo[idx][aPosX], ActorInfo[idx][aPosY], ActorInfo[idx][aPosZ]); GetPlayerFacingAngle(playerid, ActorInfo[idx][aPosA]); SetActorVirtualWorld(playerid, GetPlayerVirtualWorld(playerid)); ActorInfo[idx][aSkin] = skin; format(ActorInfo[idx][aName], 32, "%s", text); format(string,sizeof(string),"{00A2FF}%s (%d)", text ,idx); ActorInfo[idx][aText] = CreateDynamic3DTextLabel(string,-1,ActorInfo[idx][aPosX],ActorInfo[idx][aPosY],ActorInfo[idx][aPosZ]+1,8.0); CreateActorInformation(idx); SaveActors(idx); idx = MAX_ACTORSS; } } return 1; }
Code:
CMD:deleteactor(playerid, params[]) { new id; if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You're not authorized to use this command"); if(sscanf(params, "i", id)) return SendClientMessage(playerid, -1, "/deleteactor [id]"); if(ActorInfo[id][aPosX] == 0.0) return SendClientMessage(playerid, -1, "Invaild ID"); ActorInfo[id][aSkin] = 0; format(ActorInfo[id][aName], 32, "None"); ActorInfo[id][aPosX] = 0; ActorInfo[id][aPosY] = 0; ActorInfo[id][aPosZ] = 0; ActorInfo[id][aPosA] = 0; ActorInfo[id][aVW] = 0; DestroyActor(id); DestroyDynamic3DTextLabel(ActorInfo[id][aText]); CreateActorInformation(id); SaveActors(id); return 1; }
Have fun.