Advertisement
GabrielRibeiro

[G]Car[C]reator

Jul 2nd, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.03 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf>
  4. #include <DOF2>
  5.  
  6. new Float:X,
  7.     Float:Y,
  8.     Float:Z,
  9.     Text3D:TextoDoCarro[MAX_VEHICLES],
  10.     Float:Angl
  11. ;
  12. new TaProcurando[MAX_PLAYERS];
  13. enum Carrinho{
  14.     Criador,
  15.     Model,
  16.     Float:CarX,
  17.     Float:CarY,
  18.     Float:CarZ,
  19.     Float:Angle,
  20.     Car1,
  21.     Car2,
  22.     RT,
  23.  
  24. }
  25. new InfoGabriel[MAX_VEHICLES][Carrinho],
  26.     CrioCarro[MAX_VEHICLES],
  27.     Contando
  28. ;
  29.  
  30. new Str[100]; //to sem contador de Str :o  
  31.    
  32. public OnFilterScriptInit()
  33. {
  34.     CarregarCarros();
  35.     print("Programado por Gabriel Ribeiro");
  36.     print("-------------------------------------------------------------");
  37.     return 1;
  38. }
  39. public OnFilterScriptExit()
  40. {
  41.     DOF2_Exit();
  42.     return 1;
  43. }
  44. public OnPlayerConnect(playerid)
  45. {
  46.     TaProcurando[playerid] = 0;
  47.     return 1;
  48. }
  49. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  50. {
  51.      if(!success)
  52.      {
  53.             SendClientMessage(playerid, -1, "O Comando Não Existe!");
  54.             return 1;
  55.      }
  56.      return 1;
  57. }
  58. public OnPlayerEnterCheckpoint(playerid)
  59. {
  60.     if(TaProcurando[playerid] == 1)
  61.     {
  62.         TaProcurando[playerid] = 0;
  63.         DisablePlayerCheckpoint(playerid);
  64.         SendClientMessage(playerid, -1,"Voce achou seu carro!");
  65.     }
  66.     return 1;
  67. }
  68. CMD:criarcarro(playerid, params[])
  69. {
  70.     GetPlayerPos(playerid, X, Y, Z);
  71.     GetPlayerFacingAngle(playerid, Angl);
  72.     new carro, cor1, cor2, respawntime;
  73.     if(sscanf(params, "dddd", carro, cor1, cor2,respawntime))
  74.         return SendClientMessage(playerid, -1, "Use: /criarcarro [ID] [COR1] [COR2] [RESPAWN]");
  75.     if(carro < 400 || carro > 611)
  76.         return SendClientMessage(playerid, -1, "O Modelo do veiculo tem que ser entre 400 e 611");
  77.     if(cor1 < 0 || cor1 > 255)
  78.         return SendClientMessage(playerid, -1, "O numero da cor 1 tem que ser entre 0 e 255");
  79.     if(cor2 < 0 || cor2 > 255)
  80.         return SendClientMessage(playerid, -1, "O numero da cor 2 tem que ser entre 0 e 255");
  81.     Contando = 0;
  82.     CriarCarro(playerid, Contando, carro,X,Y,Z,Angl,cor1,cor2,respawntime);
  83.     SendClientMessage(playerid, -1,"Creditos: Gabriel Ribeiro.");
  84.     return 1;
  85. }
  86. CMD:deletar(playerid, params[])
  87. {
  88.     new carid;
  89.     if(sscanf(params,"d",carid))
  90.         return SendClientMessage(playerid, -1, "Use: /deletar [ID DO ARQUIVO]");
  91.     format(Str, 50, "FS/Carro %d.ini", carid);
  92.     if(fexist(Str))
  93.     {
  94.         DOF2_RemoveFile(Str);
  95.         DestroyVehicle(CrioCarro[carid]);
  96.         SendClientMessage(playerid, -1,"Voce removeu o arquivo");
  97.         return 1;
  98.     }
  99.     else
  100.     {
  101.         SendClientMessage(playerid, -1,"Arquivo nao existe!");
  102.     }
  103.        
  104.     return 1;
  105. }
  106. CMD:trazercarro(playerid, params[])
  107. {
  108.     new carid;
  109.     if(sscanf(params,"d",carid)) return SendClientMessage(playerid, -1,"Use: /trazercarro [ID ARQ]");
  110.     {
  111.         GetPlayerPos(playerid, X,Y,Z);
  112.         format(Str, 50, "FS/Carro %d.ini", carid);
  113.         if(fexist(Str))
  114.         {
  115.  
  116.             SetVehiclePos(CrioCarro[carid], X,Y,Z);
  117.         }
  118.         else
  119.         {
  120.                 SendClientMessage(playerid, -1,"Arquivo nao existe!");
  121.         }
  122.    
  123.     }
  124.    
  125.     return 1;
  126. }
  127. CMD:ircarro(playerid, params[])
  128. {
  129.     new carid;
  130.     if(sscanf(params,"d",carid)) return SendClientMessage(playerid, -1,"Use: /ircarro [ID ARQ]");
  131.     {
  132.         GetVehiclePos(CrioCarro[carid], X,Y,Z);
  133.         format(Str, 50, "FS/Carro %d.ini", carid);
  134.         if(fexist(Str))
  135.         {
  136.  
  137.             SetPlayerPos(playerid, X,Y,Z);
  138.         }
  139.         else
  140.         {
  141.             SendClientMessage(playerid, -1,"Arquivo nao existe!");
  142.         }
  143.    
  144.     }
  145.    
  146.     return 1;
  147. }
  148. CMD:acharcarro(playerid, params[])
  149. {
  150.     new carid;
  151.     if(sscanf(params,"d",carid)) return SendClientMessage(playerid, -1,"Use: /acharcarro [ID ARQ]");
  152.     {
  153.         GetVehiclePos(CrioCarro[carid], X,Y,Z);
  154.         format(Str, 50, "FS/Carro %d.ini", carid);
  155.         if(fexist(Str))
  156.         {
  157.  
  158.             DisablePlayerCheckpoint(playerid);
  159.             SetPlayerCheckpoint(playerid, X,Y,Z,8);
  160.             TaProcurando[playerid] = 1;
  161.         }
  162.         else
  163.         {
  164.             SendClientMessage(playerid, -1,"Arquivo nao existe!");
  165.         }
  166.    
  167.     }
  168.    
  169.     return 1;
  170. }
  171. CMD:ajudacarro(playerid, params[])
  172. {
  173.     SendClientMessage(playerid, -1,"CREDITOS A GABRIEL RIBEIRO.");
  174.     SendClientMessage(playerid, -1, "/criarcarro /salvarcarro /deletar /ircarro /trazercarro /acharcarro");
  175.     return 1;
  176. }
  177. CMD:salvarcarro(playerid, params[])
  178. {
  179.     new carid;
  180.     new Float: A;
  181.     if(sscanf(params,"d",carid)) return SendClientMessage(playerid, -1,"Use: /salvarcarro [ID DO ARQ]");
  182.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1,"Voce nao esta dirigindo o carro!");
  183.     format(Str, 50, "FS/Carro %d.ini", carid);
  184.     if(fexist(Str))
  185.     {
  186.         GetVehiclePos(CrioCarro[carid], X,Y,Z);
  187.         GetVehicleZAngle(CrioCarro[carid], A);
  188.         InfoGabriel[carid][CarX] = X;
  189.         InfoGabriel[carid][CarY] = Y;
  190.         InfoGabriel[carid][CarZ] = Z;
  191.         InfoGabriel[carid][Angle] = A;
  192.         DOF2_SetFloat(Str, "CarX", X);
  193.         DOF2_SetFloat(Str, "CarY", Y);
  194.         DOF2_SetFloat(Str, "CarZ", Z);
  195.         DOF2_SaveFile();
  196.         DestroyVehicle(CrioCarro[carid]);
  197.         CrioCarro[carid] = CreateVehicle(
  198.                                         DOF2_GetInt(Str, "Modelo"),
  199.                                         X,
  200.                                         Y,
  201.                                         Z,
  202.                                         A,
  203.                                         DOF2_GetInt(Str,"Cor1"),
  204.                                         DOF2_GetInt(Str,"Cor2"),
  205.                                         DOF2_GetInt(Str,"RT"));
  206.         PutPlayerInVehicle(playerid, CrioCarro[carid],0);
  207.         SendClientMessage(playerid, -1,"Carro Atualizado!");
  208.        
  209.     }
  210.     else
  211.     {
  212.         SendClientMessage(playerid, -1,"Arquivo nao existe!");
  213.     }
  214.     return 1;
  215. }
  216.  
  217. CriarCarro(playerid, CarID, Modelo, Float:CX, Float:CY, Float:CZ, Float:An, Cor1, Cor2,respawntime)
  218. {
  219.     new nome[MAX_PLAYER_NAME];
  220.     new Texto[216];
  221.     GetPlayerName(playerid, nome, sizeof(nome));
  222.     format(Str, 100, "FS/Carro %d.ini",CarID);
  223.     if(!fexist(Str))
  224.     {
  225.         DOF2_CreateFile(Str);
  226.         InfoGabriel[CarID][CarX] = CX;
  227.         InfoGabriel[CarID][CarY] = CY;
  228.         InfoGabriel[CarID][CarZ] = CZ;
  229.         InfoGabriel[CarID][Angle] = An;
  230.         InfoGabriel[CarID][RT] = respawntime;
  231.         format(InfoGabriel[CarID][Criador], 24, "%s", nome);
  232.         DOF2_SetString(Str,"Criador", nome);
  233.         DOF2_SetInt(Str,"Modelo",Modelo);
  234.         DOF2_SetFloat(Str, "CarX", CX);
  235.         DOF2_SetFloat(Str, "CarY", CY);
  236.         DOF2_SetFloat(Str, "CarZ", CZ);
  237.         DOF2_SetFloat(Str, "Angle", An);
  238.         DOF2_SetInt(Str,"Cor1", Cor1);
  239.         DOF2_SetInt(Str,"Cor2", Cor2)
  240.         DOF2_SetInt(Str,"RT", respawntime);
  241.         format(Texto,sizeof(Texto),"AddStaticVehicleEx(%d,%f,%f,%f,%f,%d,%d,%d);",Modelo, CX,CY,CZ,An,Cor1,Cor2,respawntime);
  242.         DOF2_SetString(Str,"AddGM",Texto);
  243.         DOF2_SaveFile();
  244.         CrioCarro[CarID] = CreateVehicle(Modelo, CX,CY,CZ,An,Cor1,Cor2,respawntime);
  245.         format(Str, 180,"CARRO CRIADO\nID: %d",CarID);
  246.         TextoDoCarro[CarID] = Create3DTextLabel(Str, 0xFFFFFFFF, 0.0, 0.0, 0.0, 10.0, 0, 1);
  247.         Attach3DTextLabelToVehicle(TextoDoCarro[CarID], CrioCarro[CarID], 0.0, -0.0, 0.5);
  248.         PutPlayerInVehicle(playerid, CrioCarro[CarID], 0);
  249.    
  250.     }
  251.     else{
  252.         Contando++;
  253.         CriarCarro(playerid, Contando, Modelo,X,Y,Z,An,Cor1,Cor2, respawntime);
  254.     }
  255.    
  256.     return 1;
  257. }
  258.  
  259.  
  260. CarregarCarros(){
  261.     new contagem = 0;
  262.     new Strt[100];
  263.     for(new i = 0; i < MAX_VEHICLES; i++)
  264.     {
  265.         format(Str, 30,"FS/Carro %d.ini", i);
  266.         if(fexist(Str))
  267.         {
  268.             format(Strt, 180,"CARRO CRIADO\nID: %d",i);
  269.             format(InfoGabriel[i][Criador], 24, "%s", DOF2_GetString(Str,"Criador"));
  270.             InfoGabriel[i][Model] = DOF2_GetInt(Str,"Modelo");
  271.             InfoGabriel[i][CarX] = DOF2_GetFloat(Str,"CarX");
  272.             InfoGabriel[i][CarY] = DOF2_GetFloat(Str,"CarY");
  273.             InfoGabriel[i][CarZ] = DOF2_GetFloat(Str,"Angle");
  274.             InfoGabriel[i][Angle] = DOF2_GetFloat(Str,"CarZ");
  275.             InfoGabriel[i][Car1] = DOF2_GetInt(Str,"Cor1");
  276.             InfoGabriel[i][Car2] = DOF2_GetInt(Str,"Cor2");
  277.             InfoGabriel[i][RT] = DOF2_GetInt(Str,"RT");
  278.  
  279.             contagem++;
  280.             CrioCarro[i] = CreateVehicle(
  281.                                         DOF2_GetInt(Str,"Modelo"),
  282.                                         DOF2_GetFloat(Str,"CarX"),
  283.                                         DOF2_GetFloat(Str,"CarY"),
  284.                                         DOF2_GetFloat(Str,"CarZ"),
  285.                                         DOF2_GetFloat(Str,"Angle"),
  286.                                         DOF2_GetInt(Str,"Cor1"),
  287.                                         DOF2_GetInt(Str,"Cor1"),
  288.                                         DOF2_GetInt(Str,"RT"));
  289.             printf("%d",i);
  290.             TextoDoCarro[i] = Create3DTextLabel(Strt, 0xFFFFFFFF, 0.0, 0.0, 0.0, 10.0, 0, 1);
  291.             Attach3DTextLabelToVehicle(TextoDoCarro[i], CrioCarro[i], 0.0, -0.0, 0.5);
  292.  
  293.         }
  294.        
  295.     }
  296.  
  297.     DOF2_SaveFile();
  298.     print("-------------------------------------------------------------");
  299.     printf("[FS GABRIEL] %d Carros carregados com sucesso!",contagem);
  300.  
  301. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement