Guest User

Untitled

a guest
Dec 27th, 2017
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1.  
  2.  
  3. /*
  4. Function :
  5. SetPlayerSkinEx(playerid, skinid) // return an error msg if invalid skin id (higher than sizeof custom_skin)
  6. GetCustomSkinID(skinid) // return the CUSTOM id not the row /!\
  7. */
  8.  
  9. enum
  10. {
  11. CUSTOM_INVALID = 20000, // dont modify the id 20000
  12. CUSTOM_COP,
  13. CUSTOM_WIFE
  14.  
  15. }
  16. // baseskin, newid, dff, txd
  17. new custom_skin[][][] =
  18. {
  19. {14,CUSTOM_INVALID, "Mila.dff", "Mila.txd"}, // Let the skin with INVALID id, and a VALID data to prevent a load bug, refer sa:mp forum
  20. {14,CUSTOM_WIFE,"Mila.dff", "Mila.txd"},
  21. {14,CUSTOM_COP,"lvpdpc2.dff","lvpdpc2.txd"}
  22. };
  23.  
  24. public OnGameModeInit()
  25. {
  26. SkinModel_Init();
  27. return 1;
  28. }
  29.  
  30. stock SkinModel_Init()
  31. {
  32. for(new i; i< sizeof custom_skin; i++)
  33. {
  34. new baseskin, newskin;
  35.  
  36. baseskin = strdec(custom_skin[i][0]);
  37. newskin = strdec(custom_skin[i][1]);
  38.  
  39. printf("Loading Charmodel : %d, %d, '%s', '%s'", custom_skin[i][0], custom_skin[i][1], custom_skin[i][2], custom_skin[i][3]);
  40. new result = AddCharModel(baseskin, newskin, custom_skin[i][2], custom_skin[i][3]);
  41. if(result)
  42. printf(" Skinid : %d loaded !", i);
  43. else
  44. printf("Loading Charmodel : ERROR when loading the skin : %d", i);
  45. }
  46. return 1;
  47. }
  48.  
  49. // strdec is to prevent an incorrect value format in the addcharmodel function.
  50. stock strdec(string[]) // may not working for other string to decimal, but its working 100% for this system !!!
  51. {
  52. new var_str[50];
  53. format(var_str, 50, "%i", string);
  54. return strval(var_str);
  55. }
  56.  
  57.  
  58. stock SetPlayerSkinEx(playerid, skinid)
  59. {
  60.  
  61. if(skinid >= sizeof(custom_skin))
  62. { SendClientMessage(playerid, COLOR_ERROR, "[Skin] skinid invalide."); return 1; }
  63. printf("skin id : %d, base id : %d, new id : %d", skinid, custom_skin[skinid][0], custom_skin[skinid][1]);
  64. SetPlayerSkin(playerid, strdec(custom_skin[skinid][1]));
  65.  
  66. return 1;
  67. }
  68.  
  69. stock GetCustomSkinID(skinid)
  70. {
  71. return custom_skin[skinid][1];
  72. }
  73.  
  74.  
  75. // EXEMPLE !
  76. cmd:setcustom(playerid, params[])
  77. {
  78. if(!isAdminWriter(playerid)) { return noAccess(playerid); }
  79. new target, skinid;
  80. if(sscanf(params, "ud", target, skinid)) return SendClientMessage(playerid, COLOR_USAGE, "[Usage] /setcustom <playerid> <skinid>");
  81.  
  82. SetPlayerSkinEx(target, skinid); // check of the "id" in the function
  83.  
  84. return 1;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment