Advertisement
Guest User

Untitled

a guest
Apr 6th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 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 SetPlayerPosFade(playerid,steps,Float:x,Float:y,Float:z);
  31. */
  32.  
  33.  
  34. stock SetPlayerPosFade(playerid,steps,interior,Float:x,Float:y,Float:z)
  35. {
  36. _PlayerTeleporting[playerid]=1;
  37. _pTPToPos[playerid][0]=x;
  38. _pTPToPos[playerid][1]=y;
  39. _pTPToPos[playerid][2]=z;
  40. _pTPSteps[playerid]=steps;
  41. _PlayerInterior[playerid]=interior;
  42. FadeColorForPlayer(playerid,0,0,0,0,_TELEPORTFADECOLORR,_TELEPORTFADECOLORG,_TELEPORTFADECOLORB,_TELEPORTFADECOLORA,steps,1);
  43. }
  44. stock ConvertToColor(RR,GG,BB,AA)return (RR*16777216)+(GG*65536)+(BB*256)+AA;
  45. stock _UpdateOPA(playerid=INVALID_PLAYER_ID) //my version of foreach (I made it before Y_Less did! publicly anyway)
  46. {
  47. _OnlinePlayers=0;
  48. for(new ply;ply<MAX_PLAYERS;ply++)
  49. {
  50. if(IsPlayerConnected(ply)&&(ply!=playerid))
  51. {
  52. _OPArray[_OnlinePlayers]=ply;
  53. _OnlinePlayers++;
  54. }
  55. }
  56. }
  57. stock FadeColorForPlayer(playerid,RR1,GG1,BB1,AA1,RR2,GG2,BB2,AA2,steps,hold)
  58. {
  59. _pStep[playerid]=steps;//countdown, sorta
  60. new tmpsteps; //This will have to be added to incase the math is messed up (programming annoyance)
  61. _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)
  62. _pEndColor[playerid][0]=RR2;
  63. _pEndColor[playerid][1]=GG2;
  64. _pEndColor[playerid][2]=BB2;
  65. _pEndColor[playerid][3]=AA2;
  66. _pCurrentColor[playerid][0]=RR1;
  67. _pCurrentColor[playerid][1]=GG1;
  68. _pCurrentColor[playerid][2]=BB1;
  69. _pCurrentColor[playerid][3]=AA1;
  70. _pRateColor[playerid][0]=(RR1-RR2)/steps;
  71. _pRateColor[playerid][1]=(GG1-GG2)/steps;
  72. _pRateColor[playerid][2]=(BB1-BB2)/steps;
  73. _pRateColor[playerid][3]=(AA1-AA2)/steps;
  74. //No dividing by 0!
  75. if(_pRateColor[playerid][0]!=0)if(((RR1-RR2)/_pRateColor[playerid][0])>steps)tmpsteps=((RR1-RR2)/_pRateColor[playerid][0])-steps;
  76. if(_pRateColor[playerid][1]!=0)if(((GG1-GG2)/_pRateColor[playerid][1])>steps+tmpsteps)tmpsteps=((GG1-GG2)/_pRateColor[playerid][1])-steps;
  77. if(_pRateColor[playerid][2]!=0)if(((BB1-BB2)/_pRateColor[playerid][2])>steps+tmpsteps)tmpsteps=((BB1-BB2)/_pRateColor[playerid][2])-steps;
  78. if(_pRateColor[playerid][3]!=0)if(((AA1-AA2)/_pRateColor[playerid][3])>steps+tmpsteps)tmpsteps=((AA1-AA2)/_pRateColor[playerid][3])-steps;
  79. if(tmpsteps)_pStep[playerid]+=tmpsteps+1;
  80. }
  81.  
  82.  
  83. #if defined FILTERSCRIPT
  84. public OnFilterScriptInit()
  85. {
  86. FadeInit();
  87.  
  88. if (funcidx("Fader_OnFilterScriptInit") != -1)
  89. {
  90. return CallLocalFunction("Fader_OnFilterScriptInit", "i", playerid);
  91. }
  92. return 1;
  93. }
  94.  
  95. #if defined _ALS_OnFilterScriptInit
  96. #undef OnFilterScriptInit
  97. #else
  98. #define _ALS_OnFilterScriptInit
  99. #endif
  100. #define OnFilterScriptInit Fader_OnFilterScriptInit
  101.  
  102. forward Fader_OnFilterScriptInit(playerid);
  103.  
  104. #else
  105. public OnGameModeInit()
  106. {
  107. FadeInit();
  108.  
  109. if (funcidx("Fader_OnGameModeInit") != -1)
  110. {
  111. return CallLocalFunction("Fader_OnGameModeInit", "i", playerid);
  112. }
  113. return 1;
  114. }
  115.  
  116. #if defined _ALS_OnGameModeInit
  117. #undef OnGameModeInit
  118. #else
  119. #define _ALS_OnGameModeInit
  120. #endif
  121. #define OnGameModeInit Fader_OnGameModeInit
  122.  
  123. forward Fader_OnGameModeInit(playerid);
  124.  
  125. #endif
  126.  
  127. FadeInit()
  128. {
  129. _text=TextDrawCreate(0.0,0.0,"~r~");
  130. TextDrawTextSize(_text,640,480);
  131. TextDrawLetterSize(_text,0.0,50.0);
  132. TextDrawUseBox(_text,1);
  133. SetTimer("_UpdateFadeTimer",_UPDATERATE,1);
  134. _UpdateOPA();
  135. return 1;
  136. }
  137.  
  138. #if defined FILTERSCRIPT
  139. public OnFilterScriptInit()
  140. {
  141. FadeInit();
  142.  
  143. if (funcidx("Fader_OnFilterScriptInit") != -1)
  144. {
  145. return CallLocalFunction("Fader_OnFilterScriptInit", "");
  146. }
  147. return 1;
  148. }
  149.  
  150. #if defined _ALS_OnFilterScriptExit
  151. #undef OnFilterScriptExit
  152. #else
  153. #define _ALS_OnFilterScriptExit
  154. #endif
  155. #define OnFilterScriptExit Fader_OnFilterScriptExit
  156.  
  157. forward Fader_OnFilterScriptExit(playerid);
  158.  
  159. #else
  160. public OnGameModeExit()
  161. {
  162. FadeExit();
  163.  
  164. if (funcidx("Fader_OnGameModeExit") != -1)
  165. {
  166. return CallLocalFunction("Fader_OnGameModeExit", "");
  167. }
  168. return 1;
  169. }
  170.  
  171. #if defined _ALS_OnGameModeExit
  172. #undef OnGameModeExit
  173. #else
  174. #define _ALS_OnGameModeExit
  175. #endif
  176. #define OnGameModeExit Fader_OnGameModeExit
  177.  
  178. forward Fader_OnGameModeExit(playerid);
  179.  
  180. #endif
  181.  
  182. FadeExit()
  183. {
  184. TextDrawDestroy(_text);
  185. return 1;
  186. }
  187.  
  188. public OnPlayerConnect(playerid)
  189. {
  190. _UpdateOPA();
  191. _pHold[playerid]=-1;
  192. _pStep[playerid]=-1;
  193. _PlayerTeleporting[playerid]=0;
  194.  
  195. if (funcidx("Fader_OnPlayerConnect") != -1)
  196. {
  197. return CallLocalFunction("Fader_OnPlayerConnect", "i", playerid);
  198. }
  199. return 1;
  200. }
  201.  
  202. #if defined _ALS_OnPlayerConnect
  203. #undef OnPlayerConnect
  204. #else
  205. #define _ALS_OnPlayerConnect
  206. #endif
  207. #define OnPlayerConnect Fader_OnPlayerConnect
  208.  
  209. forward Fader_OnPlayerConnect(playerid);
  210.  
  211.  
  212. public OnPlayerDisconnect(playerid, reason)
  213. {
  214. _UpdateOPA(playerid);
  215. if (funcidx("Fader_OnPlayerDisconnect") != -1)
  216. {
  217. return CallLocalFunction("Fader_OnPlayerDisconnect", "ii", playerid, reason);
  218. }
  219. return 1;
  220. }
  221.  
  222. #if defined _ALS_OnPlayerDisconnect
  223. #undef OnPlayerDisconnect
  224. #else
  225. #define _ALS_OnPlayerDisconnect
  226. #endif
  227. #define OnPlayerDisconnect Fader_OnPlayerDisconnect
  228.  
  229. forward Fader_OnPlayerDisconnect(playerid);
  230.  
  231.  
  232. stock StopPlayerFade(playerid)
  233. {
  234. _pStep[playerid]=0;
  235. _pHold[playerid]=0;
  236. }
  237. public _UpdateFadeTimer()
  238. {
  239. new playerid;
  240. for(new opa;opa<_OnlinePlayers;opa++)
  241. {
  242. playerid=_OPArray[opa];
  243. if(_pStep[playerid])
  244. {
  245. _pStep[playerid]--;
  246. for(new color;color<4;color++)
  247. {
  248. _pCurrentColor[playerid][color]-=_pRateColor[playerid][color];
  249. if(_pRateColor[playerid][color]>0)
  250. {
  251. if(_pCurrentColor[playerid][color]<_pEndColor[playerid][color])_pCurrentColor[playerid][color]=_pEndColor[playerid][color];
  252. }
  253. if(_pRateColor[playerid][color]<0)
  254. {
  255. if(_pCurrentColor[playerid][color]>_pEndColor[playerid][color])_pCurrentColor[playerid][color]=_pEndColor[playerid][color];
  256. }
  257. if(_pCurrentColor[playerid][color]<0)_pCurrentColor[playerid][color]=0;
  258. if(_pCurrentColor[playerid][color]>255)_pCurrentColor[playerid][color]=255;
  259. }
  260. TextDrawBoxColor(_text,ConvertToColor(_pCurrentColor[playerid][0],_pCurrentColor[playerid][1],_pCurrentColor[playerid][2],_pCurrentColor[playerid][3]));
  261. TextDrawShowForPlayer(playerid,_text);
  262. }
  263. else if(_pStep[playerid]==0)
  264. {
  265. _pStep[playerid]=-1;
  266. if(_PlayerTeleporting[playerid]==1)
  267. {
  268. SetPlayerPos(playerid,_pTPToPos[playerid][0],_pTPToPos[playerid][1],_pTPToPos[playerid][2]);
  269. SetPlayerInterior(playerid,_PlayerInterior[playerid]);
  270. FadeColorForPlayer(playerid,_TELEPORTFADECOLORR,_TELEPORTFADECOLORG,_TELEPORTFADECOLORB,_TELEPORTFADECOLORA,0,0,0,0,_pTPSteps[playerid],1);
  271. _PlayerTeleporting[playerid]=2;
  272. }else if(_PlayerTeleporting[playerid]==2)
  273. {
  274. _PlayerTeleporting[playerid]=0;
  275. }
  276. else
  277. {
  278. CallLocalFunction("OnFadeComplete","ii",playerid,1);
  279. }
  280. }
  281. else if(_pHold[playerid])
  282. {
  283. _pHold[playerid]--;
  284. }
  285. else if(_pHold[playerid]==0)
  286. {
  287. _pHold[playerid]=-1;
  288. TextDrawHideForPlayer(playerid,_text);
  289. CallLocalFunction("OnFadeComplete","ii",playerid,0);
  290. }
  291. }
  292. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement