Advertisement
Guest User

Felipe

a guest
Oct 17th, 2008
1,287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.56 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new speedo[MAX_PLAYERS];
  4. new shift[MAX_PLAYERS];
  5. new Float:VehHealth;
  6. new perdervida[MAX_PLAYERS];
  7. new Float:ppos[MAX_PLAYERS][3];
  8. forward Destravar(playerid);
  9.  
  10.  
  11.  
  12. forward UpdateSpeed();
  13. forward MarchaUp();
  14. forward MatarTempo();
  15. forward TirarVida(playerid,vehicleid);
  16. forward PassarMarcha(playerid);
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.     print("\n--------------------------------------");
  21.     print(" Gears");
  22.     print("--------------------------------------\n");
  23.     SetTimer("UpdateSpeed", 500, 1);
  24.     SetTimer("MarchaUp",500, 1);
  25.     SetTimer("TirarVida",1000,1);
  26.     SetTimer("MatarTempo",1000,1);
  27.     return 1;
  28. }
  29.  
  30. public OnFilterScriptExit()
  31. {
  32.     return 1;
  33. }
  34.  
  35.  
  36. public UpdateSpeed(){
  37.     for(new i=0;i<MAX_PLAYERS;i++){
  38.         if(IsPlayerConnected(i)){
  39.             new string[256];
  40.             new Float:x,Float:y,Float:z;
  41.             GetPlayerPos(i,x,y,z);
  42.             new
  43.             Float:xOff = ppos[i][0] - x,
  44.             Float:yOff = ppos[i][1] - y,
  45.             Float:zOff = ppos[i][2] - z,
  46.             Float:dis = floatsqroot((xOff * xOff) + (yOff * yOff) + (zOff * zOff));
  47.             format(string, sizeof string, "~n~~n~~n~~n~~n~~n~~w~%d ~h~km/h Shift:%d", speedo[i], shift[i]);
  48.             if(IsPlayerInAnyVehicle(i)){
  49.                     speedo[i] = floatround(((dis/1000.0)*60.0)*60.0);
  50.             }
  51.             ppos[i][0] = x;
  52.             ppos[i][1] = y;
  53.             ppos[i][2] = z;
  54.         }
  55.     }
  56. }
  57.  
  58. public MarchaUp()
  59. {
  60.     for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i) && GetPlayerState(i) == 2)
  61.     {
  62.             if(speedo[i] >= 0 && speedo[i] <= 80){
  63.             if(speedo[i] >= 0 && speedo[i] <= 8){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~�~w~��������", 1000, 3); }
  64.             if(speedo[i] >= 8 && speedo[i] <= 17){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~��~w~�������", 1000, 3); }
  65.             if(speedo[i] >= 17 && speedo[i] <= 25){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~w~������", 1000, 3); }
  66.             if(speedo[i] >= 25 && speedo[i] <= 32){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~�~w~�����", 1000, 3); }
  67.             if(speedo[i] >= 32 && speedo[i] <= 40){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~��~w~����", 1000, 3); }
  68.             if(speedo[i] >= 40 && speedo[i] <= 50){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~w~���", 1000, 3); }
  69.             if(speedo[i] >= 50 && speedo[i] <= 60){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~�~w~��", 1000, 3); }
  70.             if(speedo[i] >= 60 && speedo[i] <= 70){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~��~w~�", 1000, 3); }
  71.             if(speedo[i] >= 70 && speedo[i] <= 80){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~���", 1000, 3); }
  72.             return 1;
  73.             }else if(speedo[i] >= 80 && speedo[i] <= 120){
  74.             if(speedo[i] >= 80 && speedo[i] <= 84){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~�~w~��������", 1000, 3); }
  75.             if(speedo[i] >= 84 && speedo[i] <= 89){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~��~w~�������", 1000, 3); }
  76.             if(speedo[i] >= 89 && speedo[i] <= 93){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~w~������", 1000, 3); }
  77.             if(speedo[i] >= 93 && speedo[i] <= 98){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~�~w~�����", 1000, 3); }
  78.             if(speedo[i] >= 98 && speedo[i] <= 102){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~��~w~����", 1000, 3); }
  79.             if(speedo[i] >= 102 && speedo[i] <= 107){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~w~���", 1000, 3); }
  80.             if(speedo[i] >= 107 && speedo[i] <= 111){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~�~w~��", 1000, 3); }
  81.             if(speedo[i] >= 111 && speedo[i] <= 116){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~��~w~�", 1000, 3); }
  82.             if(speedo[i] >= 116 && speedo[i] <= 120){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~���", 1000, 3); }
  83.             return 1;
  84.             }else if(speedo[i] >= 120 && speedo[i] <= 160){
  85.             if(speedo[i] >= 120 && speedo[i] <= 124){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~�~w~��������", 1000, 3); }
  86.             if(speedo[i] >= 124 && speedo[i] <= 129){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~��~w~�������", 1000, 3); }
  87.             if(speedo[i] >= 129 && speedo[i] <= 133){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~w~������", 1000, 3); }
  88.             if(speedo[i] >= 133 && speedo[i] <= 138){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~�~w~�����", 1000, 3); }
  89.             if(speedo[i] >= 138 && speedo[i] <= 142){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~��~w~����", 1000, 3); }
  90.             if(speedo[i] >= 142 && speedo[i] <= 147){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~w~���", 1000, 3); }
  91.             if(speedo[i] >= 147 && speedo[i] <= 151){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~�~w~��", 1000, 3); }
  92.             if(speedo[i] >= 151 && speedo[i] <= 156){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~��~w~�", 1000, 3); }
  93.             if(speedo[i] >= 156 && speedo[i] <= 160){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~���", 1000, 3); }
  94.             return 1;
  95.             }else if(speedo[i] >= 160 && speedo[i] <= 200){
  96.             if(speedo[i] >= 160 && speedo[i] <= 164){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~�~w~��������", 1000, 3); }
  97.             if(speedo[i] >= 164 && speedo[i] <= 169){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~��~w~�������", 1000, 3); }
  98.             if(speedo[i] >= 169 && speedo[i] <= 173){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~w~������", 1000, 3); }
  99.             if(speedo[i] >= 173 && speedo[i] <= 178){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~�~w~�����", 1000, 3); }
  100.             if(speedo[i] >= 178 && speedo[i] <= 182){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~��~w~����", 1000, 3); }
  101.             if(speedo[i] >= 182 && speedo[i] <= 187){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~w~���", 1000, 3); }
  102.             if(speedo[i] >= 187 && speedo[i] <= 191){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~�~w~��", 1000, 3); }
  103.             if(speedo[i] >= 191 && speedo[i] <= 196){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~��~w~�", 1000, 3); }
  104.             if(speedo[i] >= 196 && speedo[i] <= 200){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~���", 1000, 3); }
  105.             return 1;
  106.             }else if(speedo[i] >= 200 && speedo[i] <= 600){
  107.             if(speedo[i] >= 200 && speedo[i] <= 244){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~�~w~��������", 1000, 3); }
  108.             if(speedo[i] >= 244 && speedo[i] <= 289){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~��~w~�������", 1000, 3); }
  109.             if(speedo[i] >= 289 && speedo[i] <= 333){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~w~������", 1000, 3); }
  110.             if(speedo[i] >= 333 && speedo[i] <= 378){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~�~w~�����", 1000, 3); }
  111.             if(speedo[i] >= 378 && speedo[i] <= 422){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~��~w~����", 1000, 3); }
  112.             if(speedo[i] >= 422 && speedo[i] <= 467){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~w~���", 1000, 3); }
  113.             if(speedo[i] >= 467 && speedo[i] <= 512){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~�~w~��", 1000, 3); }
  114.             if(speedo[i] >= 512 && speedo[i] <= 557){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~��~w~�", 1000, 3); }
  115.             if(speedo[i] >= 557 && speedo[i] <= 600){GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~~g~���~y~���~r~���", 1000, 3); }
  116.             return 1;
  117.             }else if(speedo[i] >= 0 && speedo[i] <= 80 && shift[i] != 1){
  118.             GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT UP", 1000, 3);
  119.             perdervida[i] = 1;
  120.             return 1;
  121.             }else if(speedo[i] >= 80 && speedo[i] <= 120 && shift[i] != 2){
  122.             if(shift[i] == 1) GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT UP", 1000, 3);
  123.             GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT DOWN", 1000, 3);
  124.             perdervida[i] = 1;
  125.             return 1;
  126.             }else if(speedo[i] >= 120 && speedo[i] <= 160 && shift[i] != 3){
  127.             if(shift[i] <= 2) GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT UP", 1000, 3);
  128.             GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT DOWN", 1000, 3);
  129.             perdervida[i] = 1;
  130.             return 1;
  131.             }else if(speedo[i] >= 160 && speedo[i] <= 200 && shift[i] != 4){
  132.             if(shift[i] <= 3) GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT UP", 1000, 3);
  133.             GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT DOWN", 1000, 3);
  134.             perdervida[i] = 1;
  135.             return 1;
  136.             }else if(speedo[i] >= 80 && speedo[i] <= 120 && shift[i] != 5){
  137.             GameTextForPlayer(i, "~n~~n~~n~~n~~n~~b~SHIFT UP", 1000, 3);
  138.             perdervida[i] = 1;
  139.             return 1;
  140.             }
  141.             return 1;
  142.         }
  143.     return 1;
  144.     }
  145.  
  146. public TirarVida(playerid,vehicleid)
  147. {
  148. if(perdervida[playerid] == 1){
  149. GetVehicleHealth(vehicleid, VehHealth);
  150. SetVehicleHealth(vehicleid, VehHealth -5);
  151. return 1;
  152. }
  153. return 1;
  154. }
  155.  
  156. public MatarTempo()
  157. {
  158. for(new i=0; i<MAX_PLAYERS; i++) perdervida[i] = 0;
  159. return 1;
  160. }
  161.  
  162. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  163. {
  164. if(newkeys & KEY_UP)
  165. {
  166. if(shift[playerid] == 5){
  167. SendClientMessage(playerid,0x21DD00FF,"No more shifts, so your car broke");
  168. new vehicleid = GetPlayerVehicleID(playerid);
  169. TirarVida(playerid,vehicleid);
  170. shift[playerid] = 5;
  171. return 1;
  172. }else{
  173. shift[playerid]++;
  174. PassarMarcha(playerid);
  175. return 1;
  176. }
  177. }else if(newkeys& KEY_DOWN)
  178. {
  179. if(shift[playerid] == 1){
  180. SendClientMessage(playerid,0x21DD00FF,"You dont have more shifts, so boom");
  181. new vehicleid = GetPlayerVehicleID(playerid);
  182. TirarVida(playerid,vehicleid);
  183. shift[playerid] = 1;
  184. return 1;
  185. }else{
  186. shift[playerid]--;
  187. PassarMarcha(playerid);
  188. return 1;
  189. }
  190. }
  191. return 1;
  192. }
  193.  
  194.  
  195. public OnPlayerEnterVehicle(playerid,vehicleid)
  196. {
  197. shift[playerid] = 1;
  198. return 1;
  199. }
  200.  
  201. public PassarMarcha(playerid)
  202. {
  203. TogglePlayerControllable(playerid, 0);
  204. SetTimerEx("Destravar", 500, false, "d", playerid);
  205. return 1;
  206. }
  207.  
  208. public Destravar(playerid)
  209. {
  210. TogglePlayerControllable(playerid, 1);
  211. return 1;
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement