Advertisement
ZumeZero

zAnimsFix Include SAMP

Feb 1st, 2015
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.71 KB | None | 0 0
  1. /* zAnimsFix & _Zume    */
  2.  
  3. #if !defined _samp_included
  4.     #error "Falta incluir a_samp, si no el include zAnimsFix no funciona!"
  5. #endif
  6.  
  7. #if !defined _zAnimsFix_include
  8.     #define _zAnimsFix_include
  9. #else
  10.     #endinput
  11. #endif
  12.  
  13. #define LastAnimExecuted    _getLastAnim
  14. #define LastAnimLibExecuted _getLastLib
  15. #define IsAnimLibExist      _animLibExist
  16.  
  17. #if !defined isnull
  18.     #define isnull(%1) \
  19.                 ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  20. #endif
  21.  
  22. enum _pAnims
  23. {
  24.     _pPreloadedAll,
  25.     _pAnimExecute,
  26.     _pLastAnim[32 char],
  27.     _pLastAnimLib[32 char],
  28.  
  29. };
  30. new _eAnim[MAX_PLAYERS][_pAnims];
  31.  
  32. static const _AnimsEnum[][] =
  33. {
  34.     "AIRPORT",      "Attractors",   "BAR",          "BASEBALL",     "BD_FIRE",
  35.     "BEACH",        "benchpress",   "BF_injection", "BIKED",        "BIKEH",
  36.     "BIKELEAP",     "BIKES",        "BIKEV",        "BIKE_DBZ",     "BLOWJOBZ",
  37.     "BMX",          "BOMBER",       "BOX",          "BSKTBALL",     "BUDDY",
  38.     "BUS",          "CAMERA",       "CAR",          "CARRY",        "CAR_CHAT",
  39.     "CASINO",       "CHAINSAW",     "CHOPPA",       "CLOTHES",      "COACH",
  40.     "COLT45",       "COP_AMBIENT""COP_DVBYZ",    "CRACK",        "CRIB",
  41.     "DAM_JUMP",     "DANCING",      "DEALER",       "DILDO",        "DODGE",
  42.     "DOZER",        "DRIVEBYS",     "FAT",          "FIGHT_B",      "FIGHT_C",
  43.     "FIGHT_D",      "FIGHT_E",      "FINALE",       "FINALE2",      "FLAME",
  44.     "Flowers",      "FOOD",         "Freeweights""GANGS",        "GHANDS",
  45.     "GHETTO_DB",    "goggles",      "GRAFFITI",     "GRAVEYARD",    "GRENADE",
  46.     "GYMNASIUM",    "HAIRCUTS",     "HEIST9",       "INT_HOUSE",    "INT_OFFICE",
  47.     "INT_SHOP",     "JST_BUISNESS", "KART",         "KISSING",      "KNIFE",
  48.     "LAPDAN1",      "LAPDAN2",      "LAPDAN3",      "LOWRIDER",     "MD_CHASE",
  49.     "MD_END",       "MEDIC",        "MISC",         "MTB",          "MUSCULAR",
  50.     "NEVADA",       "ON_LOOKERS",   "OTB",          "PARACHUTE",    "PARK",
  51.     "PAULNMAC",     "ped",          "PLAYER_DVBYS", "PLAYIDLES",    "POLICE",
  52.     "POOL",         "POOR",         "PYTHON",       "QUAD",         "QUAD_DBZ",
  53.     "RAPPING",      "RIFLE",        "RIOT",         "ROB_BANK",     "ROCKET",
  54.     "RUSTLER",      "RYDER",        "SCRATCHING",   "SHAMAL",       "SHOP",
  55.     "SHOTGUN",      "SILENCED",     "SKATE",        "SMOKING",      "SNIPER",
  56.     "SPRAYCAN",     "STRIP",        "SUNBATHE",     "SWAT",         "SWEET",
  57.     "SWIM",         "SWORD",        "TANK",         "TATTOOS",      "TEC",
  58.     "TRAIN",        "TRUCK",        "UZI",          "VAN",          "VENDING",
  59.     "VORTEX",       "WAYFARER",     "WEAPONS",      "WUZI"
  60. };
  61.  
  62. stock _animLibExist(_LoadAnin[])
  63. {
  64.     if(_LoadAnin[0] == '\0')
  65.         return 0;
  66.  
  67.     for(new i = 0; i < sizeof(_AnimsEnum); i ++)
  68.     {
  69.         if(!strcmp(_LoadAnin, _AnimsEnum[i], true))
  70.         {
  71.             return 1;
  72.         }
  73.     }
  74.     return 0;
  75. }
  76.  
  77. stock _animPreload(playerid, _LoadAnim[] = '\0')
  78. {
  79.     if(!IsPlayerConnected(playerid))
  80.         return 0;
  81.  
  82.     if(_eAnim[playerid][_pPreloadedAll] == sizeof(_AnimsEnum))
  83.         return 0;
  84.  
  85.     new
  86.         bool:_loaded = false,
  87.         _totalanims = 0;
  88.  
  89.     if((_LoadAnim[0] != '\0') && _animLibExist(_LoadAnim))
  90.     {
  91.         _eAnim[playerid][_pPreloadedAll] ++;
  92.         _loaded = true;
  93.         return (ApplyAnimation(playerid, _LoadAnim, "null", 4.0, 0, 0, 0, 0, 0, 1));
  94.     }
  95.     else
  96.     {
  97.         for(new i = 0; i < sizeof(_AnimsEnum); i ++)
  98.         {
  99.             ApplyAnimation(playerid, _AnimsEnum[i], "null", 4.0, 0, 0, 0, 0, 0, 1);
  100.             _totalanims++;
  101.         }
  102.         _loaded = true;
  103.     }
  104.     if(_loaded)
  105.     {
  106.         _eAnim[playerid][_pPreloadedAll] = _totalanims;
  107.     }
  108.     return 1;
  109. }
  110.  
  111. stock _getLastAnim(playerid)
  112. {
  113.     if(!IsPlayerConnected(playerid))
  114.         return 0;
  115.  
  116.     new
  117.         string[33] = "None"
  118.         ;
  119.  
  120.     if(!isnull(_eAnim[playerid][_pLastAnim])){
  121.         strunpack(string, _eAnim[playerid][_pLastAnim]);
  122.     }
  123.     return string;
  124. }
  125.  
  126. stock _getLastLib(playerid)
  127. {
  128.     if(!IsPlayerConnected(playerid))
  129.         return 0;
  130.  
  131.     new
  132.         string[33] = "None"
  133.         ;
  134.  
  135.     if(!isnull(_eAnim[playerid][_pLastAnimLib])){
  136.         strunpack(string, _eAnim[playerid][_pLastAnimLib]);
  137.     }
  138.     return string;
  139. }
  140.  
  141. stock _resetPlayerAnims(playerid)
  142. {
  143.     if(!IsPlayerConnected(playerid))
  144.         return 0;
  145.  
  146.     _eAnim[playerid][_pPreloadedAll] = 0;
  147.     _eAnim[playerid][_pAnimExecute] = 0;
  148.     _eAnim[playerid][_pLastAnim][0] = '\0';
  149.     _eAnim[playerid][_pLastAnimLib][0] = '\0';
  150. }
  151.  
  152. stock _AppliAnimEx(playerid, animlib[], anim[], vel = 4, bucle = 0, lockx = 1, locky = 1, freeze = 1, time = 1, sync = 1)
  153. {
  154.     if(IsPlayerConnected(playerid))
  155.     {
  156.         if(!strcmp(_getLastAnim(playerid), anim, true))
  157.         {
  158.             if(_eAnim[playerid][_pAnimExecute] > gettime())
  159.             {
  160.                 return 0;
  161.             }
  162.         }
  163.         new
  164.             bool:_animLibExist = false;
  165.  
  166.         if(!strcmp(_getLastLib(playerid), animlib, true))
  167.         {
  168.             _animLibExist = true;
  169.         }
  170.         else
  171.         {
  172.             if(_animLibExist != true)
  173.             {
  174.                 _animLibExist = ((_animLibExist(animlib)) ? (true) : (false));
  175.             }
  176.         }
  177.         if(_animLibExist != false)
  178.         {
  179.             ApplyAnimation(playerid, animlib, anim, vel, bucle, lockx, locky, freeze, time, sync);
  180.             _eAnim[playerid][_pAnimExecute] = gettime()+1;
  181.             strunpack(_eAnim[playerid][_pLastAnimLib], animlib);
  182.             strunpack(_eAnim[playerid][_pLastAnim], anim);
  183.             return 1;
  184.         }
  185.     }
  186.     return 0;
  187. }
  188.  
  189. public OnPlayerSpawn(playerid)
  190. {
  191.     _animPreload(playerid);
  192.  
  193.     #if defined zHook_OnPlayerSpawn
  194.         return zHook_OnPlayerSpawn();
  195.     #else
  196.         return 1;
  197.     #endif
  198. }
  199.  
  200. public OnPlayerConnect(playerid)
  201. {
  202.     _resetPlayerAnims(playerid);
  203.  
  204.     #if defined zHook_OnPlayerConnect
  205.         return zHook_OnPlayerConnect();
  206.     #else
  207.         return 1;
  208.     #endif
  209. }
  210.  
  211. #if defined _ALS_OnPlayerConnect
  212.     #undef OnPlayerConnect
  213. #else
  214.     #define _ALS_OnPlayerConnect
  215. #endif
  216.  
  217. #if defined _ALS_OnPlayerSpawn
  218.     #undef OnPlayerSpawn
  219. #else
  220.     #define _ALS_OnPlayerSpawn
  221. #endif
  222.  
  223. #if defined _ALS_ApplyAnimation
  224.     #undef ApplyAnimation
  225. #else
  226.     #define _ALS_ApplyAnimation
  227. #endif
  228.  
  229. #define ApplyAnimation          _AppliAnimEx
  230. #define OnPlayerSpawn           zHook_OnPlayerSpawn
  231. #define OnPlayerConnect         zHook_OnPlayerConnect
  232.  
  233. #if defined zHook_OnPlayerSpawn
  234.     forward zHook_OnPlayerSpawn();
  235. #endif
  236.  
  237. #if defined zHook_OnPlayerConnect
  238.     forward zHook_OnPlayerConnect();
  239. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement