YashasSamaga

Untitled

Feb 23rd, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1.     cell AMX_NATIVE_CALL GetScriptKeyFromIdentifier(AMX* amx, cell* params)
  2.     {
  3.         int len;
  4.         cell *addr = NULL;
  5.         amx_GetAddr(amx, params[1], &addr);
  6.         amx_StrLen(addr, &len);
  7.  
  8.         char scriptIdentifier_cstr[SCRIPT_IDENTIFIER_SIZE];
  9.         amx_GetString(scriptIdentifier_cstr, addr, 0, SCRIPT_IDENTIFIER_SIZE);
  10.  
  11.         std::string scriptIdentifier = scriptIdentifier_cstr; //THIS IS KILLING ME; I have to make a copy of a C string
  12.  
  13.         cell * scriptID;
  14.         amx_GetAddr(amx, params[2], &scriptID);
  15.  
  16.         int count = 0;
  17.         for (auto amx_interface = InterfaceList.begin(), interface_list_end = InterfaceList.end(); amx_interface != interface_list_end; amx_interface++)
  18.         {
  19.             if (scriptIdentifier == (*amx_interface).ScriptIdentifier)
  20.             {
  21.                 if (count < static_cast<int>(params[3]))
  22.                 {
  23.                     *scriptID++ = static_cast<cell>((*amx_interface).ScriptKey);
  24.                     count++;
  25.                 }
  26.             }
  27.         }
  28.         return static_cast<cell>(count);
  29.     }
Add Comment
Please, Sign In to add comment