How to create actors in game using Y_INI/ZCMD -
Antoniohl - 07.05.2015
I've just made it for someone in scripting help so i will share it here too..
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;
}
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
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;
}
Here's a picture
![](http://s30.postimg.org/phkokrss1/sa_mp_000.png)
Have fun.
Re: How to create actors in game using Y_INI/ZCMD -
aCloudy - 07.05.2015
Great!
Re: How to create actors in game using Y_INI/ZCMD -
J0sh... - 07.05.2015
I'm sorry but what?!:
pawn Code:
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "You're not logged in");
Re: How to create actors in game using Y_INI/ZCMD -
Antoniohl - 07.05.2015
Quote:
Originally Posted by JamesCaptGeneral
I'm sorry but what?!:
pawn Code:
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "You're not logged in");
|
Oh.. i meant IsPlayerAdmin(playerid), thanks
Re: How to create actors in game using Y_INI/ZCMD -
Beckett - 07.05.2015
Quite simple but might be useful for others, good job.
Re: How to create actors in game using Y_INI/ZCMD -
manishmulchandani11 - 07.05.2015
Great work, good for newbies (especially me xD)
Re: How to create actors in game using Y_INI/ZCMD -
Antoniohl - 07.05.2015
Thanks , enjoy xD
Re: How to create actors in game using Y_INI/ZCMD -
036 - 07.05.2015
Really useful.
Re: How to create actors in game using Y_INI/ZCMD -
LMaxCo - 07.05.2015
Nice tutorial
Re: How to create actors in game using Y_INI/ZCMD -
Lordzy - 07.05.2015
This isn't how you write a tutorial. Why didn't you simply release it as a filterscript if you haven't explained anything?
Re: How to create actors in game using Y_INI/ZCMD -
Toxik - 07.05.2015
what are even the actors ?
what is their functions ?
im asking cuz i dont wanna add a script to server without to know what is
Re: How to create actors in game using Y_INI/ZCMD -
AndreiWow - 04.09.2015
D:\server\samp\pawno\include\YSI\y_utils.inc(343) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\pawno\include\YSI\y_utils.inc(497) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\pawno\include\YSI\y_utils.inc(540) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\pawno\include\YSI\y_utils.inc(55
![Cool](images/smilies/cool.gif)
: warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\pawno\include\YSI\y_malloc.inc(216) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\pawno\include\sscanf.inc(3) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(131) : error 004: function "CreateActorInformation" is not implemented
D:\server\samp\gamemodes\abrffnew.pwn(170) : error 055: start of function body without function header
D:\server\samp\gamemodes\abrffnew.pwn(172) : error 017: undefined symbol "idx"
D:\server\samp\gamemodes\abrffnew.pwn(173) : error 021: symbol already defined: "format"
D:\server\samp\gamemodes\abrffnew.pwn(177) : error 010: invalid function or declaration
D:\server\samp\gamemodes\abrffnew.pwn(261) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(359) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(577) : warning 235: public function lacks forward declaration (symbol "OnPlayerFullyConnected")
D:\server\samp\gamemodes\abrffnew.pwn(592) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(605) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(659) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(659) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(690) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(714) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(75
![Cool](images/smilies/cool.gif)
: warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(777) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(811) : error 004: function "CreateActorInformation" is not implemented
D:\server\samp\gamemodes\abrffnew.pwn(821) : warning 219: local variable "string" shadows a variable at a preceding level
D:\server\samp\gamemodes\abrffnew.pwn(836) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(837) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(841) : error 017: undefined symbol "CreateDynamic3DTextLabel"
D:\server\samp\gamemodes\abrffnew.pwn(841) : warning 213: tag mismatch
D:\server\samp\gamemodes\abrffnew.pwn(843) : error 004: function "CreateActorInformation" is not implemented
D:\server\samp\gamemodes\abrffnew.pwn(863) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(865) : warning 217: loose indentation
D:\server\samp\gamemodes\abrffnew.pwn(865) : error 004: function "DestroyDynamic3DTextLabel" is not implemented
D:\server\samp\gamemodes\abrffnew.pwn(866) : error 004: function "CreateActorInformation" is not implemented
D:\server\samp\gamemodes\abrffnew.pwn(870) : warning 203: symbol is never used: "string"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
10 Errors.
Re: How to create actors in game using Y_INI/ZCMD -
YoussefHammad - 04.09.2015
since its a [
Tutorial] i think you should explain what u did instead of just giving it out for everyone to copy/paste without understanding anything in it. so they can edit it in the future by themselves :3
Re: How to create actors in game using Y_INI/ZCMD -
Roberto80 - 05.09.2015
Just make it a FS,its good
Re: How to create actors in game using Y_INI/ZCMD -
SoFahim - 05.09.2015
Quote:
Originally Posted by Roberto80
Just make it a FS,its good
|
you should make it yourself. It very simple
just put that
in OnGameModeInit ( OnFiterScriptInit) simple
Re: How to create actors in game using Y_INI/ZCMD -
XXpro - 22.05.2018
That's cool mate