BlackDonelly

BLACK DONELLY CLASS SELECTION CREATOR VERSÃO STRCMP

Jul 19th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1.  
  2. ////////////////////////////////////////////////////////////////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // BLACK DONELLY CLASS SELECTION CREATOR VERSÃO STRCMP 18/07/2012
  5. ////////////////////////////////////////////////////////////////////////////////
  6. ////////////////////////////////////////////////////////////////////////////////
  7.  
  8. #include <a_samp>
  9.  
  10. public OnFilterScriptInit()
  11. {
  12. print("\n--------------------------------------");
  13. print(" BLACK DONELLY STRCMP CLASS SELECTION CREATOR CARREGADO!");
  14. print("--------------------------------------\n");
  15. return 1;
  16. }
  17.  
  18. public OnFilterScriptExit()
  19. {
  20. print("\n--------------------------------------");
  21. print(" BLACK DONELLY STRCMP CLASS SELECTION CREATOR DESCARREGADO!");
  22. print("--------------------------------------\n");
  23. return 1;
  24. }
  25.  
  26. public OnPlayerCommandText(playerid, cmdtext[])
  27. {
  28. new index, cmd[128];
  29. cmd = strtok(cmdtext, index);
  30. if (!strcmp("/scs",cmd,true))
  31. {
  32. new tmp[128];
  33. tmp = strtok(cmdtext, index);
  34. if(!strlen(tmp) || !IsNumeric(tmp)) return SendClientMessage(playerid,-1,"USO: /scs [disctância entre 2 e 8]");
  35. static Float:pPos[6],string[160];
  36. new distancia=strval(tmp);
  37. GetPlayerPos(playerid,pPos[0],pPos[1],pPos[2]);
  38. GetPlayerFacingAngle(playerid,pPos[3]);
  39. GetXYInFrontOfPlayer(playerid, pPos[4], pPos[5], distancia);
  40. new File:filex = fopen("ClassPosions.txt", io_append);
  41. fwrite(filex,"//=============================================================== \r\n");
  42. fwrite(filex,"NA PUBLIC OnPlayerRequestClass COLE ISTO:\r\n");
  43. fwrite(filex,"//\r\n");
  44. format(string,sizeof(string),"SetPlayerPos(playerid, %f, %f, %f);\r\n",pPos[0],pPos[1],pPos[2]);
  45. fwrite(filex,string);
  46. format(string,sizeof(string),"SetPlayerCameraPos(playerid, %f, %f, %f);\r\n",pPos[4],pPos[5],pPos[2]);
  47. fwrite(filex,string);
  48. format(string,sizeof(string),"SetPlayerCameraLookAt(playerid, %f, %f, %f);\r\n",pPos[0],pPos[1],pPos[2]);
  49. fwrite(filex,string);
  50. format(string,sizeof(string),"SetPlayerFacingAngle(playerid, %f);\r\n",pPos[3]);
  51. fwrite(filex,string);
  52. if(GetPlayerInterior(playerid) != 0)
  53. {
  54. format(string,sizeof(string),"SetPlayerInterior(playerid,%d);\r\n",GetPlayerInterior(playerid));
  55. fwrite(filex,string);
  56. }
  57. fclose(filex);
  58. SendClientMessage(playerid,0x0080C0AA," ");
  59. SendClientMessage(playerid,0x0080C0AA,"|| Sua seleção de classe foi salva em 'ClassPosions.txt' na pasta scriptfiles ||");
  60. SendClientMessage(playerid,0x0080C0AA," ");
  61. return 1;
  62. }
  63. return 0;
  64. }
  65.  
  66. GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  67. {
  68. new Float:a;
  69. GetPlayerPos(playerid, x, y, a);
  70. GetPlayerFacingAngle(playerid, a);
  71. if (GetPlayerVehicleID(playerid))
  72. {
  73. GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  74. }
  75. x += (distance * floatsin(-a, degrees));
  76. y += (distance * floatcos(-a, degrees));
  77. }
  78.  
  79. strtok(const string[], &index)
  80. {
  81. new length = strlen(string);
  82. while ((index < length) && (string[index] <= ' '))
  83. {
  84. index++;
  85. }
  86. new offset = index;
  87. new result[20];
  88. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  89. {
  90. result[index - offset] = string[index];
  91. index++;
  92. }
  93. result[index - offset] = EOS;
  94. return result;
  95. }
  96.  
  97.  
  98. //-----
  99. stock IsNumeric(const string[]) { // by DracoBlue
  100. new length=strlen(string);
  101. if (length==0) return false;
  102. for (new i = 0; i < length; i++) {
  103. if (
  104. (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
  105. || (string[i]=='-' && i!=0) // A '-' but not at first.
  106. || (string[i]=='+' && i!=0) // A '+' but not at first.
  107. ) return false;
  108. }
  109. if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  110. return true;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment