Advertisement
Guest User

HTTP crash

a guest
Aug 9th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <string.h>
  4. #include "sampgdk.h"
  5.  
  6.  
  7. void SAMPGDK_CALL PrintTickCountTimer(int timerid, void *params) {
  8.   //sampgdk::logprintf("Tick count: %d", GetTickCount());
  9.     char message[MAX_CLIENT_MESSAGE];
  10.     sprintf(message, "Hello there with timer id %d!", timerid);
  11.     SendClientMessageToAll(-1, message);
  12. }
  13.  
  14. PLUGIN_EXPORT bool PLUGIN_CALL MyHttpResponse(int index, int response_code, char data[])
  15. {
  16.     SendClientMessageToAll(0xFFFFFFFF, "HTTP response callback");
  17.     char showdata[256];
  18.     sprintf(showdata, "Index: %d ResponseCode: %d Data: %s", index, response_code, data);
  19.     SendClientMessageToAll(-1, showdata);
  20.     return true;
  21. }
  22.  
  23. void SAMPGDK_CALL OnHTTPResponse(int index, int response_code, char data[])
  24. {
  25.     SendClientMessageToAll(0xFFFFFFFF, "OnHTTPResponse");
  26.     char showdata[256];
  27.     sprintf(showdata, "Index: %d ResponseCode: %d Data: %s", index, response_code, data);
  28.     SendClientMessageToAll(-1, showdata);
  29. }
  30.  
  31. PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
  32.   //SetTimer(5000, true, PrintTickCountTimer, 0);
  33.   return true;
  34. }
  35.  
  36. PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect(int playerid) {
  37.   SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the HelloWorld server!");
  38.   return true;
  39. }
  40.  
  41. PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerRequestClass(int playerid,int classid) {
  42.     SendClientMessage(playerid, 0xFFFFFFFF, "OnPlayerRequestClass");
  43.   return true;
  44. }
  45.  
  46.  
  47. PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerText(int playerid, const char * text)
  48. {
  49.     SendClientMessage(playerid, -1, "Someone texted");
  50.     SendClientMessageToAll(-1, "Someone texted - all");
  51.     return true;
  52. }
  53.  
  54. PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerEnterVehicle(int playerid, int vehicleid, bool ispassenger)
  55. {
  56.     if (ispassenger == true)
  57.     {
  58.         SendClientMessage(playerid, -1, "You enter as passenger");
  59.     }
  60.     else
  61.     {
  62.         SendClientMessage(playerid, -1, "You enter as driver");
  63.     }
  64.    
  65.        
  66.     return 1;
  67. }
  68.  
  69. PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerCommandText(int playerid,
  70.                                                    const char *cmdtext) {
  71.   if (strcmp(cmdtext, "/hello") == 0)
  72.   {
  73.     char name[MAX_PLAYER_NAME];
  74.     GetPlayerName(playerid, name, sizeof(name));
  75.     char message[MAX_CLIENT_MESSAGE];
  76.     sprintf(message, "Hello, %s!", name);
  77.     SendClientMessage(playerid, 0x00FF00FF, message);
  78.     sampgdk_SetPlayerPos(playerid, 0, 0, 0);
  79.     return true;
  80.   }
  81.  
  82.   if (strcmp(cmdtext, "/http") == 0)
  83.   {
  84.       SendClientMessage(playerid, -1, "http command send");
  85.       HTTP(playerid, HTTP_GET, "localhost/test/old_index.php?name=ted", "MyHttpResponse");
  86.       return true;
  87.   }
  88.   return false;
  89. }
  90.  
  91. PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
  92.   return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
  93. }
  94.  
  95. PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
  96.     sampgdk::logprintf(" * Test plugin was loaded.", ppData);
  97.   return sampgdk::Load(ppData);
  98. }
  99.  
  100. PLUGIN_EXPORT void PLUGIN_CALL Unload() {
  101.   sampgdk::Unload();
  102. }
  103.  
  104. PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
  105.   sampgdk::ProcessTick();
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement