Guest User

Untitled

a guest
Nov 15th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.67 KB | None | 0 0
  1. ///////////////////////////////////////
  2. ///////////Made by Joe Staff///////////
  3. ///////////////////////////////////////
  4.  
  5. #include <a_samp>
  6. #define _UPDATERATE 100 //milliseconds
  7. #define _TELEPORTFADECOLORR 0
  8. #define _TELEPORTFADECOLORG 0
  9. #define _TELEPORTFADECOLORB 0
  10. #define _TELEPORTFADECOLORA 255
  11. forward _UpdateFadeTimer();
  12. forward OnFadeComplete(playerid,beforehold);
  13. new _pEndColor[MAX_PLAYERS][4];
  14. new _pCurrentColor[MAX_PLAYERS][4];
  15. new _pRateColor[MAX_PLAYERS][4];
  16. new _pStep[MAX_PLAYERS];
  17. new _pHold[MAX_PLAYERS];
  18. new _OPArray[MAX_PLAYERS];
  19. new _OnlinePlayers;
  20. new _PlayerTeleporting[MAX_PLAYERS];
  21. new _PlayerInterior[MAX_PLAYERS];
  22. new Float:_pTPToPos[MAX_PLAYERS][3];
  23. new _pTPSteps[MAX_PLAYERS];
  24. new Text:_text; //Look, only one!
  25.  
  26. /*
  27. native ConvertToColor(RR,GG,BB,AA);
  28. native StopPlayerFade(playerid);
  29. native FadeColorForPlayer(playerid,RR1,GG1,BB1,AA1,RR2,GG2,BB2,AA2,steps,hold);
  30. native FadeInit();
  31. native FadeExit();
  32. native FadePlayerConnect(playerid);
  33. native FadePlayerDisonnect(playerid);
  34. native SetPlayerPosFade(playerid,steps,Float:x,Float:y,Float:z);
  35. */
  36.  
  37.  
  38. stock SetPlayerPosFade(playerid,steps,interior,Float:x,Float:y,Float:z)
  39. {
  40.     _PlayerTeleporting[playerid]=1;
  41.     _pTPToPos[playerid][0]=x;
  42.     _pTPToPos[playerid][1]=y;
  43.     _pTPToPos[playerid][2]=z;
  44.     _pTPSteps[playerid]=steps;
  45.     _PlayerInterior[playerid]=interior;
  46.     FadeColorForPlayer(playerid,0,0,0,0,_TELEPORTFADECOLORR,_TELEPORTFADECOLORG,_TELEPORTFADECOLORB,_TELEPORTFADECOLORA,steps,1);
  47. }
  48. stock ConvertToColor(RR,GG,BB,AA)return (RR*16777216)+(GG*65536)+(BB*256)+AA;
  49. stock _UpdateOPA(playerid=INVALID_PLAYER_ID) //my version of foreach (I made it before Y_Less did! publicly anyway)
  50. {
  51.     _OnlinePlayers=0;
  52.     for(new ply;ply<MAX_PLAYERS;ply++)
  53.     {
  54.         if(IsPlayerConnected(ply)&&(ply!=playerid))
  55.         {
  56.             _OPArray[_OnlinePlayers]=ply;
  57.             _OnlinePlayers++;
  58.         }
  59.     }
  60. }
  61. stock FadeColorForPlayer(playerid,RR1,GG1,BB1,AA1,RR2,GG2,BB2,AA2,steps,hold)
  62. {
  63.     _pStep[playerid]=steps;//countdown, sorta
  64.     new tmpsteps; //This will have to be added to incase the math is messed up (programming annoyance)
  65.     _pHold[playerid]=hold;//How long the last color is held before disappearing (Divide this by UPDATERATE to get the time Ex:hold=10, in milliseconds that's 1000)
  66.     _pEndColor[playerid][0]=RR2;
  67.     _pEndColor[playerid][1]=GG2;
  68.     _pEndColor[playerid][2]=BB2;
  69.     _pEndColor[playerid][3]=AA2;
  70.     _pCurrentColor[playerid][0]=RR1;
  71.     _pCurrentColor[playerid][1]=GG1;
  72.     _pCurrentColor[playerid][2]=BB1;
  73.     _pCurrentColor[playerid][3]=AA1;
  74.     _pRateColor[playerid][0]=(RR1-RR2)/steps;
  75.     _pRateColor[playerid][1]=(GG1-GG2)/steps;
  76.     _pRateColor[playerid][2]=(BB1-BB2)/steps;
  77.     _pRateColor[playerid][3]=(AA1-AA2)/steps;
  78.     //No dividing by 0!
  79.     if(_pRateColor[playerid][0]!=0)if(((RR1-RR2)/_pRateColor[playerid][0])>steps)tmpsteps=((RR1-RR2)/_pRateColor[playerid][0])-steps;
  80.     if(_pRateColor[playerid][1]!=0)if(((GG1-GG2)/_pRateColor[playerid][1])>steps+tmpsteps)tmpsteps=((GG1-GG2)/_pRateColor[playerid][1])-steps;
  81.     if(_pRateColor[playerid][2]!=0)if(((BB1-BB2)/_pRateColor[playerid][2])>steps+tmpsteps)tmpsteps=((BB1-BB2)/_pRateColor[playerid][2])-steps;
  82.     if(_pRateColor[playerid][3]!=0)if(((AA1-AA2)/_pRateColor[playerid][3])>steps+tmpsteps)tmpsteps=((AA1-AA2)/_pRateColor[playerid][3])-steps;
  83.     if(tmpsteps)_pStep[playerid]+=tmpsteps+1;
  84. }
  85. FadeInit()
  86. {
  87.     _text=TextDrawCreate(0.0,0.0,"~r~");
  88.     TextDrawTextSize(_text,640,480);
  89.     TextDrawLetterSize(_text,0.0,50.0);
  90.     TextDrawUseBox(_text,1);
  91.     SetTimer("_UpdateFadeTimer",_UPDATERATE,1);
  92.     _UpdateOPA();
  93.     return 1;
  94. }
  95. FadeExit()
  96. {
  97.     TextDrawDestroy(_text);
  98.     return 1;
  99. }
  100. FadePlayerConnect(playerid)
  101. {
  102.     _UpdateOPA();
  103.     _pHold[playerid]=-1;
  104.     _pStep[playerid]=-1;
  105.     _PlayerTeleporting[playerid]=0;
  106.     return 1;
  107. }
  108. FadePlayerDisconnect(playerid)
  109. {
  110.     _UpdateOPA(playerid);
  111.     return 1;
  112. }
  113. stock StopPlayerFade(playerid)
  114. {
  115.     _pStep[playerid]=0;
  116.     _pHold[playerid]=0;
  117. }
  118. public _UpdateFadeTimer()
  119. {
  120.     new playerid;
  121.     for(new opa;opa<_OnlinePlayers;opa++)
  122.     {
  123.         playerid=_OPArray[opa];
  124.         if(_pStep[playerid])
  125.         {
  126.             _pStep[playerid]--;
  127.             for(new color;color<4;color++)
  128.             {
  129.                 _pCurrentColor[playerid][color]-=_pRateColor[playerid][color];
  130.                 if(_pRateColor[playerid][color]>0)
  131.                 {
  132.                     if(_pCurrentColor[playerid][color]<_pEndColor[playerid][color])_pCurrentColor[playerid][color]=_pEndColor[playerid][color];
  133.                 }
  134.                 if(_pRateColor[playerid][color]<0)
  135.                 {
  136.                     if(_pCurrentColor[playerid][color]>_pEndColor[playerid][color])_pCurrentColor[playerid][color]=_pEndColor[playerid][color];
  137.                 }
  138.                 if(_pCurrentColor[playerid][color]<0)_pCurrentColor[playerid][color]=0;
  139.                 if(_pCurrentColor[playerid][color]>255)_pCurrentColor[playerid][color]=255;
  140.             }
  141.             TextDrawBoxColor(_text,ConvertToColor(_pCurrentColor[playerid][0],_pCurrentColor[playerid][1],_pCurrentColor[playerid][2],_pCurrentColor[playerid][3]));
  142.             TextDrawShowForPlayer(playerid,_text);
  143.         }
  144.         else if(_pStep[playerid]==0)
  145.         {
  146.             _pStep[playerid]=-1;
  147.             if(_PlayerTeleporting[playerid]==1)
  148.             {
  149.                 SetPlayerPos(playerid,_pTPToPos[playerid][0],_pTPToPos[playerid][1],_pTPToPos[playerid][2]);
  150.                 SetPlayerInterior(playerid,_PlayerInterior[playerid]);
  151.                 FadeColorForPlayer(playerid,_TELEPORTFADECOLORR,_TELEPORTFADECOLORG,_TELEPORTFADECOLORB,_TELEPORTFADECOLORA,0,0,0,0,_pTPSteps[playerid],1);
  152.                 _PlayerTeleporting[playerid]=2;
  153.             }else if(_PlayerTeleporting[playerid]==2)
  154.             {
  155.                 _PlayerTeleporting[playerid]=0;
  156.             }
  157.             else           
  158.             {
  159.                 CallLocalFunction("OnFadeComplete","ii",playerid,1);
  160.             }
  161.         }
  162.         else if(_pHold[playerid])
  163.         {
  164.             _pHold[playerid]--;
  165.         }
  166.         else if(_pHold[playerid]==0)
  167.         {
  168.             _pHold[playerid]=-1;
  169.             TextDrawHideForPlayer(playerid,_text);
  170.             CallLocalFunction("OnFadeComplete","ii",playerid,0);
  171.         }
  172.     }
  173. }
Add Comment
Please, Sign In to add comment