Advertisement
Guest User

CidadeNovaRP

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