SHARE
TWEET

Pubnite Custom items

a guest Apr 20th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define MAX_CUSTOM_ITEMS    10
  2.  
  3. enum cCustomItensData
  4. {
  5.     szCustomItemName[MAX_MODEL_LENGTH],
  6.     szCustomItemModel[MAX_MODEL_LENGTH],
  7.     iCustomItemRarity,
  8.     iCustomItemID,
  9.     iCustomItemPluginID,
  10.     iCustomItemFuncID
  11. }
  12.  
  13. new g_szCustomItem[MAX_CUSTOM_ITEMS][cCustomItensData]
  14. new g_iCustomItensLoaded
  15.  
  16. public _HasCustomItem()
  17. {
  18.     new id = get_param(1), iCustomItem = get_param(2), iReturn;
  19.  
  20.     if(iCustomItem >= MAX_CUSTOM_ITEMS || iCustonItem < 0)
  21.         return -1;
  22.  
  23.     if(g_szCustomItem[iCustomItem][iCustomItemFuncID] < 0)
  24.         return -1;
  25.  
  26.     callfunc_begin_i(g_szCustomItem[iCustomItem][iCustomItemFuncID], g_szCustomItem[iCustomItem][iCustomItemPluginID])
  27.     callfunc_push_int(id);
  28.     callfunc_push_intrf(iReturn)
  29.     callfunc_end();
  30.  
  31.     return iReturn;
  32. }
  33. //pubnite_register_customitem(szCustomItemName[32], szCustomItemModel[64], iCustomItemRarity, func_hasItem[31])
  34. public _RegisterCustomItem(iPlugin, iParams)
  35. {
  36.  
  37.     if(iParams != 4)
  38.     {
  39.         log_error(AMX_ERR_PARAMS, "[PUBNite Custom Items] This native use 4 params. You have: %d.", iParams)
  40.         return -1;
  41.     }
  42.  
  43.     if(g_iCustomItensLoaded >= MAX_CUSTOM_ITEMS)
  44.     {
  45.         log_amx("Couldn't create more custom items, the max value has been reached!")
  46.         return -1;
  47.     }
  48.  
  49.     new szNativeStringParams[3][MAX_MODEL_LENGTH]
  50.     get_string(2, szNativeStringParams[1], charsmax(szNativeStringParams[]))
  51.  
  52.     if(!precacheModel(szNativeStringParams[1]))
  53.     {
  54.         log_amx("Model ^"%s^" does not exists!", szNativeStringParams[1])
  55.         return -1;
  56.     }
  57.     get_string(1, szNativeStringParams[0], charsmax(szNativeStringParams[]))
  58.  
  59.     g_szCustomItem[g_iCustomItensLoaded][szCustomItemName] = szNativeStringParams[0]
  60.     g_szCustomItem[g_iCustomItensLoaded][szCustomItemModel] = szNativeStringParams[1]
  61.  
  62.     g_szCustomItem[g_iCustomItensLoaded][iCustomItemRarity] = get_param(3)
  63.  
  64.     get_string(4, szNativeStringParams[2], charsmax(szNativeStringParams[]))
  65.     g_szCustomItem[g_iCustomItensLoaded][iCustomItemPluginID] = iPlugin;
  66.     g_szCustomItem[g_iCustomItensLoaded++][iCustomItemFuncID] = get_func_id(szNativeStringParams[2], iPlugin);
  67.  
  68.     return g_iCustomItensLoaded - 1;
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top