Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================================================
- =================================[Actor System]=================================
- =================================[by Yogurt]====================================
- ==============================================================================*/
- /*===================================[Legal]====================================
- The contents of this file are subject to the Mozilla Public License
- Version 2.0 (the "License"); you may not use this file except in
- compliance with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- License for the specific language governing rights and limitations
- under the License.
- The Original Code is Actor System.
- The Initial Developer of the Original Code is Yogurt.
- Portions created by Initial Developer are Copyright (C) 2016
- Initial Developer. All Rights Reserved.
- Contributor(s): Y_Less, Incognito, Zeex.
- And dont forget to add my facebook account Muhamad Ramadhan. Thank you
- ==============================================================================*/
- /*==================================[Credits]===================================
- Special Thanks to :
- • SA:MP Team past & present
- Thanks to :
- • Y_Less for sscanf, foreach, and YSI
- • Incognito for streamer
- • Zeex for zcmd
- ==============================================================================*/
- /*=================================[Changelog]==================================
- Version 0.1:
- - Initial release
- Planned Updates 0.2:
- - Actor Text with 3DTextLabel
- - Actor Animation
- Date Thursday 03/22/2016
- ==============================================================================*/
- //=============================[Include & Defines]==============================
- #pragma tabsize 0
- #include <a_samp>
- #include <a_actor>
- #include <sscanf2> // sscanf plugin by Y_Less
- #include <streamer> // streamer plugin by Incognito
- #include <YSI\y_iterate> // YSI by Y_Less
- #if defined USE_YCMD
- #include <YSI\y_commands> // YSI by Y_Less
- #else
- #include <zcmd> // zcmd include by Zeex
- #endif
- #define SEM(%0,%1) SendClientMessage(%0,0xBFC0C200,%1) // SEM = Send Error Message by Myself
- #define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++) // Loop by Myself
- #define IsNull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) // IsNull macro by Y_Less
- #define strToLower(%0) \
- for(new i; %0[i] != EOS; ++i) \
- %0[i] = ('A' <= %0[i] <= 'Z') ? (%0[i] += 'a' - 'A') : (%0[i]) // strToLower by RyDeR`
- #define RGBAToInt(%0,%1,%2,%3) \
- ((16777216 * (%0)) + (65536 * (%1)) + (256 * (%2)) + (%3)) // RGBAToInt by RyDeR`
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFFF
- #define MAX_EDITING_ACTOR (100)
- new Iterator:DynamicActors<MAX_EDITING_ACTOR>;
- new DynamicActor[MAX_EDITING_ACTOR];
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- public OnFilterScriptInit()
- {
- print("=========================================");
- print("|==========[Actor System V0.1]==========|");
- print("|==========[----By Yogurt----]==========|");
- print("|==========[Has been loaded!!]==========|");
- print("=========================================");
- return 1;
- }
- SSCANF:actormenu(string[])
- {
- if(!strcmp(string,"create",true)) return 1;
- else if(!strcmp(string,"add",true)) return 1;
- else if(!strcmp(string,"destroy",true)) return 2;
- else if(!strcmp(string,"delete",true)) return 2;
- else if(!strcmp(string,"remove",true)) return 2;
- else if(!strcmp(string,"clear",true)) return 3;
- else if(!strcmp(string,"reset",true)) return 3;
- else if(!strcmp(string,"goto",true)) return 4;
- else if(!strcmp(string,"gethere",true)) return 5;
- return 0;
- }
- //------------------------------------------------------------------------------
- CMD:actor(playerid,params[])
- {
- new action,subparam[128],string[256];
- unformat(params,"k<actormenu>S()[128]",action,subparam);
- switch(action)
- {
- case 1:
- {
- if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor create [skin]");
- new model = strval(subparam);
- new slot = Iter_Free(DynamicActors);
- if(slot != -1)
- {
- new Float:cPos[4];
- GetPlayerPos(playerid,cPos[0],cPos[1],cPos[2]);
- GetPlayerFacingAngle(playerid,cPos[3]);
- DynamicActor[slot] = CreateActor(model,cPos[0],cPos[1],cPos[2],cPos[3]);
- Streamer_Update(playerid);
- SetPlayerPos(playerid,cPos[0],cPos[1],(cPos[2]+2.0));
- Iter_Add(DynamicActors,slot);
- format(string,128,"<ACTOR> : Actor model '%d' with slot id '%d' created, total actors: %d",model,slot,Iter_Count(DynamicActors));
- SendClientMessage(playerid,-1,string);
- }
- else SEM(playerid,"<ERROR> : No actor free slot!");
- }
- case 2:
- {
- if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor destroy [slot]");
- new slot = strval(subparam);
- if(Iter_Contains(DynamicActors,slot))
- {
- DestroyActor(DynamicActor[slot]);
- Iter_Remove(DynamicActors,slot);
- format(string,128,"<ACTOR> : Actor with slot id '%d' has been deleted, total actors: %d",slot,Iter_Count(DynamicActors));
- SendClientMessage(playerid,-1,string);
- }
- else SEM(playerid,"<ERROR> : Invalid actor slot id!");
- }
- case 3:
- {
- if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor clear [confirm]");
- if(!strcmp(subparam,"confirm",true))
- {
- new count = Iter_Count(DynamicActors);
- if(count > 0)
- {
- foreach(new i : DynamicActors)
- {
- DestroyActor(DynamicActor[i]);
- }
- Iter_Clear(DynamicActors);
- format(string,128,"<ACTOR> : %d actors have been cleared",count);
- SendClientMessage(playerid,-1,string);
- }
- else SEM(playerid,"<ERROR> : There are no actors!");
- }
- else SEM(playerid,"<SYNTAX> : /actor clear [confirm]");
- }
- case 4:
- {
- if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor goto [slot]");
- new slot = strval(subparam);
- if(Iter_Contains(DynamicActors,slot))
- {
- new Float:cPos[3];
- GetActorPos(DynamicActor[slot],cPos[0],cPos[1],cPos[2]);
- Streamer_UpdateEx(playerid,cPos[0],cPos[1],cPos[2]);
- SetPlayerPos(playerid,cPos[0],cPos[1],(cPos[2]+1.0));
- format(string,128,"<ACTOR> : Teleported to actor id %d!",slot);
- SendClientMessage(playerid,-1,string);
- }
- else SEM(playerid,"<ERROR> : Invalid actor slot id!");
- }
- case 5:
- {
- if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor gethere [slot]");
- new slot = strval(subparam);
- if(Iter_Contains(DynamicActors,slot))
- {
- new Float:cPos[3];
- GetPlayerPos(playerid,cPos[0],cPos[1],cPos[2]);
- SetActorPos(DynamicActor[slot],cPos[0],cPos[1],cPos[2]);
- Streamer_Update(playerid);
- SetPlayerPos(playerid,cPos[0],cPos[1],(cPos[2]+1.0));
- format(string,128,"<ACTOR> : Teleported actor id %d to your location!",slot);
- SendClientMessage(playerid,-1,string);
- }
- else SEM(playerid,"<ERROR> : Invalid actor slot id!");
- }
- default:
- {
- SEM(playerid,"<SYNTAX> : /actor [action]");
- SEM(playerid,"<ACTIONS> : create,destroy,clear,move,goto,gethere");
- }
- }
- return 1;
- }
- //------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment