garfield

[INC]: SuYaNw's Icon Streamer

Jun 25th, 2012
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.32 KB | None | 0 0
  1. /*
  2.         SuYaNw's Icon Streamer
  3.         - Criado por G. SuYaNw Dácio.
  4.        
  5.         Aumente 5x o limite de icones no game,
  6.         tudo otimizado e simplificado.
  7.        
  8.         Parâmetros:
  9.         sCreateMapIcon(Modelo, Cor, Float:X, Float:Y, Float:Z);
  10. */
  11.  
  12. #define MAX_MAPICONS                    (500)                                   // Máximo de ícones suportados
  13. #define MAX_DISTANCE                    Float:380.0                             // Máximo de distância para exibir o ícone (380.0 PADRÃO)
  14. #define SHOW_DEBUGGING                  false                                   // Função para exibir debugging
  15.  
  16. enum siconx
  17. {
  18.     Float:Icon_X,                   Float:Icon_Y,                   Float:Icon_Z,
  19.     IconModel,                      Cor
  20. }
  21.  
  22. new
  23.     sMapIcons[MAX_MAPICONS][siconx],
  24.     LastPlayerIcon[MAX_PLAYERS char],
  25.     CurrentIconID
  26. ;
  27.  
  28.  
  29. stock sCreateMapIcon(map_model, cor,Float:mapiconx,Float:mapicony,Float:mapiconz)
  30. {
  31.     if(CurrentIconID == MAX_MAPICONS)
  32.     {
  33.         printf("[S.I.S]: Limite de icones atingido, por favor, diminuia.");
  34.         return false;
  35.     }
  36.    
  37.     sMapIcons[CurrentIconID][Icon_X]    =   mapiconx;
  38.     sMapIcons[CurrentIconID][Icon_Y]    =   mapicony;
  39.     sMapIcons[CurrentIconID][Icon_Z]    =   mapiconz;
  40.     sMapIcons[CurrentIconID][IconModel] =   map_model;
  41.     sMapIcons[CurrentIconID][Cor]       =   cor;
  42.    
  43.     #if SHOW_DEBUGGING == true
  44.     {
  45.         printf("[S.I.S]: Novo ícone criado: ID Interno: (%i) | Modelo: (%i) | Cor: (%h)| Posição(X:%f, Y:%f, Z:%f)", CurrentIconID, map_model, cor, mapiconx, mapicony, mapiconz);
  46.     }
  47.     #endif
  48.     return CurrentIconID++;
  49. }
  50.  
  51.  
  52. stock ResetMapIcons(playerid){
  53.  
  54.     for(new i; i != CurrentIconID; ++i){
  55.    
  56.         RemovePlayerMapIcon(playerid, i);
  57.         LastPlayerIcon{i} = -1;
  58.     }
  59. }
  60.  
  61. OnIconUpdate(); public OnIconUpdate()
  62. {
  63.     for(new i, getMaxPlayers = GetMaxPlayers(); i != getMaxPlayers; ++i){
  64.         if(IsPlayerConnected(i)){
  65.             for(new e; e < CurrentIconID; ++e){
  66.                 if(IsPlayerInRangeOfPoint(i, MAX_DISTANCE, sMapIcons[e][Icon_X], sMapIcons[e][Icon_Y], sMapIcons[e][Icon_Z])){
  67.                     if(LastPlayerIcon{i} == e && LastPlayerIcon{i} != -1)
  68.                     {
  69.                         #if SHOW_DEBUGGING
  70.                         {
  71.                             printf("[S.I.S]: Erro ao exibir icone -> Icone já exibido (ID:%i)", e);
  72.                         }
  73.                         #endif
  74.                         continue;
  75.                     }
  76.                     SetPlayerMapIcon(i, e, sMapIcons[e][Icon_X], sMapIcons[e][Icon_Y], sMapIcons[e][Icon_Z], sMapIcons[e][IconModel], sMapIcons[e][Cor], 0);
  77.                     LastPlayerIcon{i} = CurrentIconID;
  78.                 }
  79.                 else{
  80.                     #if SHOW_DEBUGGING
  81.                     {
  82.                         printf("[S.I.S]: Icone destruido -> Distância máxima exedida, Dis: (%f radious)", MAX_DISTANCE);
  83.                     }
  84.                     #endif
  85.                     RemovePlayerMapIcon(i, e);
  86.                     LastPlayerIcon{i} = -1;
  87.                 }
  88.             }
  89.         }
  90.     }
  91.     return 1;
  92. }
  93.  
  94.  
  95. public OnGameModeInit()
  96. {
  97.     print (#|| SuYaNw's Icon Stremaer carregado\n||#);
  98.     print ("|| --> Configuração: ");
  99.     printf("|| Máximo de ícones: %i ", MAX_MAPICONS);
  100.     printf("|| Distância Máxima: %1.0f ", MAX_DISTANCE);
  101.     printf("|| Teste  Debugging: %d\n||\n||", SHOW_DEBUGGING);
  102.    
  103.     SetTimer("OnIconUpdate", 2000, true);
  104.     return CallRemoteFunction(#sisOnGameModeInit, #);
  105. }
  106.  
  107. #if defined _ALS_OnGameModeInit
  108.     #undef OnGameModeInit
  109. #else
  110.     #define _ALS_OnGameModeInit
  111. #endif
  112. #define OnGameModeInit sisOnGameModeInit
  113.  
  114. forward sisOnGameModeInit();
  115. //
Add Comment
Please, Sign In to add comment