Advertisement
Chip7

[FS] Garagem System (Com Garagem)

May 11th, 2012
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 25.53 KB | None | 0 0
  1. /*VISITE NOSSO SITE: http://www.sampknd.com/
  2.   SAMP KND MELHOR BLOG DE SAMP DO BRASIL
  3. */
  4.  
  5. #include <a_samp>
  6. #include <DOF2>
  7.  
  8. #define MAX_GARAGENS 200 // MAXIMO DE GARAGENS
  9. #define MAX_CARS 1 // MAXIMO DE CARRO POR GARAGEM +1
  10. #define COORDENADASGARAGEM -1232.7811279297,-74.612930297852,14.502492904663 // X,Y,Z DA GARAGEM (NÃO COLOCAR ESPAÇOS ENTRE AS COORDENADAS)
  11. #define COR_ERRO 0xAD0000AA
  12. #define COR_SUCESSO 0x00AB00AA
  13.  
  14. forward CarregarGaragens();
  15. forward SalvarGaragens();
  16. forward CriarGaragem(playerdono[64], garageid, Float:gx, Float:gy, Float:gz, coment[128], bool:lock);
  17. forward DeletarGaragem(garageid);
  18. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  19. forward GarageToPoint(Float:radi, garageid, Float:x, Float:y, Float:z);
  20. forward FecharGaragem(playerid, garageid);
  21. forward AbrirGaragem(playerid, garageid);
  22. forward SetGaragemComent(garageid, coment[128]);
  23. forward SetGaragemDono(garageid, playerdono[64]);
  24. forward SetGaragemPos(garageid, Float:gx, Float:gy, Float:gz);
  25. forward Creditos();
  26.  
  27. enum pGaragem
  28. {
  29.     Float:cnX,
  30.     Float:cnY,
  31.     Float:cnZ,
  32.     cnLock,
  33.     cnCar,
  34. }
  35.  
  36. new Garagem[MAX_GARAGENS][pGaragem];
  37. new Text3D:LabelEntrada[MAX_GARAGENS];
  38. new Text3D:LabelSaida[MAX_GARAGENS];
  39. new LabelString[MAX_GARAGENS][128];
  40. new NameString[MAX_GARAGENS][64];
  41. new GaragemAtual;
  42. new EditandoGaragem[MAX_PLAYERS];
  43. new bool:Deletado[MAX_GARAGENS];
  44.  
  45. public OnFilterScriptInit()
  46. {
  47.     print("\n--------------------------------------");
  48.     print("         FS by CidadeNovaRP ¬¬");
  49.     print("Não retire os Créditos ou lhe dará uma Caimbra no cú!");
  50.     print("--------------------------------------\n");
  51.     CarregarGaragens();
  52.     SetTimer("Creditos", 1000*1*60*15, true);
  53.     CreateObject(14776,-1222.58178711,-73.19232178,20.01030540,0.00000000,0.00000000,315.19982910);
  54.     CreateObject(2893,-1226.20849609,-78.41390991,14.47902775,4.00000000,0.00000000,314.72668457);
  55.     CreateObject(2893,-1224.88500977,-79.58795166,14.47902775,4.00000000,0.00000000,315.72119141);
  56.     CreateObject(2893,-1220.97375488,-75.61949158,14.47902679,344.00000000,0.00000000,315.64929199);
  57.     CreateObject(2893,-1222.22424316,-74.27712250,14.47902679,344.00000000,0.00000000,315.22387695);
  58.     CreateObject(1558,-1222.23022461,-74.30402374,14.07644463,0.00000000,0.00000000,315.19995117);
  59.     CreateObject(1558,-1220.96813965,-75.57649994,14.07644463,0.00000000,0.00000000,134.84912109);
  60.     CreateObject(2860,-1220.97290039,-75.57939911,14.53230476,0.00000000,0.00000000,245.51635742);
  61.     return 1;
  62. }
  63.  
  64. public OnFilterScriptExit()
  65. {
  66.     DOF2_Exit();
  67.     return 1;
  68. }
  69.  
  70. stock GetLockGaragem(garageid)
  71. {
  72.     new lock[64];
  73.     if(Garagem[garageid][cnLock] == 0)
  74.     {
  75.         lock = "{00F600}Aberto";
  76.     }
  77.     else if(Garagem[garageid][cnLock] == 1)
  78.     {
  79.         lock = "{F60000}Fechado";
  80.     }
  81.     else if(Garagem[garageid][cnLock] == 2)
  82.     {
  83.         lock = "{F6F600}Abrindo";
  84.     }
  85.     else if(Garagem[garageid][cnLock] == 3)
  86.     {
  87.         lock = "{F6F600}Fechando";
  88.     }
  89.     return lock;
  90. }
  91.  
  92. public CarregarGaragens()
  93. {
  94.     new string[256];
  95.     new arquivo[64];
  96.     new arquivoatual[64];
  97.     for(new g=0; g<MAX_GARAGENS; g++)
  98.     {
  99.         format(arquivoatual, sizeof(arquivoatual), "GaragemAtual.inc", g);
  100.         format(arquivo, sizeof(arquivo), "Garagem%d.inc", g);
  101.         if(DOF2_FileExists(arquivo))
  102.         {
  103.             if(Deletado[g] == false)
  104.             {
  105.                 new word = g + 10;
  106.                 Garagem[g][cnX] = DOF2_GetFloat(arquivo, "X");
  107.                 Garagem[g][cnY] = DOF2_GetFloat(arquivo, "Y");
  108.                 Garagem[g][cnZ] = DOF2_GetFloat(arquivo, "Z");
  109.                 Garagem[g][cnLock] = DOF2_GetInt(arquivo, "Lock");
  110.                 format(NameString[g], 64, "%s", DOF2_GetString(arquivo, "Dono", NameString[g]));
  111.                 LabelString[g] = DOF2_GetString(arquivo, "Comentario", LabelString[g]);
  112.                 GaragemAtual = DOF2_GetInt(arquivoatual, "GGID");
  113.                 format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  114.                 LabelEntrada[g] = Create3DTextLabel(string, 0xFFFFFFFF, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ], 30.0, 0, 1 );
  115.                 format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  116.                 LabelSaida[g] = Create3DTextLabel(string, 0xFFFFFFFF, COORDENADASGARAGEM, 30.0, word, 1 );
  117.                 printf("Garagem Carregada: %d %d %d \nComentario: %s\nDono: %s", Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ], LabelString[g], NameString[g]);
  118.             }
  119.         }
  120.     }
  121.     return 1;
  122. }
  123.  
  124. public SalvarGaragens()
  125. {
  126.     new arquivo[64];
  127.     new arquivoatual[64];
  128.     for(new g=0; g<MAX_GARAGENS; g++)
  129.     {
  130.         format(arquivoatual, sizeof(arquivoatual), "GaragemAtual.inc", g);
  131.         format(arquivo, sizeof(arquivo), "Garagem%d.inc", g);
  132.         if(DOF2_FileExists(arquivo))
  133.         {
  134.             if(Deletado[g] == false)
  135.             {
  136.                 DOF2_CreateFile(arquivo);
  137.                 DOF2_SetFloat(arquivo, "X", Garagem[g][cnX]);
  138.                 DOF2_SetFloat(arquivo, "Y", Garagem[g][cnY]);
  139.                 DOF2_SetFloat(arquivo, "Z", Garagem[g][cnZ]);
  140.                 DOF2_SetInt(arquivo, "Lock", Garagem[g][cnLock]);
  141.                 DOF2_SetString(arquivo, "Comentario", LabelString[g]);
  142.                 DOF2_SetString(arquivo, "Dono", NameString[g]);
  143.                 if(!DOF2_FileExists(arquivoatual))
  144.                 {
  145.                     if(GaragemAtual <= MAX_GARAGENS)
  146.                     {
  147.                         DOF2_CreateFile(arquivoatual);
  148.                         DOF2_SetInt(arquivoatual, "GGID", GaragemAtual);
  149.                     }
  150.                     else
  151.                     {
  152.                         printf("Máximo de Garagens Atingido, aumente o MAX_GARAGENS ou Delete Garagens e renove o arquivo 'GaragemAtual'!");
  153.                     }
  154.                 }
  155.                 else
  156.                 {
  157.                     if(GaragemAtual <= MAX_GARAGENS)
  158.                     {
  159.                         DOF2_SetInt(arquivoatual, "GGID", GaragemAtual);
  160.                     }
  161.                     else
  162.                     {
  163.                         printf("Máximo de Garagens Atingido, aumente o MAX_GARAGENS ou Delete Garagens e renove o arquivo 'GaragemAtual'!");
  164.                     }
  165.                 }
  166.             }
  167.             DOF2_SaveFile();
  168.         }
  169.     }
  170.     return 1;
  171. }
  172.  
  173. public CriarGaragem(playerdono[64], garageid, Float:gx, Float:gy, Float:gz, coment[128], bool:lock)
  174. {
  175.     new string[256];
  176.     new arquivo[64];
  177.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  178.     if(!DOF2_FileExists(arquivo))
  179.     {
  180.         if(!GarageToPoint(7.0, garageid, gx, gy, gz))
  181.         {
  182.             if(GaragemAtual <= MAX_GARAGENS)
  183.             {
  184.                 DOF2_CreateFile(arquivo);
  185.                 new word = garageid + 10;
  186.                 Garagem[garageid][cnX] = gx;
  187.                 Garagem[garageid][cnY] = gy;
  188.                 Garagem[garageid][cnZ] = gz;
  189.                 Garagem[garageid][cnLock] = lock;
  190.                 NameString[garageid] = playerdono;
  191.                 LabelString[garageid] = coment;
  192.                 GaragemAtual ++;
  193.                 format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  194.                 LabelEntrada[garageid] = Create3DTextLabel(string, 0xFFFFFFFF, gx, gy, gz, 30.0, 0, 1 );
  195.                 format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  196.                 LabelSaida[garageid] = Create3DTextLabel(string, 0xFFFFFFFF, COORDENADASGARAGEM, 30.0, word, 1 );
  197.                 printf("Garagem Criada: %d %d %d \nComentario: %s\nDono: %s", Garagem[garageid][cnX], Garagem[garageid][cnY], Garagem[garageid][cnZ], LabelString[garageid], NameString[garageid]);
  198.                 SalvarGaragens();
  199.             }
  200.             else
  201.             {
  202.                 printf("Máximo de Garagens Atingido, aumente o MAX_GARAGENS ou Delete Garagens e renove o arquivo 'GaragemAtual'!");
  203.             }
  204.         }
  205.         else
  206.         {
  207.             printf("Já existe uma Garagem neste Raio.");
  208.         }
  209.     }
  210.     else
  211.     {
  212.         printf("Já existe este GarageID.");
  213.     }
  214.     return 1;
  215. }
  216.  
  217. public DeletarGaragem(garageid)
  218. {
  219.     new arquivo[64];
  220.     new string[128];
  221.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  222.     if(!DOF2_FileExists(arquivo))
  223.     {
  224.         printf("Não existe este GarageID.");
  225.         return 1;
  226.     }
  227.     else
  228.     {
  229.         for(new i = 0; i < MAX_PLAYERS; i++)
  230.         {
  231.             for(new v = 0; v < MAX_VEHICLES; v++)
  232.             {
  233.                 if(garageid == GetVehicleVirtualWorld(v)-10)
  234.                 {
  235.                     if(!IsPlayerInVehicle(i, v))
  236.                     {
  237.                         SetVehicleVirtualWorld(v, 0);
  238.                         SetVehicleToRespawn(v);
  239.                     }
  240.                 }
  241.             }
  242.             if(garageid == GetPlayerVirtualWorld(i)-10)
  243.             {
  244.                 if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
  245.                 {
  246.                     SetPlayerPos(i, Garagem[garageid][cnX], Garagem[garageid][cnY], Garagem[garageid][cnZ]);
  247.                     SetPlayerVirtualWorld(i, 0);
  248.                     SetPlayerInterior(i, 0);
  249.                     format(string, sizeof(string), "A Garagem %d{00AB00} foi deletada.", garageid);
  250.                     SendClientMessage(i, COR_SUCESSO, string);
  251.                 }
  252.                 else
  253.                 {
  254.                     new tmpcar = GetPlayerVehicleID(i);
  255.                     SetVehiclePos(tmpcar, Garagem[garageid][cnX], Garagem[garageid][cnY], Garagem[garageid][cnZ]);
  256.                     SetVehicleVirtualWorld(tmpcar, 0);
  257.                     SetPlayerVirtualWorld(i, 0);
  258.                     SetPlayerInterior(i, 0);
  259.                     format(string, sizeof(string), "A Garagem %d{00AB00} foi deletada.", garageid);
  260.                     SendClientMessage(i, COR_SUCESSO, string);
  261.                 }
  262.             }
  263.         }
  264.         DOF2_RemoveFile(arquivo);
  265.         Deletado[garageid] = true;
  266.         Delete3DTextLabel(LabelSaida[garageid]);
  267.         Delete3DTextLabel(LabelEntrada[garageid]);
  268.         printf("Garagem %d foi deletada", garageid);
  269.         SalvarGaragens();
  270.     }
  271.     return 1;
  272. }
  273.  
  274. public SetGaragemComent(garageid, coment[128])
  275. {
  276.     new arquivo[64];
  277.     new string[128];
  278.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  279.     if(!DOF2_FileExists(arquivo))
  280.     {
  281.         printf("Não existe este GarageID.");
  282.         return 1;
  283.     }
  284.     else
  285.     {
  286.         if(Deletado[garageid] == false)
  287.         {
  288.             printf("O Comentario da Garagem %d foi alterado", garageid);
  289.             LabelString[garageid] = coment;
  290.             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", garageid, coment, GetLockGaragem(garageid), NameString[garageid]);
  291.             Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  292.             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", garageid, coment, GetLockGaragem(garageid), NameString[garageid]);
  293.             Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  294.             SalvarGaragens();
  295.         }
  296.     }
  297.     return 1;
  298. }
  299.  
  300. public SetGaragemDono(garageid, playerdono[64])
  301. {
  302.     new arquivo[64];
  303.     new string[128];
  304.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  305.     if(!DOF2_FileExists(arquivo))
  306.     {
  307.         printf("Não existe este GarageID.");
  308.         return 1;
  309.     }
  310.     else
  311.     {
  312.         if(Deletado[garageid] == false)
  313.         {
  314.             printf("O Dono da Garagem %d foi alterado", garageid);
  315.             NameString[garageid] = playerdono;
  316.             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), playerdono);
  317.             Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  318.             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), playerdono);
  319.             Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  320.             SalvarGaragens();
  321.         }
  322.     }
  323.     return 1;
  324. }
  325.  
  326. public SetGaragemPos(garageid, Float:gx, Float:gy, Float:gz)
  327. {
  328.     new arquivo[64];
  329.     new string[128];
  330.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  331.     if(!DOF2_FileExists(arquivo))
  332.     {
  333.         printf("Não existe este GarageID.");
  334.         return 1;
  335.     }
  336.     else
  337.     {
  338.         if(Deletado[garageid] == false)
  339.         {
  340.             printf("A Pos da Garagem %d foi alterada", garageid);
  341.             Garagem[garageid][cnX] = gx;
  342.             Garagem[garageid][cnY] = gy;
  343.             Garagem[garageid][cnZ] = gz;
  344.             Delete3DTextLabel(LabelEntrada[garageid]);
  345.             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  346.             LabelEntrada[garageid] = Create3DTextLabel(string, 0xFFFFFFFF, gx, gy, gz, 30.0, 0, 1 );
  347.             SalvarGaragens();
  348.         }
  349.     }
  350.     return 1;
  351. }
  352.  
  353. public GarageToPoint(Float:radi, garageid, Float:x, Float:y, Float:z)
  354. {
  355.     for(new g=0; g<MAX_GARAGENS; g++)
  356.     {
  357.         if(Deletado[g] == false)
  358.         {
  359.             new Float:oldposx, Float:oldposy, Float:oldposz;
  360.             new Float:tempposx, Float:tempposy, Float:tempposz;
  361.             oldposx = Garagem[g][cnX];
  362.             oldposy = Garagem[g][cnY];
  363.             oldposz = Garagem[g][cnZ];
  364.             tempposx = (oldposx -x);
  365.             tempposy = (oldposy -y);
  366.             tempposz = (oldposz -z);
  367.             if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  368.             {
  369.                 return 1;
  370.             }
  371.         }
  372.     }
  373.     return 0;
  374. }
  375.  
  376. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  377. {
  378.     if(IsPlayerConnected(playerid))
  379.     {
  380.         new Float:oldposx, Float:oldposy, Float:oldposz;
  381.         new Float:tempposx, Float:tempposy, Float:tempposz;
  382.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  383.         tempposx = (oldposx -x);
  384.         tempposy = (oldposy -y);
  385.         tempposz = (oldposz -z);
  386.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  387.         {
  388.             return 1;
  389.         }
  390.     }
  391.     return 0;
  392. }
  393.  
  394. public FecharGaragem(playerid, garageid)
  395. {
  396.     if(Deletado[garageid] == false)
  397.     {
  398.         SendClientMessage(playerid, COR_SUCESSO, "O Portão foi {F60000}Fechado {00AB00}totalmente.");
  399.         Garagem[garageid][cnLock] = 1;
  400.         new string[256];
  401.         format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  402.         Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  403.         format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  404.         Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  405.         SalvarGaragens();
  406.     }
  407.     return 1;
  408. }
  409.  
  410. public AbrirGaragem(playerid, garageid)
  411. {
  412.     if(Deletado[garageid] == false)
  413.     {
  414.         SendClientMessage(playerid, COR_SUCESSO, "O Portão foi {00F600}Aberto {00AB00}totalmente.");
  415.         Garagem[garageid][cnLock] = 0;
  416.         new string[256];
  417.         format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  418.         Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  419.         format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  420.         Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  421.         SalvarGaragens();
  422.     }
  423.     return 1;
  424. }
  425.  
  426. public Creditos()
  427. {
  428.     SendClientMessageToAll(-1, "Garage System made by CidadeNovaRP.");
  429.     return 1;
  430. }
  431.  
  432. public OnPlayerConnect(playerid)
  433. {
  434.     return 1;
  435. }
  436.  
  437. public OnPlayerCommandText(playerid, cmdtext[])
  438. {
  439.  
  440.     if(strcmp(cmdtext, "/cneditar", true) == 0)
  441.     {
  442.         if(IsPlayerAdmin(playerid))
  443.         {
  444.             for(new g=0; g<MAX_GARAGENS; g++)
  445.             {
  446.                 if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]))
  447.                 {
  448.                     if(Deletado[g] == false)
  449.                     {
  450.                         EditandoGaragem[playerid] = g;
  451.                         ShowPlayerDialog(playerid, 5555, DIALOG_STYLE_MSGBOX, "Criar Garagem","Clique em 'Meu Nome' para você ser o Dono ou em 'Editar' para mudar o Dono", "Meu Nome", "Editar");
  452.                     }
  453.                 }
  454.             }
  455.         }
  456.         return 1;
  457.     }
  458.    
  459.     if(strcmp(cmdtext, "/cncriar", true) == 0)
  460.     {
  461.         if(IsPlayerAdmin(playerid))
  462.         {
  463.             new Float:x, Float:y, Float:z;
  464.             GetPlayerPos(playerid, x, y, z);
  465.             EditandoGaragem[playerid] = GaragemAtual+1;
  466.             if(!GarageToPoint(7.0, EditandoGaragem[playerid], x, y, z))
  467.             {
  468.                 ShowPlayerDialog(playerid, 5555, DIALOG_STYLE_MSGBOX, "Criar Garagem","Clique em 'Meu Nome' para você ser o Dono ou em 'Editar' para mudar o Dono", "Meu Nome", "Editar");
  469.                 CriarGaragem("", GaragemAtual+1, x, y, z, "", true);
  470.             }
  471.         }
  472.         return 1;
  473.     }
  474.  
  475.     if(strcmp(cmdtext, "/cndeletar", true) == 0)
  476.     {
  477.         if(IsPlayerAdmin(playerid))
  478.         {
  479.             for(new g=0; g<MAX_GARAGENS; g++)
  480.             {
  481.                 if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]))
  482.                 {
  483.                     if(Deletado[g] == false)
  484.                     {
  485.                         DeletarGaragem(g);
  486.                     }
  487.                 }
  488.             }
  489.         }
  490.         return 1;
  491.     }
  492.  
  493.     if (strcmp("/cnfechar", cmdtext, true, 10) == 0)
  494.     {
  495.         new string[256];
  496.         new playername[24];
  497.         for(new g=0; g<MAX_GARAGENS; g++)
  498.         {
  499.             if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]) || PlayerToPoint(3.0, playerid, COORDENADASGARAGEM) && g == GetPlayerVirtualWorld(playerid)-10)
  500.             {
  501.                 GetPlayerName(playerid,playername,24);
  502.                 if(!strcmp(NameString[g],playername,true) || IsPlayerAdmin(playerid))
  503.                 {
  504.                     if(Deletado[g] == false)
  505.                     {
  506.                         if(Garagem[g][cnLock] == 0)
  507.                         {
  508.                             SetTimerEx("FecharGaragem", 5000, false, "ii", playerid, g);
  509.                             Garagem[g][cnLock] = 3;
  510.                             SendClientMessage(playerid, COR_SUCESSO, "O Portão está {F6F600}Fechando{00AB00}.");
  511.                             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  512.                             Update3DTextLabelText(LabelEntrada[g], 0xFFFFFFFF, string);
  513.                             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  514.                             Update3DTextLabelText(LabelSaida[g], 0xFFFFFFFF, string);
  515.                             break;
  516.                         }
  517.                         else
  518.                         {
  519.                             format(string, sizeof(string), "O Portão já está %s{AD0000}.", GetLockGaragem(g));
  520.                             SendClientMessage(playerid, COR_ERRO, string);
  521.                         }
  522.                     }
  523.                 }
  524.                 else
  525.                 {
  526.                     SendClientMessage(playerid, COR_ERRO, "Você não é Dono desta Garagem.");
  527.                 }
  528.             }
  529.         }
  530.         return 1;
  531.     }
  532.  
  533.     if (strcmp("/cnabrir", cmdtext, true, 10) == 0)
  534.     {
  535.         new string[256];
  536.         new playername[24];
  537.         for(new g=0; g<MAX_GARAGENS; g++)
  538.         {
  539.             if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]) || PlayerToPoint(3.0, playerid, COORDENADASGARAGEM) && g == GetPlayerVirtualWorld(playerid)-10)
  540.             {
  541.                 GetPlayerName(playerid,playername,24);
  542.                 if(!strcmp(NameString[g],playername,true) || IsPlayerAdmin(playerid))
  543.                 {
  544.                     if(Deletado[g] == false)
  545.                     {
  546.                         if(Garagem[g][cnLock] == 1)
  547.                         {
  548.                             SetTimerEx("AbrirGaragem", 5000, false, "ii", playerid, g);
  549.                             Garagem[g][cnLock] = 2;
  550.                             SendClientMessage(playerid, COR_SUCESSO, "O Portão está {F6F600}Abrindo{00AB00}.");
  551.                             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Entrada\n%s\n{ED6B79}Dono: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  552.                             Update3DTextLabelText(LabelEntrada[g], 0xFFFFFFFF, string);
  553.                             format(string, sizeof(string), "{0000F6}[GARAGEM ID: %d]\n{00F6F6}%s\n{0000F6}Saida\n%s\n{ED6B79}Dono: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  554.                             Update3DTextLabelText(LabelSaida[g], 0xFFFFFFFF, string);
  555.                             break;
  556.                         }
  557.                         else
  558.                         {
  559.                             format(string, sizeof(string), "O Portão já está %s{AD0000}.", GetLockGaragem(g));
  560.                             SendClientMessage(playerid, COR_ERRO, string);
  561.                         }
  562.                     }
  563.                 }
  564.                 else
  565.                 {
  566.                     SendClientMessage(playerid, COR_ERRO, "Você não é Dono desta Garagem.");
  567.                 }
  568.             }
  569.         }
  570.         return 1;
  571.     }
  572.  
  573.     if (strcmp("/cnentrar", cmdtext, true, 10) == 0)
  574.     {
  575.         new string[64];
  576.         for(new g=0; g<MAX_GARAGENS; g++)
  577.         {
  578.             if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]))
  579.             {
  580.                 if(Garagem[g][cnLock] == 0)
  581.                 {
  582.                     if(Deletado[g] == false)
  583.                     {
  584.                         if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  585.                         {
  586.                             SetPlayerPos(playerid, COORDENADASGARAGEM);
  587.                             SetPlayerVirtualWorld(playerid, g+10);
  588.                             SetPlayerInterior(playerid, 2);
  589.                             format(string, sizeof(string), "Bem Vindo a Garagem %d.", g);
  590.                             SendClientMessage(playerid, COR_SUCESSO, string);
  591.                         }
  592.                         else
  593.                         {
  594.                             if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  595.                             {
  596.                                 if(Garagem[g][cnCar] <= MAX_CARS)
  597.                                 {
  598.                                     for(new i = 0; i < MAX_PLAYERS; i++)
  599.                                     {
  600.                                         new tmpcar = GetPlayerVehicleID(playerid);
  601.                                         if(IsPlayerInVehicle(i, tmpcar))
  602.                                         {
  603.                                             SetPlayerVirtualWorld(i, g+10);
  604.                                             SetPlayerInterior(playerid, 2);
  605.                                             Garagem[g][cnCar] ++;
  606.                                             SetVehicleVirtualWorld(tmpcar, g+10);
  607.                                             SetVehiclePos(tmpcar, COORDENADASGARAGEM);
  608.                                             format(string, sizeof(string), "Bem Vindo a Garagem %d.", g);
  609.                                             SendClientMessage(i, COR_SUCESSO, string);
  610.                                         }
  611.                                     }
  612.                                 }
  613.                                 else
  614.                                 {
  615.                                     SendClientMessage(playerid, COR_ERRO, "Já tem o máximo de Veículos aceitos dentro desta Garagem.");
  616.                                 }
  617.                             }
  618.                             else
  619.                             {
  620.                                 SendClientMessage(playerid, COR_ERRO, "Apenas Motoristas podem Entrar e Sair da Garagem.");
  621.                             }
  622.                         }
  623.                     }
  624.                 }
  625.                 else
  626.                 {
  627.                     format(string, sizeof(string), "O Portão está %s{AD0000}.", GetLockGaragem(g));
  628.                     SendClientMessage(playerid, COR_ERRO, string);
  629.                     break;
  630.                 }
  631.             }
  632.         }
  633.         return 1;
  634.     }
  635.  
  636.     if (strcmp("/cnsair", cmdtext, true, 10) == 0)
  637.     {
  638.         new string[128];
  639.         for(new g=0; g<MAX_GARAGENS; g++)
  640.         {
  641.             if(g == GetPlayerVirtualWorld(playerid)-10)
  642.             {
  643.                 if(PlayerToPoint(3.0, playerid, COORDENADASGARAGEM))
  644.                 {
  645.                     if(Garagem[g][cnLock] == 0)
  646.                     {
  647.                         if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  648.                         {
  649.                             SetPlayerPos(playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]);
  650.                             SetPlayerVirtualWorld(playerid, 0);
  651.                             SetPlayerInterior(playerid, 0);
  652.                             format(string, sizeof(string), "Volte Sempre a Garagem %d.", g);
  653.                             SendClientMessage(playerid, COR_SUCESSO, string);
  654.                         }
  655.                         else
  656.                         {
  657.                             if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  658.                             {
  659.                                 for(new i = 0; i < MAX_PLAYERS; i++)
  660.                                 {
  661.                                     new tmpcar = GetPlayerVehicleID(playerid);
  662.                                     if(IsPlayerInVehicle(i, tmpcar))
  663.                                     {
  664.                                         SetPlayerVirtualWorld(i, 0);
  665.                                         SetPlayerInterior(playerid, 0);
  666.                                         Garagem[g][cnCar] --;
  667.                                         SetVehicleVirtualWorld(tmpcar, 0);
  668.                                         SetVehiclePos(tmpcar, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]);
  669.                                         format(string, sizeof(string), "Volte Sempre a Garagem %d.", g);
  670.                                         SendClientMessage(i, COR_SUCESSO, string);
  671.                                     }
  672.                                 }
  673.                             }
  674.                             else
  675.                             {
  676.                                 SendClientMessage(playerid, COR_ERRO, "Apenas Motoristas podem Entrar e Sair da Garagem.");
  677.                             }
  678.                         }
  679.                     }
  680.                     else
  681.                     {
  682.                         format(string, sizeof(string), "O Portão está %s{AD0000}.", GetLockGaragem(g));
  683.                         SendClientMessage(playerid, COR_ERRO, string);
  684.                         break;
  685.                     }
  686.                 }
  687.             }
  688.         }
  689.         return 1;
  690.     }
  691.     return 0;
  692. }
  693.  
  694. public OnVehicleSpawn(vehicleid)
  695. {
  696.     for(new g=0; g<MAX_GARAGENS; g++)
  697.     {
  698.         if(g == GetVehicleVirtualWorld(vehicleid)-10)
  699.         {
  700.             SetVehicleVirtualWorld(vehicleid, 0);
  701.             Garagem[g][cnCar] --;
  702.         }
  703.     }
  704.     return 1;
  705. }
  706.  
  707. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  708. {
  709.     if(dialogid == 5555)
  710.     {
  711.         if(response)
  712.         {
  713.             new playername[64];
  714.             GetPlayerName(playerid, playername, sizeof(playername));
  715.             SetGaragemDono(EditandoGaragem[playerid], playername);
  716.             ShowPlayerDialog(playerid, 5557, DIALOG_STYLE_INPUT, "Criar Garagem", "Digite o Comentario que irá aparecer no Label\nOBS: Caso não queira deixe o espaço em branco e Avançe", "Finalizar", "");
  717.         }
  718.         else
  719.         {
  720.             ShowPlayerDialog(playerid, 5556, DIALOG_STYLE_INPUT, "Criar Garagem", "Digite o Nick do Dono (Não o  ID)\nOBS: Não importa se o Player está Online ou não\nOBS: Caso não queira deixe o espaço em branco e Avançe", "Próximo", "");
  721.         }
  722.     }
  723.     if(dialogid == 5556)
  724.     {
  725.         if(response)
  726.         {
  727.             if(!strlen(inputtext))
  728.             {
  729.                 SetGaragemDono(EditandoGaragem[playerid], "Ninguem");
  730.                 ShowPlayerDialog(playerid, 5557, DIALOG_STYLE_INPUT, "Criar Garagem", "Digite o Comentario que irá aparecer no Label\nOBS: Caso não queira deixe o espaço em branco e Avançe", "Finalizar", "");
  731.             }
  732.             else
  733.             {
  734.                 new string[64];
  735.                 format(string, sizeof(string), "%s", inputtext);
  736.                 SetGaragemDono(EditandoGaragem[playerid], string);
  737.                 ShowPlayerDialog(playerid, 5557, DIALOG_STYLE_INPUT, "Criar Garagem", "Digite o Comentario que irá aparecer no Label\nOBS: Caso não queira deixe o espaço em branco e Avançe", "Finalizar", "");
  738.             }
  739.         }
  740.         else
  741.         {
  742.         }
  743.     }
  744.     if(dialogid == 5557)
  745.     {
  746.         if(response)
  747.         {
  748.             if(!strlen(inputtext))
  749.             {
  750.                 new string[128];
  751.                 format(string, sizeof(string), "Sem Comentario");
  752.                 SetGaragemComent(EditandoGaragem[playerid], string);
  753.             }
  754.             else
  755.             {
  756.                 new string[128];
  757.                 format(string, sizeof(string), "%s", inputtext);
  758.                 SetGaragemComent(EditandoGaragem[playerid], string);
  759.             }
  760.         }
  761.         else
  762.         {
  763.         }
  764.     }
  765.     return 1;
  766. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement