Advertisement
CddNovaRP

[FilterScript] Garage System

Jun 25th, 2012
5,234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 25.38 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3.  
  4. #define MAX_GARAGENS 200 // MAXIMUM OF GARAGES
  5. #define MAX_CARS 1 // MAXIMUM CAR GARAGE BY +1
  6. #define COORDENADASGARAGEM -1232.7811279297,-74.612930297852,14.502492904663 // X,Y,Z THE GARAGE (DO NOT PUT SPACES BETWEEN COORDINATES)
  7. #define COR_ERRO 0xAD0000AA
  8. #define COR_SUCESSO 0x00AB00AA
  9.  
  10. forward CarregarGaragens();
  11. forward SalvarGaragens();
  12. forward CreateGarage(playerowner[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, playerowner[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");
  46.     CarregarGaragens();
  47.     SetTimer("Creditos", 1000*1*60*15, true);
  48.     CreateObject(14776,-1222.58178711,-73.19232178,20.01030540,0.00000000,0.00000000,315.19982910);
  49.     CreateObject(2893,-1226.20849609,-78.41390991,14.47902775,4.00000000,0.00000000,314.72668457);
  50.     CreateObject(2893,-1224.88500977,-79.58795166,14.47902775,4.00000000,0.00000000,315.72119141);
  51.     CreateObject(2893,-1220.97375488,-75.61949158,14.47902679,344.00000000,0.00000000,315.64929199);
  52.     CreateObject(2893,-1222.22424316,-74.27712250,14.47902679,344.00000000,0.00000000,315.22387695);
  53.     CreateObject(1558,-1222.23022461,-74.30402374,14.07644463,0.00000000,0.00000000,315.19995117);
  54.     CreateObject(1558,-1220.96813965,-75.57649994,14.07644463,0.00000000,0.00000000,134.84912109);
  55.     CreateObject(2860,-1220.97290039,-75.57939911,14.53230476,0.00000000,0.00000000,245.51635742);
  56.     return 1;
  57. }
  58.  
  59. public OnFilterScriptExit()
  60. {
  61.     DOF2_Exit();
  62.     return 1;
  63. }
  64.  
  65. stock GetLockGaragem(garageid)
  66. {
  67.     new lock[64];
  68.     if(Garagem[garageid][cnLock] == 0)
  69.     {
  70.         lock = "{00F600}Open";
  71.     }
  72.     else if(Garagem[garageid][cnLock] == 1)
  73.     {
  74.         lock = "{F60000}Close";
  75.     }
  76.     else if(Garagem[garageid][cnLock] == 2)
  77.     {
  78.         lock = "{F6F600}Opening";
  79.     }
  80.     else if(Garagem[garageid][cnLock] == 3)
  81.     {
  82.         lock = "{F6F600}Closing";
  83.     }
  84.     return lock;
  85. }
  86.  
  87. public CarregarGaragens()
  88. {
  89.     new string[256];
  90.     new arquivo[64];
  91.     new arquivoatual[64];
  92.     for(new g=0; g<MAX_GARAGENS; g++)
  93.     {
  94.         format(arquivoatual, sizeof(arquivoatual), "GaragemAtual.inc", g);
  95.         format(arquivo, sizeof(arquivo), "Garagem%d.inc", g);
  96.         if(DOF2_FileExists(arquivo))
  97.         {
  98.             if(Deletado[g] == false)
  99.             {
  100.                 new word = g + 10;
  101.                 Garagem[g][cnX] = DOF2_GetFloat(arquivo, "X");
  102.                 Garagem[g][cnY] = DOF2_GetFloat(arquivo, "Y");
  103.                 Garagem[g][cnZ] = DOF2_GetFloat(arquivo, "Z");
  104.                 Garagem[g][cnLock] = DOF2_GetInt(arquivo, "Lock");
  105.                 format(NameString[g], 64, "%s", DOF2_GetString(arquivo, "Owner", NameString[g]));
  106.                 LabelString[g] = DOF2_GetString(arquivo, "Coment", LabelString[g]);
  107.                 GaragemAtual = DOF2_GetInt(arquivoatual, "GGID");
  108.                 format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  109.                 LabelEntrada[g] = Create3DTextLabel(string, 0xFFFFFFFF, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ], 30.0, 0, 1 );
  110.                 format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  111.                 LabelSaida[g] = Create3DTextLabel(string, 0xFFFFFFFF, COORDENADASGARAGEM, 30.0, word, 1 );
  112.                 printf("Garagem Carregada: %d %d %d \nComentario: %s\nDono: %s", Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ], LabelString[g], NameString[g]);
  113.             }
  114.         }
  115.     }
  116.     return 1;
  117. }
  118.  
  119. public SalvarGaragens()
  120. {
  121.     new arquivo[64];
  122.     new arquivoatual[64];
  123.     for(new g=0; g<MAX_GARAGENS; g++)
  124.     {
  125.         format(arquivoatual, sizeof(arquivoatual), "GaragemAtual.inc", g);
  126.         format(arquivo, sizeof(arquivo), "Garagem%d.inc", g);
  127.         if(DOF2_FileExists(arquivo))
  128.         {
  129.             if(Deletado[g] == false)
  130.             {
  131.                 DOF2_CreateFile(arquivo);
  132.                 DOF2_SetFloat(arquivo, "X", Garagem[g][cnX]);
  133.                 DOF2_SetFloat(arquivo, "Y", Garagem[g][cnY]);
  134.                 DOF2_SetFloat(arquivo, "Z", Garagem[g][cnZ]);
  135.                 DOF2_SetInt(arquivo, "Lock", Garagem[g][cnLock]);
  136.                 DOF2_SetString(arquivo, "Coment", LabelString[g]);
  137.                 DOF2_SetString(arquivo, "Owner", NameString[g]);
  138.                 if(!DOF2_FileExists(arquivoatual))
  139.                 {
  140.                     if(GaragemAtual <= MAX_GARAGENS)
  141.                     {
  142.                         DOF2_CreateFile(arquivoatual);
  143.                         DOF2_SetInt(arquivoatual, "GGID", GaragemAtual);
  144.                     }
  145.                     else
  146.                     {
  147.                         printf("Reached Maximum Garages, increase the MAX_GARAGENS Garages and renew or delete the file 'GaragemAtual'!");
  148.                     }
  149.                 }
  150.                 else
  151.                 {
  152.                     if(GaragemAtual <= MAX_GARAGENS)
  153.                     {
  154.                         DOF2_SetInt(arquivoatual, "GGID", GaragemAtual);
  155.                     }
  156.                     else
  157.                     {
  158.                         printf("Reached Maximum Garages, increase the MAX_GARAGENS Garages and renew or delete the file 'GaragemAtual'!");
  159.                     }
  160.                 }
  161.             }
  162.             DOF2_SaveFile();
  163.         }
  164.     }
  165.     return 1;
  166. }
  167.  
  168. public CreateGarage(playerowner[64], garageid, Float:gx, Float:gy, Float:gz, coment[128], bool:lock)
  169. {
  170.     new string[256];
  171.     new arquivo[64];
  172.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  173.     if(!DOF2_FileExists(arquivo))
  174.     {
  175.         if(!GarageToPoint(7.0, garageid, gx, gy, gz))
  176.         {
  177.             if(GaragemAtual <= MAX_GARAGENS)
  178.             {
  179.                 DOF2_CreateFile(arquivo);
  180.                 new word = garageid + 10;
  181.                 Garagem[garageid][cnX] = gx;
  182.                 Garagem[garageid][cnY] = gy;
  183.                 Garagem[garageid][cnZ] = gz;
  184.                 Garagem[garageid][cnLock] = lock;
  185.                 NameString[garageid] = playerowner;
  186.                 LabelString[garageid] = coment;
  187.                 GaragemAtual ++;
  188.                 format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  189.                 LabelEntrada[garageid] = Create3DTextLabel(string, 0xFFFFFFFF, gx, gy, gz, 30.0, 0, 1 );
  190.                 format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  191.                 LabelSaida[garageid] = Create3DTextLabel(string, 0xFFFFFFFF, COORDENADASGARAGEM, 30.0, word, 1 );
  192.                 printf("Garage Built: %d %d %d \nComent: %s\nOwner: %s", Garagem[garageid][cnX], Garagem[garageid][cnY], Garagem[garageid][cnZ], LabelString[garageid], NameString[garageid]);
  193.                 SalvarGaragens();
  194.             }
  195.             else
  196.             {
  197.                 printf("Reached Maximum Garages, increase the MAX_GARAGENS Garages and renew or delete the file 'GaragemAtual'!");
  198.             }
  199.         }
  200.         else
  201.         {
  202.             printf("There is already a garage at this radius.");
  203.         }
  204.     }
  205.     else
  206.     {
  207.         printf("There is this GarageID.");
  208.     }
  209.     return 1;
  210. }
  211.  
  212. public DeletarGaragem(garageid)
  213. {
  214.     new arquivo[64];
  215.     new string[128];
  216.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  217.     if(!DOF2_FileExists(arquivo))
  218.     {
  219.         printf("There is this GarageID.");
  220.         return 1;
  221.     }
  222.     else
  223.     {
  224.         for(new i = 0; i < MAX_PLAYERS; i++)
  225.         {
  226.             for(new v = 0; v < MAX_VEHICLES; v++)
  227.             {
  228.                 if(garageid == GetVehicleVirtualWorld(v)-10)
  229.                 {
  230.                     if(!IsPlayerInVehicle(i, v))
  231.                     {
  232.                         SetVehicleVirtualWorld(v, 0);
  233.                         SetVehicleToRespawn(v);
  234.                     }
  235.                 }
  236.             }
  237.             if(garageid == GetPlayerVirtualWorld(i)-10)
  238.             {
  239.                 if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
  240.                 {
  241.                     SetPlayerPos(i, Garagem[garageid][cnX], Garagem[garageid][cnY], Garagem[garageid][cnZ]);
  242.                     SetPlayerVirtualWorld(i, 0);
  243.                     SetPlayerInterior(i, 0);
  244.                     format(string, sizeof(string), "The Garage %d{00AB00} was deleted.", garageid);
  245.                     SendClientMessage(i, COR_SUCESSO, string);
  246.                 }
  247.                 else
  248.                 {
  249.                     new tmpcar = GetPlayerVehicleID(i);
  250.                     SetVehiclePos(tmpcar, Garagem[garageid][cnX], Garagem[garageid][cnY], Garagem[garageid][cnZ]);
  251.                     SetVehicleVirtualWorld(tmpcar, 0);
  252.                     SetPlayerVirtualWorld(i, 0);
  253.                     SetPlayerInterior(i, 0);
  254.                     format(string, sizeof(string), "The Garage %d{00AB00} was deleted.", garageid);
  255.                     SendClientMessage(i, COR_SUCESSO, string);
  256.                 }
  257.             }
  258.         }
  259.         DOF2_RemoveFile(arquivo);
  260.         Deletado[garageid] = true;
  261.         Delete3DTextLabel(LabelSaida[garageid]);
  262.         Delete3DTextLabel(LabelEntrada[garageid]);
  263.         printf("Garagem %d foi deletada", garageid);
  264.         SalvarGaragens();
  265.     }
  266.     return 1;
  267. }
  268.  
  269. public SetGaragemComent(garageid, coment[128])
  270. {
  271.     new arquivo[64];
  272.     new string[128];
  273.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  274.     if(!DOF2_FileExists(arquivo))
  275.     {
  276.         printf("There is this GarageID.");
  277.         return 1;
  278.     }
  279.     else
  280.     {
  281.         if(Deletado[garageid] == false)
  282.         {
  283.             printf("The Comment of garage %d has changed", garageid);
  284.             LabelString[garageid] = coment;
  285.             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  286.             Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  287.             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  288.             Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  289.             SalvarGaragens();
  290.         }
  291.     }
  292.     return 1;
  293. }
  294.  
  295. public SetGaragemDono(garageid, playerowner[64])
  296. {
  297.     new arquivo[64];
  298.     new string[128];
  299.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  300.     if(!DOF2_FileExists(arquivo))
  301.     {
  302.         printf("There is this GarageID.");
  303.         return 1;
  304.     }
  305.     else
  306.     {
  307.         if(Deletado[garageid] == false)
  308.         {
  309.             printf("The owner of Garage %d has changed", garageid);
  310.             NameString[garageid] = playerowner;
  311.             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  312.             Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  313.             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  314.             Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  315.             SalvarGaragens();
  316.         }
  317.     }
  318.     return 1;
  319. }
  320.  
  321. public SetGaragemPos(garageid, Float:gx, Float:gy, Float:gz)
  322. {
  323.     new arquivo[64];
  324.     new string[128];
  325.     format(arquivo, sizeof(arquivo), "Garagem%d.inc", garageid);
  326.     if(!DOF2_FileExists(arquivo))
  327.     {
  328.         printf("There is this GarageID.");
  329.         return 1;
  330.     }
  331.     else
  332.     {
  333.         if(Deletado[garageid] == false)
  334.         {
  335.             printf("The Post's Garage %d has changed", garageid);
  336.             Garagem[garageid][cnX] = gx;
  337.             Garagem[garageid][cnY] = gy;
  338.             Garagem[garageid][cnZ] = gz;
  339.             Delete3DTextLabel(LabelEntrada[garageid]);
  340.             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  341.             LabelEntrada[garageid] = Create3DTextLabel(string, 0xFFFFFFFF, gx, gy, gz, 30.0, 0, 1 );
  342.             SalvarGaragens();
  343.         }
  344.     }
  345.     return 1;
  346. }
  347.  
  348. public GarageToPoint(Float:radi, garageid, Float:x, Float:y, Float:z)
  349. {
  350.     for(new g=0; g<MAX_GARAGENS; g++)
  351.     {
  352.         if(Deletado[g] == false)
  353.         {
  354.             new Float:oldposx, Float:oldposy, Float:oldposz;
  355.             new Float:tempposx, Float:tempposy, Float:tempposz;
  356.             oldposx = Garagem[g][cnX];
  357.             oldposy = Garagem[g][cnY];
  358.             oldposz = Garagem[g][cnZ];
  359.             tempposx = (oldposx -x);
  360.             tempposy = (oldposy -y);
  361.             tempposz = (oldposz -z);
  362.             if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  363.             {
  364.                 return 1;
  365.             }
  366.         }
  367.     }
  368.     return 0;
  369. }
  370.  
  371. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  372. {
  373.     if(IsPlayerConnected(playerid))
  374.     {
  375.         new Float:oldposx, Float:oldposy, Float:oldposz;
  376.         new Float:tempposx, Float:tempposy, Float:tempposz;
  377.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  378.         tempposx = (oldposx -x);
  379.         tempposy = (oldposy -y);
  380.         tempposz = (oldposz -z);
  381.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  382.         {
  383.             return 1;
  384.         }
  385.     }
  386.     return 0;
  387. }
  388.  
  389. public FecharGaragem(playerid, garageid)
  390. {
  391.     if(Deletado[garageid] == false)
  392.     {
  393.         SendClientMessage(playerid, COR_SUCESSO, "The gate was {F60000}Close {00AB00}fully.");
  394.         Garagem[garageid][cnLock] = 1;
  395.         new string[256];
  396.         format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  397.         Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  398.         format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  399.         Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  400.         SalvarGaragens();
  401.     }
  402.     return 1;
  403. }
  404.  
  405. public AbrirGaragem(playerid, garageid)
  406. {
  407.     if(Deletado[garageid] == false)
  408.     {
  409.         SendClientMessage(playerid, COR_SUCESSO, "The gate was {00F600}Open {00AB00}fully.");
  410.         Garagem[garageid][cnLock] = 0;
  411.         new string[256];
  412.         format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  413.         Update3DTextLabelText(LabelEntrada[garageid], 0xFFFFFFFF, string);
  414.         format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", garageid, LabelString[garageid], GetLockGaragem(garageid), NameString[garageid]);
  415.         Update3DTextLabelText(LabelSaida[garageid], 0xFFFFFFFF, string);
  416.         SalvarGaragens();
  417.     }
  418.     return 1;
  419. }
  420.  
  421. public Creditos()
  422. {
  423.     SendClientMessageToAll(-1, "Garage System made by CidadeNovaRP.");
  424.     return 1;
  425. }
  426.  
  427. public OnPlayerConnect(playerid)
  428. {
  429.     return 1;
  430. }
  431.  
  432. public OnPlayerCommandText(playerid, cmdtext[])
  433. {
  434.  
  435.     if(strcmp(cmdtext, "/cnedit", true) == 0)
  436.     {
  437.         if(IsPlayerAdmin(playerid))
  438.         {
  439.             for(new g=0; g<MAX_GARAGENS; g++)
  440.             {
  441.                 if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]))
  442.                 {
  443.                     if(Deletado[g] == false)
  444.                     {
  445.                         EditandoGaragem[playerid] = g;
  446.                         ShowPlayerDialog(playerid, 5555, DIALOG_STYLE_MSGBOX, "Create/Edit Garage","Click on 'My Name' for you are the owner or 'Edit' to change the Owner", "My Name", "Edit");
  447.                     }
  448.                 }
  449.             }
  450.         }
  451.         return 1;
  452.     }
  453.  
  454.     if(strcmp(cmdtext, "/cncreate", true) == 0)
  455.     {
  456.         if(IsPlayerAdmin(playerid))
  457.         {
  458.             new Float:x, Float:y, Float:z;
  459.             GetPlayerPos(playerid, x, y, z);
  460.             EditandoGaragem[playerid] = GaragemAtual+1;
  461.             if(!GarageToPoint(7.0, EditandoGaragem[playerid], x, y, z))
  462.             {
  463.                 ShowPlayerDialog(playerid, 5555, DIALOG_STYLE_MSGBOX, "Create/Edit Garage","Click on 'My Name' for you are the owner or 'Edit' to change the Owner", "My Name", "Edit");
  464.                 CreateGarage("", GaragemAtual+1, x, y, z, "", true);
  465.             }
  466.         }
  467.         return 1;
  468.     }
  469.  
  470.     if(strcmp(cmdtext, "/cndelet", true) == 0)
  471.     {
  472.         if(IsPlayerAdmin(playerid))
  473.         {
  474.             for(new g=0; g<MAX_GARAGENS; g++)
  475.             {
  476.                 if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]))
  477.                 {
  478.                     if(Deletado[g] == false)
  479.                     {
  480.                         DeletarGaragem(g);
  481.                     }
  482.                 }
  483.             }
  484.         }
  485.         return 1;
  486.     }
  487.  
  488.     if (strcmp("/cnclose", cmdtext, true, 10) == 0)
  489.     {
  490.         new string[256];
  491.         new playername[24];
  492.         for(new g=0; g<MAX_GARAGENS; g++)
  493.         {
  494.             if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]) || PlayerToPoint(3.0, playerid, COORDENADASGARAGEM) && g == GetPlayerVirtualWorld(playerid)-10)
  495.             {
  496.                 GetPlayerName(playerid,playername,24);
  497.                 if(!strcmp(NameString[g],playername,true) || IsPlayerAdmin(playerid))
  498.                 {
  499.                     if(Deletado[g] == false)
  500.                     {
  501.                         if(Garagem[g][cnLock] == 0)
  502.                         {
  503.                             SetTimerEx("FecharGaragem", 5000, false, "ii", playerid, g);
  504.                             Garagem[g][cnLock] = 3;
  505.                             SendClientMessage(playerid, COR_SUCESSO, "The Gate is {F6F600}Closing{00AB00}.");
  506.                             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  507.                             Update3DTextLabelText(LabelEntrada[g], 0xFFFFFFFF, string);
  508.                             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  509.                             Update3DTextLabelText(LabelSaida[g], 0xFFFFFFFF, string);
  510.                             break;
  511.                         }
  512.                         else
  513.                         {
  514.                             format(string, sizeof(string), "The Gate is %s{AD0000}.", GetLockGaragem(g));
  515.                             SendClientMessage(playerid, COR_ERRO, string);
  516.                         }
  517.                     }
  518.                 }
  519.                 else
  520.                 {
  521.                     SendClientMessage(playerid, COR_ERRO, "You are not owner of this garage.");
  522.                 }
  523.             }
  524.         }
  525.         return 1;
  526.     }
  527.  
  528.     if (strcmp("/cnopen", cmdtext, true, 10) == 0)
  529.     {
  530.         new string[256];
  531.         new playername[24];
  532.         for(new g=0; g<MAX_GARAGENS; g++)
  533.         {
  534.             if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]) || PlayerToPoint(3.0, playerid, COORDENADASGARAGEM) && g == GetPlayerVirtualWorld(playerid)-10)
  535.             {
  536.                 GetPlayerName(playerid,playername,24);
  537.                 if(!strcmp(NameString[g],playername,true) || IsPlayerAdmin(playerid))
  538.                 {
  539.                     if(Deletado[g] == false)
  540.                     {
  541.                         if(Garagem[g][cnLock] == 1)
  542.                         {
  543.                             SetTimerEx("AbrirGaragem", 5000, false, "ii", playerid, g);
  544.                             Garagem[g][cnLock] = 2;
  545.                             SendClientMessage(playerid, COR_SUCESSO, "The Gate is {F6F600}Opening{00AB00}.");
  546.                             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Entry\n%s\n{ED6B79}Owner: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  547.                             Update3DTextLabelText(LabelEntrada[g], 0xFFFFFFFF, string);
  548.                             format(string, sizeof(string), "{0000F6}[GARAGE ID: %d]\n{00F6F6}%s\n{0000F6}Exit\n%s\n{ED6B79}Owner: %s%s", g, LabelString[g], GetLockGaragem(g), NameString[g]);
  549.                             Update3DTextLabelText(LabelSaida[g], 0xFFFFFFFF, string);
  550.                             break;
  551.                         }
  552.                         else
  553.                         {
  554.                             format(string, sizeof(string), "The Gate is %s{AD0000}.", GetLockGaragem(g));
  555.                             SendClientMessage(playerid, COR_ERRO, string);
  556.                         }
  557.                     }
  558.                 }
  559.                 else
  560.                 {
  561.                     SendClientMessage(playerid, COR_ERRO, "You are not owner of this garage.");
  562.                 }
  563.             }
  564.         }
  565.         return 1;
  566.     }
  567.  
  568.     if (strcmp("/cnentry", cmdtext, true, 10) == 0)
  569.     {
  570.         new string[64];
  571.         for(new g=0; g<MAX_GARAGENS; g++)
  572.         {
  573.             if(PlayerToPoint(3.0, playerid, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]))
  574.             {
  575.                 if(Garagem[g][cnLock] == 0)
  576.                 {
  577.                     if(Deletado[g] == false)
  578.                     {
  579.                         if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  580.                         {
  581.                             SetPlayerPos(playerid, COORDENADASGARAGEM);
  582.                             SetPlayerVirtualWorld(playerid, g+10);
  583.                             SetPlayerInterior(playerid, 2);
  584.                             format(string, sizeof(string), "Welcome to Garage %d.", g);
  585.                             SendClientMessage(playerid, COR_SUCESSO, string);
  586.                         }
  587.                         else
  588.                         {
  589.                             if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  590.                             {
  591.                                 if(Garagem[g][cnCar] <= MAX_CARS)
  592.                                 {
  593.                                     for(new i = 0; i < MAX_PLAYERS; i++)
  594.                                     {
  595.                                         new tmpcar = GetPlayerVehicleID(playerid);
  596.                                         if(IsPlayerInVehicle(i, tmpcar))
  597.                                         {
  598.                                             SetPlayerVirtualWorld(i, g+10);
  599.                                             SetPlayerInterior(playerid, 2);
  600.                                             Garagem[g][cnCar] ++;
  601.                                             SetVehicleVirtualWorld(tmpcar, g+10);
  602.                                             LinkVehicleToInterior(tmpcar, 2);
  603.                                             SetVehiclePos(tmpcar, COORDENADASGARAGEM);
  604.                                             format(string, sizeof(string), "Welcome to Garage %d.", g);
  605.                                             SendClientMessage(i, COR_SUCESSO, string);
  606.                                         }
  607.                                     }
  608.                                 }
  609.                                 else
  610.                                 {
  611.                                     SendClientMessage(playerid, COR_ERRO, "You already have the maximum accepted vehicles in the garage.");
  612.                                 }
  613.                             }
  614.                             else
  615.                             {
  616.                                 SendClientMessage(playerid, COR_ERRO, "Drivers can only enter and exit the garage.");
  617.                             }
  618.                         }
  619.                     }
  620.                 }
  621.                 else
  622.                 {
  623.                     format(string, sizeof(string), "The Gate is %s{AD0000}.", GetLockGaragem(g));
  624.                     SendClientMessage(playerid, COR_ERRO, string);
  625.                     break;
  626.                 }
  627.             }
  628.         }
  629.         return 1;
  630.     }
  631.  
  632.     if (strcmp("/cnexit", 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), "Return always the Garage %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.                                         LinkVehicleToInterior(tmpcar, 0);
  665.                                         SetVehiclePos(tmpcar, Garagem[g][cnX], Garagem[g][cnY], Garagem[g][cnZ]);
  666.                                         format(string, sizeof(string), "Return always the Garage %d.", g);
  667.                                         SendClientMessage(i, COR_SUCESSO, string);
  668.                                     }
  669.                                 }
  670.                             }
  671.                             else
  672.                             {
  673.                                 SendClientMessage(playerid, COR_ERRO, "Drivers can only enter and exit the garage.");
  674.                             }
  675.                         }
  676.                     }
  677.                     else
  678.                     {
  679.                         format(string, sizeof(string), "The Gate is %s{AD0000}.", GetLockGaragem(g));
  680.                         SendClientMessage(playerid, COR_ERRO, string);
  681.                         break;
  682.                     }
  683.                 }
  684.             }
  685.         }
  686.         return 1;
  687.     }
  688.     return 0;
  689. }
  690.  
  691. public OnVehicleSpawn(vehicleid)
  692. {
  693.     for(new g=0; g<MAX_GARAGENS; g++)
  694.     {
  695.         if(g == GetVehicleVirtualWorld(vehicleid)-10)
  696.         {
  697.             SetVehicleVirtualWorld(vehicleid, 0);
  698.             Garagem[g][cnCar] --;
  699.         }
  700.     }
  701.     return 1;
  702. }
  703.  
  704. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  705. {
  706.     if(dialogid == 5555)
  707.     {
  708.         if(response)
  709.         {
  710.             new playername[64];
  711.             GetPlayerName(playerid, playername, sizeof(playername));
  712.             SetGaragemDono(EditandoGaragem[playerid], playername);
  713.             ShowPlayerDialog(playerid, 5557, DIALOG_STYLE_INPUT, "Create/Edit Garage", "Enter a Comment that will appear in the Label\nNote: If you do not want to leave the space blank and go", "End", "");
  714.         }
  715.         else
  716.         {
  717.             ShowPlayerDialog(playerid, 5556, DIALOG_STYLE_INPUT, "Create/Edit Garage", "Enter Nick the owner (not the ID)\nNote: Whether the player is online or not\nNote: If you do not want to leave the space blank and go", "Next", "");
  718.         }
  719.     }
  720.     if(dialogid == 5556)
  721.     {
  722.         if(response)
  723.         {
  724.             if(!strlen(inputtext))
  725.             {
  726.                 SetGaragemDono(EditandoGaragem[playerid], "Nobody");
  727.                 ShowPlayerDialog(playerid, 5557, DIALOG_STYLE_INPUT, "Create/Edit Garage", "Enter a Comment that will appear in the Label\nNote: If you do not want to leave the space blank and go", "End", "");
  728.             }
  729.             else
  730.             {
  731.                 new string[64];
  732.                 format(string, sizeof(string), "%s", inputtext);
  733.                 SetGaragemDono(EditandoGaragem[playerid], string);
  734.                 ShowPlayerDialog(playerid, 5557, DIALOG_STYLE_INPUT, "Create/Edit Garage", "Enter a Comment that will appear in the Label\nNote: If you do not want to leave the space blank and go", "End", "");
  735.             }
  736.         }
  737.         else
  738.         {
  739.         }
  740.     }
  741.     if(dialogid == 5557)
  742.     {
  743.         if(response)
  744.         {
  745.             if(!strlen(inputtext))
  746.             {
  747.                 new string[128];
  748.                 format(string, sizeof(string), "No Comment");
  749.                 SetGaragemComent(EditandoGaragem[playerid], string);
  750.             }
  751.             else
  752.             {
  753.                 new string[128];
  754.                 format(string, sizeof(string), "%s", inputtext);
  755.                 SetGaragemComent(EditandoGaragem[playerid], string);
  756.             }
  757.         }
  758.         else
  759.         {
  760.         }
  761.     }
  762.     return 1;
  763. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement