Advertisement
Guest User

SA-MP HTTP

a guest
Dec 23rd, 2011
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.66 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <a_http>
  4.  
  5. new Text:WhatsNewText[MAX_PLAYERS];
  6.  
  7. forward HideTextDraw2(playerid);
  8.  
  9. public HideTextDraw2(playerid) {
  10.  
  11.     TextDrawHideForPlayer(playerid, WhatsNewText[playerid]);
  12.     return 1;
  13. }
  14.  
  15. forward UpdateResponse(playerid, response_code, data[]);
  16.  
  17. public UpdateResponse(playerid, response_code, data[])
  18. {
  19.  
  20.     new
  21.         string[ 1028 ];
  22.  
  23.     if(response_code == 200)
  24.     {
  25.         format(string, sizeof(string), "%s", data);
  26.         TextDrawSetString(WhatsNewText[playerid], string);
  27.         TextDrawShowForPlayer(playerid, WhatsNewText[playerid]);
  28.         SetTimerEx("HideTextDraw2", 15000, false, "i", playerid);
  29.     }
  30.     else
  31.     {
  32.         format(string, sizeof(string), "The request failed! The response code was: %d", response_code);
  33.         SendClientMessage(playerid, 0xFFFFFFFF, string);
  34.     }
  35. }
  36.  
  37. public OnPlayerConnect(playerid) {
  38.  
  39.     WhatsNewText[playerid] = TextDrawCreate(36, 198, " ");
  40.     TextDrawFont(WhatsNewText[playerid], 1);
  41.     TextDrawLetterSize(WhatsNewText[playerid], 0.2, 1.4);
  42.     TextDrawColor(WhatsNewText[playerid], 0xFFFFFFFF);
  43.     TextDrawSetOutline(WhatsNewText[playerid], 0);
  44.     TextDrawSetProportional(WhatsNewText[playerid], 1);
  45.     TextDrawSetShadow(WhatsNewText[playerid], 0);
  46.     TextDrawHideForPlayer(playerid, WhatsNewText[playerid]);
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerDisconnect(playerid, reason) {
  51.     TextDrawDestroy(WhatsNewText[playerid]);
  52.     return 1;
  53. }
  54.  
  55. public OnPlayerCommandText(playerid, cmdtext[]) {
  56.  
  57.     if(strcmp(cmdtext, "/new", true) == 0)
  58.     {
  59.         HTTP(playerid, HTTP_GET, "devine-gaming.com/update_test.txt", "", "UpdateResponse");
  60.         return 1;
  61.     }
  62.  
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement