Advertisement
Guest User

[Include] Nachrichten-Cache

a guest
Oct 12th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. /* SA-MP Include Nachrichten-Cache System
  2.  *
  3.  * (c) by Kaliber, 2017
  4.  *
  5.  */
  6. static stock bool:inCache[MAX_PLAYERS], cache_id[MAX_PLAYERS];
  7.  
  8. stock initCache(playerid)
  9. {
  10.     inCache[playerid] = false;
  11.     cache_id[playerid] = 0;
  12.     return 1;
  13. }
  14.  
  15. stock startCache(playerid)
  16. {
  17.     inCache[playerid] = true;
  18.     return 1;
  19. }
  20.  
  21. stock bool:isCache(playerid)
  22. {
  23.     return inCache[playerid];
  24. }
  25.  
  26. stock appendCache(playerid,color,msg[])
  27. {
  28.     new string[16];
  29.     format(string,sizeof(string),"$!c_%d",cache_id[playerid]);
  30.     SetPVarString(playerid,string,msg);
  31.     cache_id[playerid]++;
  32.     format(string,sizeof(string),"$!c_%d",cache_id[playerid]);
  33.     SetPVarInt(playerid,string,color);
  34.     return ++cache_id[playerid];
  35. }
  36.  
  37. stock endCache(playerid)
  38. {
  39.     new m = cache_id[playerid];
  40.     for(new i,msg[145],string[16]; i<m; i+=2)
  41.     {
  42.         format(string,sizeof(string),"$!c_%d",i);
  43.         GetPVarString(playerid,string,msg,sizeof(msg));
  44.         DeletePVar(playerid,string);
  45.         format(string,sizeof(string),"$!c_%d",i+1);
  46.         SendClientMessage(playerid,GetPVarInt(playerid,string),msg);
  47.         DeletePVar(playerid,string);
  48.     }
  49.     inCache[playerid] = false;
  50.     cache_id[playerid] = 0;
  51.     return 1;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement