Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ACTOR STUDIO :: CREATED BY LYNN *
- **************************************************
- * .:PURPOSE:. *
- * The purpose of this filterscript is to create *
- * actors that are both responsive and/or actors *
- * that are unresponsive. Wll with the simplicity *
- * of this filterscript. Hopefully you will enjoy!*
- **************************************************/
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <foreach>
- #define PF:%0(%1) forward %0(%1); \
- public %0(%1) // Automatically creates a Public and Forward, using PF: FunctionName() {
- #define SCM SendClientMessage // Shortens SendClientMessage to SCM
- #define ACTOR_ (9001) // Dialog definition
- #define MAX_3DTEXT (1000) // Maximum 3D Text Labels allowed. Matches Max_Actors
- enum ActorInfo {
- a_ID, // Actor physical ID
- a_SkinID, // Actor Skin
- bool:a_Respond, // Responsive to actions: True = Yes False = No
- Float:a_X, // Position X
- Float:a_Y, // Position Y
- Float:a_Z, // Position Z
- Float:a_R, // Rotation
- };
- static a_Info[MAX_ACTORS][ActorInfo];
- static LastSkin;// Last skin used by the Actor Studio
- static Text3D:ActorText[MAX_ACTORS]; // 3DText Label created upon actor spawn.
- static Actor_ID = 0; // Actors created
- static bool:a_Studio_Used = false; // Actor Studio being used: false = No, true = Yes.
- static CreatedActor[MAX_ACTORS]; // Most recent created actor, once deleted it takes the place of the next highest ID
- static PlayerUpdate[MAX_PLAYERS]; // Update Timer variable
- public OnFilterScriptInit()
- {
- // Please leave the following. Although I'm asking, I know it won't happen because how will I ever know?
- print("\n**************************************************");
- print(" * *");
- print(" * ACTOR STUDIO : CREATED BY LYNN v1.0 *");
- print(" * Verison v2.0 avalible soon. *");
- print(" * *");
- print("**************************************************\n");
- foreach(Player, i)
- {
- PlayerUpdate[i] = SetTimerEx("OnPlayerUpdateEx", 1000, true, "i", i); // Iniates now, in the even the filter script is loaded after players are already connected.
- }
- Actor_ID = 0; // Actors created set to 0.
- // ACTOR DEFAULTS SET TO 0.
- a_Info[Actor_ID][a_ID] = 0;
- a_Info[Actor_ID][a_SkinID] = 0;
- a_Info[Actor_ID][a_Respond] = false;
- a_Info[Actor_ID][a_X] = 0;
- a_Info[Actor_ID][a_Y] = 0;
- a_Info[Actor_ID][a_Z] = 0;
- a_Info[Actor_ID][a_Z] = 0;
- a_Studio_Used = false; // Re-set to false to avoid any complications.
- // Load_Actors();
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new i = 0, j = GetActorPoolSize(); i <= j; i++)
- {
- if(IsValidActor(i))
- {
- DestroyActor(i); // Loops through every actor, deleting it.
- }
- }
- for(new u = 0; u < MAX_3DTEXT; u++)
- {
- Delete3DTextLabel(Text3D:u); // Loops through created 3D TextLabels, deleting them.
- }
- foreach(Player, u) {
- if(IsPlayerAdmin(u)) {
- SCM(u, -1, #** All actors have been destroyed.);// RCON Admins are now aware their creations have been destroyed.
- }
- }
- a_Studio_Used = false; // Studio no longer in-use.
- return 1;
- }
- // Currently not used. V2.0 will use this function for it's saving system.
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- // Is the player using the actor studio? Well let's reset that real quick...
- if(GetPVarInt(playerid, #Using_Actor_Studio) == 1)
- {
- a_Studio_Used = false;
- DeletePVar(playerid, #Using_Actor_Studio);
- }
- return 1;
- }
- // ACTOR FUNCTIONS
- PF: OnPlayerUpdateEx(playerid)// Update function.
- {
- new actorid = GetPlayerTargetActor(playerid);
- if (actorid != INVALID_ACTOR_ID)// Is the target a valid actor? If not, do nothing.
- {
- ApplyActorAnimation(actorid, "PED", "handsup", 4.1, 0, 0, 0, 0, 0); // Make him put his hands up when aimed at.
- }
- return 1;
- }
- PF: OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
- {
- if(IsActorInvulnerable(damaged_actorid))
- {
- SCM(playerid, -1, #That actor is unresponsive.);// Is this actor responsive to actions? No? Do nothing.
- }
- else
- {
- new Float:hp;
- SetActorHealth(damaged_actorid, hp-amount/2);//Removes half of the normal damage.
- }
- return 1;
- }
- // ACTOR STUDIO - COMMANDS
- CMD:ahelp(playerid, params[])
- {
- SCM(playerid, -1, " >> Use /actors to view total amount of actors currently created.");
- SCM(playerid, -1, " >> Use /astudio to open the actor studio and begin creating.");
- SCM(playerid, -1, " >> Please report any bugs on the SA-MP forums, under the Actor Studio post.");
- return true;
- }
- // Check the total actors within the server.
- CMD:actors(playerid, params[])
- {
- new str[64];
- format(str, sizeof str, " Actor Studio: {F81414}Total Actors (%d) ", Actor_ID);
- SCM(playerid, -1, str);
- return true;
- }
- // Start creating actors!
- CMD:astudio(playerid, params[])
- {
- if(IsPlayerConnected(playerid))
- {
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) {
- if(a_Studio_Used == false) {
- SetPVarInt(playerid, #Using_Actor_Studio, 1);
- ShowPlayerDialog(playerid, ACTOR_, DIALOG_STYLE_LIST, "{3399FF}Actor Studio {FFFFFF}- Created by {3399FF}Lynn",
- "{3399FF}Skin ID\n{3399FF}Responsive\n{3399FF}Duplicate\n{00FF22}Create\n{F81414}Delete", "{F81414}Select", "{F81414}Cancel");
- a_Studio_Used = true;
- }
- else return SCM(playerid, -1, # >> Actor studio currently in-use.);
- }
- else return SCM(playerid, -1, # >> You may not use this command at this moment.);
- }
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case ACTOR_:
- {
- switch(listitem)
- {
- case 0: {
- if(!response) {
- SCM(playerid, -1, # >> You have canceled the Actor Studio progress);
- a_Studio_Used = false;
- }
- else if(response) {
- ShowPlayerDialog(playerid, ACTOR_+1, DIALOG_STYLE_INPUT, "Actor Skin ID", "{FFFFFF}Input the desired skin id of the new actor.", "Select", "");
- }
- }
- case 1: {
- if(!response) {
- SCM(playerid, -1, # >> You have canceled the Actor Studio progress);
- a_Studio_Used = false;
- }
- else if(response) {
- ShowPlayerDialog(playerid, ACTOR_+2, DIALOG_STYLE_MSGBOX, "Actor Responsive", "{FFFFFF}Would you like your actor to respond to actions?", "Yes", "No");
- }
- }
- case 2: {
- if(!response) {
- SCM(playerid, -1, # >> You have canceled the Actor Studio progress);
- a_Studio_Used = false;
- }
- else if(response) {
- if(Actor_ID != 0)
- {
- SCM(playerid, -1, "You are now duplicating. Press '{3399FF}Y{FFFFFF}' to duplicate and '{F81414}N{FFFFFF}' to stop.");
- SetPVarInt(playerid, "A_Editor", 1);
- }
- else {
- SCM(playerid, -1, #You must create an actor before you can duplicate it.);
- a_Studio_Used = false;
- }
- }
- }
- case 3: {
- if(!response) {
- SCM(playerid, -1, # >> You have canceled the Actor Studio progress);
- a_Studio_Used = false;
- }
- else if(response) {
- if(a_Info[Actor_ID][a_SkinID] != 0) {
- new Float:pX, Float:pY, Float:pZ, Float:pR;
- GetPlayerPos(playerid, pX, pY, pZ);
- GetPlayerFacingAngle(playerid, pR);
- a_Info[Actor_ID][a_X] = pX+0.5;
- a_Info[Actor_ID][a_Y] = pY;
- a_Info[Actor_ID][a_Z] = pZ;
- a_Info[Actor_ID][a_R] = pR;
- CreatedActor[Actor_ID] = CreateActor(a_Info[Actor_ID][a_SkinID], a_Info[Actor_ID][a_X], a_Info[Actor_ID][a_Y], a_Info[Actor_ID][a_Z], a_Info[Actor_ID][a_R]);
- LastSkin = a_Info[Actor_ID][a_SkinID];
- if(a_Info[Actor_ID][a_Respond] == true)
- {
- SetActorInvulnerable(CreatedActor[Actor_ID], false);
- SetActorHealth(CreatedActor[Actor_ID], 100);
- new string[64];
- a_Info[Actor_ID][a_ID] = Actor_ID;
- format(string, sizeof(string), "Actor ID: ({3399FF}%d{FFFFFF})\nResponsive", Actor_ID+1);
- ActorText[Actor_ID] = Create3DTextLabel(string, -1, a_Info[Actor_ID][a_X], a_Info[Actor_ID][a_Y], a_Info[Actor_ID][a_Z]+0.3, 10.0, 0, 1);
- }
- else {
- SetActorInvulnerable(CreatedActor[Actor_ID], true);
- new string[64];
- a_Info[Actor_ID][a_ID] = Actor_ID;
- format(string, sizeof(string), "Actor ID: ({3399FF}%d{FFFFFF})\nUnresponsive", Actor_ID+1);
- ActorText[Actor_ID] = Create3DTextLabel(string, -1, a_Info[Actor_ID][a_X], a_Info[Actor_ID][a_Y], a_Info[Actor_ID][a_Z]+0.3, 10.0, 0, 1);
- }
- Actor_ID++;
- a_Studio_Used = false;
- }
- else {
- SCM(playerid, -1, ">> You did not input enough information for a new creation.");
- ShowPlayerDialog(playerid, ACTOR_, DIALOG_STYLE_LIST, "{3399FF}Actor Studio {FFFFFF}- Created by {3399FF}Lynn",
- "{3399FF}Skin ID\n{3399FF}Responsive\n{3399FF}Duplicate\n{3399FF}Create\n{F81414}Delete", "{F81414}Select", "{F81414}Cancel");
- }
- }
- }
- case 4: {
- if(!response) {
- SCM(playerid, -1, # >> You have canceled the Actor Studio progress);
- a_Studio_Used = false;
- }
- else if(response) {
- ShowPlayerDialog(playerid, ACTOR_+5, DIALOG_STYLE_MSGBOX, "{FFFFFF}Actor Deletion", "{FFFFFF}Are you sure you sure of this?\nIt will {F81414}DELETE{FFFFFF} your {F81414}LAST{FFFFFF} actor.", "Yes", "No");
- }
- }
- }
- }
- case ACTOR_+1: {
- if(!response) return ShowPlayerDialog(playerid, ACTOR_, DIALOG_STYLE_LIST, "{3399FF}Actor Studio {FFFFFF}- Created by {3399FF}Lynn",
- "{3399FF}Skin ID\n{3399FF}Responsive\n{3399FF}Duplicate\n{3399FF}Create\n{F81414}Delete", "{F81414}Select", "{F81414}Cancel");
- else if(response) {
- new a_sid = strval(inputtext);
- if(a_sid > 0 && a_sid < 312)
- {
- a_Info[Actor_ID][a_SkinID] = a_sid;
- if(GetPVarInt(playerid, #A_Editor) != 1)
- {
- ShowPlayerDialog(playerid, ACTOR_+2, DIALOG_STYLE_MSGBOX, "Actor Responsive", "{FFFFFF}Would you like your actor to respond to actions?", "Yes", "No");
- }
- }
- else {
- ShowPlayerDialog(playerid, ACTOR_+1, DIALOG_STYLE_INPUT, "Actor Skin ID", "{F81414}ERROR: {FFFFFF}Invalid skin ID, select a new one.", "Input", "");
- }
- }
- }
- case ACTOR_+2: {
- if(!response) {
- a_Info[Actor_ID][a_Respond] = false;
- SCM(playerid, -1, # >> Actor Selection: Unresponsive);
- ShowPlayerDialog(playerid, ACTOR_, DIALOG_STYLE_LIST, "{3399FF}Actor Studio {FFFFFF}- Created by {3399FF}Lynn",
- "{3399FF}Skin ID\n{3399FF}Responsive\n{3399FF}Duplicate\n{3399FF}Create\n{F81414}Delete", "{F81414}Select", "{F81414}Cancel");
- }
- else if(response) {
- a_Info[Actor_ID][a_Respond] = true;
- SCM(playerid, -1, # >> Actor Selection: Responsive);
- ShowPlayerDialog(playerid, ACTOR_, DIALOG_STYLE_LIST, "{3399FF}Actor Studio {FFFFFF}- Created by {3399FF}Lynn",
- "{3399FF}Skin ID\n{3399FF}Responsive\n{3399FF}Duplicate\n{3399FF}Create\n{F81414}Delete", "{F81414}Select", "{F81414}Cancel");
- }
- }
- case ACTOR_+5:
- {
- if(!response) {
- SCM(playerid, -1, # >> You have decided to keep your actor.);
- a_Studio_Used = false;
- }
- else if(response) {
- if(Actor_ID > 0) {
- Actor_ID--;
- DestroyActor(CreatedActor[Actor_ID]);
- Delete3DTextLabel(ActorText[Actor_ID]);
- a_Studio_Used = false;
- new str[128];
- format(str, sizeof str, " >> Actor ID ({3399FF}%d{FFFFFF}) has been {F81414}removed {FFFFFF}from the server.");
- SCM(playerid, -1, str);
- }
- else {
- SCM(playerid, -1, # >> You have not created any actors to delete.);
- a_Studio_Used = false;
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return false;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
- {
- if(GetPVarInt(playerid, #A_Editor) == 1)
- {
- DeletePVar(playerid, #A_Editor);
- SCM(playerid, -1, # >> You are no longer no longer duplicating actors.);
- a_Studio_Used = false;
- }
- }
- return true;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (newkeys & KEY_YES)
- {
- if(GetPVarInt(playerid, #A_Editor) == 1)
- {
- new Float:pX, Float:pY, Float:pZ, Float:pR;
- GetPlayerPos(playerid, pX, pY, pZ);
- GetPlayerFacingAngle(playerid, pR);
- a_Info[Actor_ID][a_X] = pX+0.6;
- a_Info[Actor_ID][a_Y] = pY;
- a_Info[Actor_ID][a_Z] = pZ;
- a_Info[Actor_ID][a_R] = pR;
- // Create an actor, using the information above.
- CreatedActor[Actor_ID] = CreateActor(LastSkin, a_Info[Actor_ID][a_X], a_Info[Actor_ID][a_Y], a_Info[Actor_ID][a_Z], a_Info[Actor_ID][a_R]);
- new string[64];
- // Create the 3D TextLabel for an actor.
- if(a_Info[Actor_ID-1][a_Respond] == true)
- {
- SetActorInvulnerable(CreatedActor[Actor_ID], false);
- a_Info[Actor_ID][a_Respond] = true;
- SetActorHealth(CreatedActor[Actor_ID], 100);
- format(string, sizeof(string), "Actor ID: ({3399FF}%d{FFFFFF})\nResponsive", Actor_ID+1);
- ActorText[Actor_ID] = Create3DTextLabel(string, -1, a_Info[Actor_ID][a_X], a_Info[Actor_ID][a_Y], a_Info[Actor_ID][a_Z]+0.3, 10.0, 0, 1);
- }
- else {
- SetActorInvulnerable(CreatedActor[Actor_ID], true);
- a_Info[Actor_ID][a_Respond] = false;
- format(string, sizeof(string), "Actor ID: ({3399FF}%d{FFFFFF})\nUnresponsive", Actor_ID+1);
- ActorText[Actor_ID] = Create3DTextLabel(string, -1, a_Info[Actor_ID][a_X], a_Info[Actor_ID][a_Y], a_Info[Actor_ID][a_Z]+0.3, 10.0, 0, 1);
- }
- a_Info[Actor_ID][a_ID] = Actor_ID;
- Actor_ID++;
- }
- }
- // Quit the duplication progress.
- if (newkeys & KEY_NO)
- {
- if(GetPVarInt(playerid, #A_Editor) == 1)
- {
- DeletePVar(playerid, #A_Editor);
- SCM(playerid, -1, # >> You are no longer no longer duplicating actors.);
- a_Studio_Used = false;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment