Advertisement
Chip7

[FS] Garagem System (Sem Garagem)

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