15.08.2016, 07:11
Hello, I tried to make "/createactor" & "/deleteactor" commands, but "/deleteactor" isn't deleting right, I can create like 4 actors, and delete only 1 or 2 randomly.. please help
PHP код:
enum Actor
{
Float:aX,
Float:aY,
Float:aZ,
aID,
aSkin,
Text3D:aString
};
new ActorData[MAX_ACTORS][Actor];
new Actor_ID;
PHP код:
CMD:createactor(playerid, params[])
{
if(IsPlayerAnAdmin(playerid,3))
{
new modelid,string[200],Float:pos[4];
if(!sscanf(params, "i", modelid))
{
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
GetPlayerFacingAngle(playerid,pos[3]);
ActorData[Actor_ID][aID] = CreateActor(modelid,pos[0],pos[1]+0.5,pos[2],pos[3]);
SetActorInvulnerable(ActorData[Actor_ID][aID], false);
SetActorHealth(ActorData[Actor_ID][aID], 100);
format(string, sizeof(string), "ACTOR ID: %d and SKIN ID: %d",Actor_ID,modelid);
ActorData[Actor_ID][aString] = CreateDynamic3DTextLabel(string,ORANGE,pos[0],pos[1],pos[2],20,-1,0);
format(string, sizeof(string), "Actor created, SKIN ID: %d and ID: %d",modelid,Actor_ID); SCM(playerid,GREEN,string);
Actor_ID++;
}
else SCM(playerid,RED,"[INFO]: /createactor <skin>");
}
else SCM(playerid,RED,">> You are not an admin!");
return 1;
}
PHP код:
CMD:deleteactor(playerid, params[])
{
if(IsPlayerAnAdmin(playerid,3))
{
new string[200];
if(!sscanf(params, "u", Actor_ID))
{
if(Actor_ID != INVALID_ACTOR_ID)
{
DestroyActor(ActorData[Actor_ID][aID]);
DestroyDynamic3DTextLabel(ActorData[Actor_ID][aString]);
format(string, sizeof(string), "Actor deleted.. (ACTOR ID: %d)",ActorData[Actor_ID][aID]);
SCM(playerid,GREEN,string);
Actor_ID--;
}
else SCM(playerid,RED,">> Bad actor ID!");
}
else SCM(playerid,RED,"[INFO]: /deleteactor <ID>");
}
else SCM(playerid,RED,">> You are not an admin!");
return 1;
}