Guest User

Actor System V0.1

a guest
Mar 21st, 2016
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.91 KB | None | 0 0
  1. /*==============================================================================
  2. =================================[Actor System]=================================
  3. =================================[by Yogurt]====================================
  4. ==============================================================================*/
  5.  
  6. /*===================================[Legal]====================================
  7.  
  8. The contents of this file are subject to the Mozilla Public License
  9. Version 2.0 (the "License"); you may not use this file except in
  10. compliance with the License. You may obtain a copy of the License at
  11. http://www.mozilla.org/MPL/
  12.  
  13. Software distributed under the License is distributed on an "AS IS"
  14. basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  15. License for the specific language governing rights and limitations
  16. under the License.
  17.  
  18. The Original Code is Actor System.
  19.  
  20. The Initial Developer of the Original Code is Yogurt.
  21. Portions created by Initial Developer are Copyright (C) 2016
  22. Initial Developer. All Rights Reserved.
  23.  
  24. Contributor(s): Y_Less, Incognito, Zeex.
  25.  
  26. And dont forget to add my facebook account Muhamad Ramadhan. Thank you
  27.  
  28. ==============================================================================*/
  29.  
  30. /*==================================[Credits]===================================
  31.  
  32. Special Thanks to :
  33. • SA:MP Team past & present
  34.  
  35. Thanks to :
  36. • Y_Less for sscanf, foreach, and YSI
  37. • Incognito for streamer
  38. • Zeex for zcmd
  39. ==============================================================================*/
  40.  
  41. /*=================================[Changelog]==================================
  42.  
  43. Version 0.1:
  44. - Initial release
  45.  
  46. Planned Updates 0.2:
  47. - Actor Text with 3DTextLabel
  48. - Actor Animation
  49. Date Thursday 03/22/2016
  50. ==============================================================================*/
  51.  
  52. //=============================[Include & Defines]==============================
  53.  
  54. #pragma tabsize 0
  55. #include <a_samp>
  56.  
  57. #include <a_actor>
  58. #include <sscanf2> // sscanf plugin by Y_Less
  59. #include <streamer> // streamer plugin by Incognito
  60.  
  61. #include <YSI\y_iterate> // YSI by Y_Less
  62. #if defined USE_YCMD
  63. #include <YSI\y_commands> // YSI by Y_Less
  64. #else
  65. #include <zcmd> // zcmd include by Zeex
  66. #endif
  67.  
  68.  
  69. #define SEM(%0,%1) SendClientMessage(%0,0xBFC0C200,%1) // SEM = Send Error Message by Myself
  70. #define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++) // Loop by Myself
  71. #define IsNull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) // IsNull macro by Y_Less
  72. #define strToLower(%0) \
  73. for(new i; %0[i] != EOS; ++i) \
  74. %0[i] = ('A' <= %0[i] <= 'Z') ? (%0[i] += 'a' - 'A') : (%0[i]) // strToLower by RyDeR`
  75. #define RGBAToInt(%0,%1,%2,%3) \
  76. ((16777216 * (%0)) + (65536 * (%1)) + (256 * (%2)) + (%3)) // RGBAToInt by RyDeR`
  77.  
  78. #define COLOR_GREY 0xAFAFAFAA
  79. #define COLOR_GREEN 0x33AA33AA
  80. #define COLOR_RED 0xAA3333AA
  81. #define COLOR_YELLOW 0xFFFF00AA
  82. #define COLOR_WHITE 0xFFFFFFFF
  83.  
  84. #define MAX_EDITING_ACTOR (100)
  85.  
  86. new Iterator:DynamicActors<MAX_EDITING_ACTOR>;
  87. new DynamicActor[MAX_EDITING_ACTOR];
  88.  
  89. //------------------------------------------------------------------------------------------------------
  90.  
  91. //------------------------------------------------------------------------------------------------------
  92.  
  93. public OnFilterScriptInit()
  94. {
  95. print("=========================================");
  96. print("|==========[Actor System V0.1]==========|");
  97. print("|==========[----By Yogurt----]==========|");
  98. print("|==========[Has been loaded!!]==========|");
  99. print("=========================================");
  100. return 1;
  101. }
  102.  
  103. SSCANF:actormenu(string[])
  104. {
  105. if(!strcmp(string,"create",true)) return 1;
  106. else if(!strcmp(string,"add",true)) return 1;
  107. else if(!strcmp(string,"destroy",true)) return 2;
  108. else if(!strcmp(string,"delete",true)) return 2;
  109. else if(!strcmp(string,"remove",true)) return 2;
  110. else if(!strcmp(string,"clear",true)) return 3;
  111. else if(!strcmp(string,"reset",true)) return 3;
  112. else if(!strcmp(string,"goto",true)) return 4;
  113. else if(!strcmp(string,"gethere",true)) return 5;
  114. return 0;
  115. }
  116.  
  117. //------------------------------------------------------------------------------
  118.  
  119. CMD:actor(playerid,params[])
  120. {
  121. new action,subparam[128],string[256];
  122. unformat(params,"k<actormenu>S()[128]",action,subparam);
  123. switch(action)
  124. {
  125. case 1:
  126. {
  127. if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor create [skin]");
  128. new model = strval(subparam);
  129. new slot = Iter_Free(DynamicActors);
  130. if(slot != -1)
  131. {
  132. new Float:cPos[4];
  133. GetPlayerPos(playerid,cPos[0],cPos[1],cPos[2]);
  134. GetPlayerFacingAngle(playerid,cPos[3]);
  135. DynamicActor[slot] = CreateActor(model,cPos[0],cPos[1],cPos[2],cPos[3]);
  136. Streamer_Update(playerid);
  137. SetPlayerPos(playerid,cPos[0],cPos[1],(cPos[2]+2.0));
  138. Iter_Add(DynamicActors,slot);
  139. format(string,128,"<ACTOR> : Actor model '%d' with slot id '%d' created, total actors: %d",model,slot,Iter_Count(DynamicActors));
  140. SendClientMessage(playerid,-1,string);
  141. }
  142. else SEM(playerid,"<ERROR> : No actor free slot!");
  143. }
  144. case 2:
  145. {
  146. if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor destroy [slot]");
  147. new slot = strval(subparam);
  148. if(Iter_Contains(DynamicActors,slot))
  149. {
  150. DestroyActor(DynamicActor[slot]);
  151. Iter_Remove(DynamicActors,slot);
  152. format(string,128,"<ACTOR> : Actor with slot id '%d' has been deleted, total actors: %d",slot,Iter_Count(DynamicActors));
  153. SendClientMessage(playerid,-1,string);
  154. }
  155. else SEM(playerid,"<ERROR> : Invalid actor slot id!");
  156. }
  157. case 3:
  158. {
  159. if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor clear [confirm]");
  160. if(!strcmp(subparam,"confirm",true))
  161. {
  162. new count = Iter_Count(DynamicActors);
  163. if(count > 0)
  164. {
  165. foreach(new i : DynamicActors)
  166. {
  167. DestroyActor(DynamicActor[i]);
  168. }
  169. Iter_Clear(DynamicActors);
  170. format(string,128,"<ACTOR> : %d actors have been cleared",count);
  171. SendClientMessage(playerid,-1,string);
  172. }
  173. else SEM(playerid,"<ERROR> : There are no actors!");
  174. }
  175. else SEM(playerid,"<SYNTAX> : /actor clear [confirm]");
  176. }
  177. case 4:
  178. {
  179. if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor goto [slot]");
  180. new slot = strval(subparam);
  181. if(Iter_Contains(DynamicActors,slot))
  182. {
  183. new Float:cPos[3];
  184. GetActorPos(DynamicActor[slot],cPos[0],cPos[1],cPos[2]);
  185. Streamer_UpdateEx(playerid,cPos[0],cPos[1],cPos[2]);
  186. SetPlayerPos(playerid,cPos[0],cPos[1],(cPos[2]+1.0));
  187. format(string,128,"<ACTOR> : Teleported to actor id %d!",slot);
  188. SendClientMessage(playerid,-1,string);
  189. }
  190. else SEM(playerid,"<ERROR> : Invalid actor slot id!");
  191. }
  192. case 5:
  193. {
  194. if(IsNull(subparam)) return SEM(playerid,"<SYNTAX> : /actor gethere [slot]");
  195. new slot = strval(subparam);
  196. if(Iter_Contains(DynamicActors,slot))
  197. {
  198. new Float:cPos[3];
  199. GetPlayerPos(playerid,cPos[0],cPos[1],cPos[2]);
  200. SetActorPos(DynamicActor[slot],cPos[0],cPos[1],cPos[2]);
  201. Streamer_Update(playerid);
  202. SetPlayerPos(playerid,cPos[0],cPos[1],(cPos[2]+1.0));
  203. format(string,128,"<ACTOR> : Teleported actor id %d to your location!",slot);
  204. SendClientMessage(playerid,-1,string);
  205. }
  206. else SEM(playerid,"<ERROR> : Invalid actor slot id!");
  207. }
  208. default:
  209. {
  210. SEM(playerid,"<SYNTAX> : /actor [action]");
  211. SEM(playerid,"<ACTIONS> : create,destroy,clear,move,goto,gethere");
  212. }
  213. }
  214. return 1;
  215. }
  216. //------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment