Advertisement
Guest User

Pedro Felipe - Cinto de Segurança

a guest
Aug 4th, 2010
1,505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. /* FEITO - TRADUZIDO POR PEDRO_FELIPE - PEDRO_TILAMBUCU
  2. CREDITOS : LEO_FELIPE, A.K.A Jason , FALLOUTS (Sistema de Batidas)
  3. Agradecimentos: A todos que me ajudaram no forum da SAMP www.sa-mp.com/forum
  4. FS - SISTEMA DE CINTO DE SEGURANÇA E BATIDAS
  5. */
  6.  
  7. #include <a_samp>
  8. #include <a_players>
  9.  
  10. #define MAX_STRING 255
  11. #define COLOR_WHITE 0xFFFFFFAA
  12. #define COLOR_PURPLE 0xC2A2DAAA
  13. #define COLOR_LIGHTRED 0xFF6347AA
  14. #define COLOR_GRAD2 0xBFC0C2FF
  15. #define COLOR_GREY 0xAFAFAFAA
  16.  
  17. forward ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5);
  18. forward OnPlayerUpdate(playerid);
  19.  
  20. new cinto[MAX_PLAYERS];
  21. new gPlayerLogged[MAX_PLAYERS];
  22. new Float:CarHealth[MAX_PLAYERS];
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.  
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31. print(" Cinto de Seguranca "); // Não tirar
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36. gPlayerLogged[playerid] = 0;
  37. cinto[playerid] = 0;
  38. return 1;
  39. }
  40.  
  41. strtok(const string[], &index)
  42. {
  43. new length = strlen(string);
  44. while ((index < length) && (string[index] <= ' '))
  45. {
  46. index++;
  47. }
  48.  
  49. new offset = index;
  50. new result[20];
  51. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  52. {
  53. result[index - offset] = string[index];
  54. index++;
  55. }
  56. result[index - offset] = EOS;
  57. return result;
  58. }
  59.  
  60. public ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
  61. {
  62. if(IsPlayerConnected(playerid))
  63. {
  64. new Float:posx, Float:posy, Float:posz;
  65. new Float:oldposx, Float:oldposy, Float:oldposz;
  66. new Float:tempposx, Float:tempposy, Float:tempposz;
  67. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  68. //radi = 2.0; //Trigger Radius
  69. for(new i = 0; i < MAX_PLAYERS; i++)
  70. {
  71. if(IsPlayerConnected(i))
  72. {
  73.  
  74. GetPlayerPos(i, posx, posy, posz);
  75. tempposx = (oldposx -posx);
  76. tempposy = (oldposy -posy);
  77. tempposz = (oldposz -posz);
  78. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  79. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  80. {
  81. SendClientMessage(i, col1, str);
  82. }
  83. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  84. {
  85. SendClientMessage(i, col2, str);
  86. }
  87. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  88. {
  89. SendClientMessage(i, col3, str);
  90. }
  91. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  92. {
  93. SendClientMessage(i, col4, str);
  94. }
  95. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  96. {
  97. SendClientMessage(i, col5, str);
  98. }
  99. }
  100. }
  101. }//not connected
  102. return 1;
  103. }
  104.  
  105. public OnPlayerCommandText(playerid, cmdtext[])
  106. {
  107. new string[256];
  108. new sendername[MAX_PLAYER_NAME];
  109. new cmd[256];
  110. new idx;
  111. cmd = strtok(cmdtext, idx);
  112.  
  113. if(strcmp(cmd, "/cintoseg", true) == 0)
  114. {
  115. if(IsPlayerConnected(playerid))
  116. {
  117. GetPlayerName(playerid, sendername, sizeof(sendername));
  118. new length = strlen(cmdtext);
  119. while ((idx < length) && (cmdtext[idx] <= ' '))
  120. {
  121. idx++;
  122. }
  123. new offset = idx;
  124. new result[64];
  125. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  126. {
  127. result[idx - offset] = cmdtext[idx];
  128. idx++;
  129. }
  130. result[idx - offset] = EOS;
  131. if(!strlen(result) && IsPlayerInAnyVehicle(playerid) == 0)
  132. { //line 124
  133. SendClientMessage(playerid, COLOR_GRAD2, "Você não está em um veiculo");
  134. return 1;
  135. }
  136. if(IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 0)
  137. {
  138. cinto[playerid] = 1;
  139. SendClientMessage(playerid, COLOR_WHITE, "Você está com cinto , use (/cintoseg) para tirar o cinto.");
  140. format(string, sizeof(string), "* %s Colocou o cinto de seguranca.", sendername);
  141. }
  142. else if(IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 1)
  143. {
  144. cinto[playerid] = 0;
  145. SendClientMessage(playerid, COLOR_WHITE, "Você tirou seu cinto");
  146. format(string, sizeof(string), "* %s tirou o cinto de segurança.", sendername);
  147. TogglePlayerControllable(playerid, 1)
  148. }
  149. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  150. printf("%s", string);
  151. }
  152. return 1; }
  153. if (strcmp("/scintoseg", cmdtext, true, 10) == 0)
  154. {
  155. SendClientMessage(playerid,COLOR_GREY,"*** Para você colocar/tirar o cinto de segurança , Use /cintoseg. ***");
  156. SendClientMessage(playerid,COLOR_GREY,"*** Não pule do veiculo com cinto de segurança ou poderá MORRER ENFORCADO! ***");
  157. SendClientMessage(playerid,COLOR_GREY,"*** Evite andar sem cinto de segurança. Valorize a sua vida ! ***");
  158. }
  159. return 0;
  160. }
  161.  
  162. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  163. {
  164. SendClientMessage(playerid, COLOR_LIGHTRED, "Para a sua segurança , ultilize o cinto de seguranca (/cintoseg).");
  165. SendClientMessage(playerid, COLOR_LIGHTRED, "Não pule do veiculo com cinto de segurança , Poderá se enforcar !")
  166. return 1;
  167. }
  168.  
  169. public OnPlayerExitVehicle(playerid, vehicleid){
  170. if(cinto[playerid] == 1){
  171. SendClientMessage(playerid, COLOR_WHITE, "Você pulou do carro com cinto de segurança");
  172. GameTextForPlayer(playerid, " ~r~E se enforcou com o cinto!", 5000, 3)
  173. SetPlayerHealth(playerid,0);
  174. GivePlayerMoney(playerid,-1000);
  175. }
  176. return 1;
  177. }
  178.  
  179. // if (IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 1)
  180. // cinto[playerid] = 0;
  181.  
  182. public OnPlayerUpdate(playerid)
  183. {
  184. if(IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 0)
  185. {
  186. new Float:TempCarHealth;
  187. GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
  188. new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
  189. if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
  190. {
  191. Difference = floatdiv(Difference, 10.0);
  192. new Float:OldHealth;
  193. GetPlayerHealth(playerid, OldHealth);
  194. SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
  195. }
  196. CarHealth[playerid] = TempCarHealth;
  197. }
  198. else
  199. {
  200. CarHealth[playerid] = 0.0;
  201. }
  202. return 1;
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement