Guest User

[FS] Sistema de aluguel de veiculo by DJLoko

a guest
May 28th, 2010
1,198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.07 KB | None | 0 0
  1. #include <a_samp>
  2. #include <float>
  3.  
  4. #define COR_CINZA 0xBFC0C2FF
  5. #define tabsize 0
  6.  
  7.  
  8. new AlugarCarro[MAX_PLAYERS];
  9. forward CarroDestrancado(carid);
  10. forward Respawndocarro(playerid);
  11. forward Carrosparaalugar(carid);
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print("\n--------------------------------------");
  16.     print(" Sistema de aluguel de carros by DJLoko ");
  17.     print("------------<[Carregado]>-------------\n");
  18.     AddStaticVehicleEx(562,2160.0573730469,1799.5623779297,10.8203125,0,-1,-1,30000);// Veiculoalguel 1
  19.     AddStaticVehicleEx(562,2168.0100097656,1799.7695312500,10.8203125,0,-1,-1,30000);// Veiculoalguel 2
  20.     AddStaticVehicleEx(562,2175.5317382813,1799.8051757813,10.8203125,0,-1,-1,30000);// Veiculoalguel 3
  21.     AddStaticVehicleEx(562,2183.4045410156,1799.8276367188,10.8203125,0,-1,-1,30000);// Veiculoalguel 4
  22.     AddStaticVehicleEx(562,2191.1486816406,1799.7927246094,10.8203125,0,-1,-1,30000);// Veiculoalguel 5
  23.     AddStaticVehicleEx(562,2198.4870605469,1799.7885742188,10.8203125,0,-1,-1,30000);// Veiculoalguel 6
  24.     AddStaticVehicleEx(562,2198.6010742188,1810.0036621094,10.8203125,0,-1,-1,30000);// Veiculoalguel 7
  25.     AddStaticVehicleEx(562,2191.0888671875,1810.1614990234,10.8203125,0,-1,-1,30000);// Veiculoalguel 8
  26.     AddStaticVehicleEx(562,2183.3344726563,1810.1407470703,10.8203125,0,-1,-1,30000);// Veiculoalguel 9
  27.     AddStaticVehicleEx(562,2175.3098144531,1810.1428222656,10.8203125,0,-1,-1,30000);// Veiculoalguel 10
  28.     AddStaticVehicleEx(562,2167.7849121094,1810.1483154297,10.8203125,0,-1,-1,30000);// Veiculoalguel 11
  29.     AddStaticVehicleEx(562,2160.4975585938,1810.2126464844,10.8203125,0,-1,-1,30000);// Veiculoalguel 12
  30.     return 1;
  31. }
  32.  
  33. public OnPlayerCommandText(playerid, cmdtext[])
  34. {
  35.     new CarroTrancado[265];
  36.     if(strcmp("/alugarveiculo", cmdtext, true, 10) == 0)
  37.     {
  38.         if(IsPlayerConnected(playerid))
  39.         {
  40.             new carid = GetPlayerVehicleID(playerid);
  41.             if(Carrosparaalugar(carid))
  42.             {
  43.                 if (GetPlayerMoney(playerid) <  1000)
  44.                 {
  45.                     SendClientMessage(playerid, COR_CINZA, "Você não tem dinheiro soficiente!");
  46.                     return 1;
  47.                 }
  48.                 AlugarCarro[playerid] = GetPlayerVehicleID(playerid);
  49.                 GivePlayerMoney(playerid,-1000);
  50.                 PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  51.                 TogglePlayerControllable(playerid, 1);
  52.                 GameTextForPlayer(playerid, "~w~Nao se esqueca ~b~/deslugarveiculo~n~ ~w~para desalugar seu veiculo", 5000, 3);
  53.             }
  54.         }
  55.         return 1;
  56.     }
  57.     if(strcmp("/sair", cmdtext, true, 10) == 0)
  58.     {
  59.         TogglePlayerControllable(playerid, 1);
  60.         RemovePlayerFromVehicle(playerid);
  61.         return 1;
  62.     }
  63.     if(strcmp("/desalugarveiculo", cmdtext, true, 10) == 0)
  64.     {
  65.         if(IsPlayerConnected(playerid))
  66.         {
  67.             if(AlugarCarro[playerid] != 299)
  68.             {
  69.                 SetTimer("Respawndocarro", 2000, 0);
  70.                 RemovePlayerFromVehicle(playerid);
  71.                 TogglePlayerControllable(playerid, 1);
  72.                 CarroTrancado[AlugarCarro[playerid]] = 0;
  73.                 CarroDestrancado(AlugarCarro[playerid]);
  74.                 AlugarCarro[playerid] = 299;
  75.                 GameTextForPlayer(playerid, "~w~Voce agora nao tem nenhum veiculo alugado", 5000, 3);
  76.             }
  77.         }
  78.         return 1;
  79.     }
  80.     return 0;
  81. }
  82.  
  83. public OnPlayerStateChange(playerid, newstate, oldstate)
  84. {
  85.     new ultimocarro[301];
  86.     new novocarro = GetPlayerVehicleID(playerid);
  87.     new carid = GetPlayerVehicleID(playerid);
  88.     if(Carrosparaalugar(carid))
  89.     {
  90.         if (AlugarCarro[playerid] != novocarro)
  91.         {
  92.             TogglePlayerControllable(playerid, 0);
  93.             GameTextForPlayer(playerid,"~w~Voce pode alugar essa veiculo~n~Cost:~g~$1000~n~~w~Para alugar digite ~g~/alugarveiculo~w~~n~para sair use ~r~/sair", 5000, 3);
  94.         }
  95.         ultimocarro[playerid] = novocarro;
  96.     }
  97.     return 1;
  98. }
  99.  
  100. public CarroDestrancado(carid)
  101. {
  102.     for(new i = 0; i < MAX_PLAYERS; i++)
  103.     {
  104.         if(IsPlayerConnected(i))
  105.         {
  106.             SetVehicleParamsForPlayer(carid,i,0,0);
  107.         }
  108.     }
  109. }
  110.  
  111. public Respawndocarro(playerid)
  112. {
  113.     new i = playerid;
  114.     SetVehicleToRespawn(AlugarCarro[i]);
  115.     TogglePlayerControllable(i, 1);
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerExitVehicle(playerid, vehicleid)
  120. {
  121.     new i = playerid;
  122.     TogglePlayerControllable(i, 1);
  123.     return 1;
  124. }
  125.  
  126. public Carrosparaalugar(carid)
  127. {
  128.     if(carid == 1 || carid == 12)
  129.     {
  130.         return 1;
  131.     }
  132.     return 0;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment