Guest User

Dynamic Actor Creator v0.1

a guest
May 13th, 2015
2,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.15 KB | None | 0 0
  1.  
  2. #define FILTERSCRIPT
  3. /*******************************************************************************
  4.     Dynamic Actor Creator
  5.     Version: v0.1
  6.     Scripted by: Acke
  7. //------------------------------------------------------------------------------
  8.     * Update v0.1 : Dodana mogucnost postavljanja Virtual Worlda na Actora
  9.  
  10. */
  11. #include < a_samp >
  12. #include < YSI\y_ini >
  13. #include < zcmd >
  14. #include < sscanf2 >
  15. #include < a_actor >
  16.  
  17. //------------------------------------------------------------------------------ [ Kreiranje actora ( varijable actora ) ]
  18. #define ACTORS  "Aktori/%d.ini"//                                                [ Falj za cuvanje Actora ]
  19. #define MAX_ACTOR 50
  20. enum AcInfo
  21. {
  22.     aSkin,
  23.     aVW,
  24.     Float: aPozX,
  25.     Float: aPozY,
  26.     Float: aPozZ,
  27.     Float: aRot,
  28.     aAnimCat[20],
  29.     aAnimName[20]
  30.    
  31. }
  32. new ActorInfo[MAX_ACTOR][AcInfo];
  33. //------------------------------------------------------------------------------
  34. stock SendClientMessageF(playerid,color,fstring[],{Float, _}:...)
  35. {
  36.    new n=(numargs()-3)*4;
  37.    if(n)
  38.    {
  39.       new message[128],arg_start,arg_end;
  40.       #emit CONST.alt                fstring
  41.       #emit LCTRL                    5
  42.       #emit ADD
  43.       #emit STOR.S.pri               arg_start
  44.       #emit LOAD.S.alt               n
  45.       #emit ADD
  46.       #emit STOR.S.pri               arg_end
  47.       do
  48.       {
  49.          #emit LOAD.I
  50.          #emit PUSH.pri
  51.          arg_end-=4;
  52.          #emit LOAD.S.pri           arg_end
  53.       }
  54.       while(arg_end>arg_start);
  55.       #emit PUSH.S                   fstring
  56.       #emit PUSH.C                   255
  57.       #emit PUSH.ADR                 message
  58.       n+=4*3;
  59.       #emit PUSH.S                   n
  60.       #emit SYSREQ.C                 format
  61.       n+=4;
  62.       #emit LCTRL                    4
  63.       #emit LOAD.S.alt               n
  64.       #emit ADD
  65.       #emit SCTRL                    4
  66.       return SendClientMessage(playerid,color,message);
  67.    }
  68.    else return SendClientMessage(playerid,color,fstring);
  69. }
  70. public OnFilterScriptInit()
  71. {
  72. //------------------------------------------------------------------------------ [ Ucitavanje Actora ]
  73.     for(new a = 0; a < sizeof(ActorInfo); a++)
  74.     {
  75.         new aFile[43];
  76.         format(aFile,sizeof(aFile), ACTORS, a);
  77.         {
  78.             INI_ParseFile(aFile,"LoadActor", .bExtra = true, .extra = a);
  79.             {
  80.                 CreateActor(ActorInfo[a][aSkin], ActorInfo[a][aPozX], ActorInfo[a][aPozY], ActorInfo[a][aPozZ],ActorInfo[a][aRot]); SetActorVirtualWorld(a, ActorInfo[a][aVW]);
  81.             }
  82.         }
  83.     }
  84.     return 1;
  85. }
  86.  
  87. public OnFilterScriptExit()
  88. {
  89.     for(new a = 0; a < sizeof(ActorInfo); a++) { SaveActor(a); }
  90.     return 1;
  91. }
  92. forward LoadActor(idactor, name[], value[]);
  93. public LoadActor(idactor, name[], value[])
  94. {
  95.     INI_Int("Skin",ActorInfo[idactor][aSkin]);
  96.     INI_Int("VW",ActorInfo[idactor][aVW]);
  97.     INI_Float("ApozX",ActorInfo[idactor][aPozX]);
  98.     INI_Float("ApozY",ActorInfo[idactor][aPozY]);
  99.     INI_Float("ApozZ",ActorInfo[idactor][aPozZ]);
  100.     INI_Float("APozA",ActorInfo[idactor][aRot]);
  101.     INI_String("AnimCat",ActorInfo[idactor][aAnimCat],20);
  102.     INI_String("AnimName",ActorInfo[idactor][aAnimName],20);
  103.     return 1;
  104. }
  105. stock SaveActor(idactor)
  106. {
  107.     new aFile[43];
  108.     format(aFile,sizeof(aFile), ACTORS, idactor);
  109.     new INI:File = INI_Open(aFile);
  110.     INI_WriteInt(File,"Skin",ActorInfo[idactor][aSkin]);
  111.     INI_WriteInt(File,"VW",ActorInfo[idactor][aVW]);
  112.     INI_WriteFloat(File,"ApozX",ActorInfo[idactor][aPozX]);
  113.     INI_WriteFloat(File,"ApozY",ActorInfo[idactor][aPozY]);
  114.     INI_WriteFloat(File,"ApozZ",ActorInfo[idactor][aPozZ]);
  115.     INI_WriteFloat(File,"APozA",ActorInfo[idactor][aRot]);
  116.     INI_WriteString(File,"AnimCat",ActorInfo[idactor][aAnimCat]);
  117.     INI_WriteString(File,"AnimName",ActorInfo[idactor][aAnimName]);
  118.     INI_Close(File);
  119.     return 1;
  120. }
  121. CMD:actorcreate(playerid, params[])//                                            [ /actorcreate ]
  122. {
  123.     #pragma unused params
  124.     if(IsPlayerAdmin(playerid))
  125.     {
  126.         new Float: X, Float: Y, Float: Z, Float: Rot, skin, actorid, actorvw, factor[80]; GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid, Rot);
  127.         if(sscanf(params, "iii", actorid, skin, actorvw)) return SendClientMessage(playerid,-1,"Koristi: /actorcreate [Actor ID], [Actor Skin ID] [Actor VW ID]");
  128.         if(actorid >= MAX_ACTOR) return SendClientMessageF(playerid,-1,"ERROR: Maksimalan broj actora je [ %d ]/ Maximal number of actor id is [ %d ] ",MAX_ACTOR,MAX_ACTOR);
  129.         format(factor,sizeof(factor), ACTORS, actorid);
  130.         if(fexist(factor)) return SendClientMessage(playerid,-1,"ERROR: Actor sa tim ID-em vec postoji !/ This Actor ID was used !");
  131.         if(skin >= 311 || skin < 0) return SendClientMessage(playerid,-1,"ERROR: Nepravilan id skina !/ Invalid skin id ! [0,350]");
  132.         if(actorid < 0) return SendClientMessage(playerid,-1,"ERROR: ID Actora ne moze biti manji od 0/ Actor id cannot be under 0");
  133.         {
  134.             SetPlayerPos(playerid, X,Y+2,Z);
  135.             ActorInfo[actorid][aSkin] = skin;
  136.             ActorInfo[actorid][aVW] = actorvw;
  137.             ActorInfo[actorid][aPozX] = X;
  138.             ActorInfo[actorid][aPozY] = Y;
  139.             ActorInfo[actorid][aPozZ] = Z;
  140.             ActorInfo[actorid][aRot] = Rot;
  141.             CreateActor(skin,X,Y,Z,Rot);
  142.             SetActorVirtualWorld(actorid, actorvw);
  143.             SaveActor(actorid);
  144.         }
  145.     }
  146.     return 1;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment