Advertisement
Guest User

Garage System made by CidadeNovaRP

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