Advertisement
marcelodell

Criação de Teleportes In Game v2.0

Mar 23rd, 2012
1,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.03 KB | None | 0 0
  1. /*--------------------------------------- Sistema de criação de Teleportes IN GAME v2.0 --------------------------------------
  2. ----------------------------------------- Não retire os creditos, caso o retire dará erro -------------------------------------
  3. -------------------------------- Creditos a Marcelodell ou Spark_DaSantos pela criação do FS -----------------------------------*/
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <DOF2>
  8.  
  9. #define                 COR_BRANCO              0xFFFFFFAA 
  10. #define                 COR_AMARELO             0xFFFF00AA
  11. #define                 COR_GRAD                0xCBCCCEFF
  12.  
  13. #define                 DIALOG_CRIAR                (1313)
  14. #define                 DIALOG_IR                   (1314)
  15. #define                 DIALOG_APAGAR               (1315)
  16. #define                 DIALOG_ATUALIZAR            (1316)
  17.  
  18. new Float:angulo,
  19. Float:x,
  20. Float:y,
  21. Float:z,
  22. arquivo[64],
  23. interior,
  24. vw,
  25. arquivo2[12], //2 células a mais para não causar possiveis BUG's
  26. String[128];
  27.  
  28. public OnFilterScriptInit()
  29. {
  30.     print("\n--------------------------------------");
  31.     print(" Sistema de Teleportes com Salvamento v2.0");
  32.     print(" Carregado com sucesso!");
  33.     print(" ====================================");
  34.     print(" Autor: Marcelodell ou Spark_DaSantos");
  35.     print("--------------------------------------\n");
  36.     return 1;
  37. }
  38.  
  39. public OnFilterScriptExit()
  40. {
  41.     return 1;
  42. }
  43.  
  44. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  45. {
  46.     if(dialogid == DIALOG_CRIAR)
  47.     {
  48.         if(response)
  49.         {
  50.             if(!DOF2_FileExists("Locais.txt")) DOF2_CreateFile("Locais.txt");
  51.             format(arquivo,sizeof(arquivo), "/Locais/%s.ini",inputtext);
  52.             format(arquivo2,sizeof(arquivo2), "Locais.txt");
  53.             if(DOF2_FileExists(arquivo))
  54.             {
  55.                 ShowPlayerDialog(playerid, DIALOG_CRIAR, DIALOG_STYLE_INPUT, "{FFFF00}Criar Teleporte", "{FF0000}Esse Nome já está salvo em nosso Banco de Dados\n\n{FFFFFF}Digite outro nome para seu teleporte:", "Criar", "Cancelar");
  56.                 return 1;
  57.             }
  58.             DOF2_CreateFile(arquivo);
  59.             GetPlayerPos(playerid, x, y, z);
  60.             GetPlayerFacingAngle(playerid, angulo);
  61.             DOF2_SetString(arquivo,"Nome",inputtext);
  62.             DOF2_SetString(arquivo2,inputtext,"Salvo no Banco de Dados");
  63.             DOF2_SetFloat(arquivo,"X",x);
  64.             DOF2_SetFloat(arquivo,"Y",y);
  65.             DOF2_SetFloat(arquivo,"Z",z);
  66.             DOF2_SetFloat(arquivo,"Angulo",angulo);
  67.             DOF2_SetInt(arquivo,"Interior",GetPlayerInterior(playerid));
  68.             DOF2_SetInt(arquivo,"VirtualWorld",GetPlayerVirtualWorld(playerid));
  69.             DOF2_SaveFile();
  70.             SendClientMessage(playerid, COR_BRANCO,"Teleporte Criado com Sucesso!");
  71.             return 1;
  72.         }
  73.         else
  74.         {
  75.             SendClientMessage(playerid, COR_AMARELO, "Você cancelou a criação de um Novo Teleporte!");
  76.             return 1;
  77.         }
  78.     }
  79.     if(dialogid == DIALOG_IR)
  80.     {
  81.         if(response)
  82.         {
  83.             format(arquivo,sizeof(arquivo), "/Locais/%s.ini",inputtext);
  84.             if(!DOF2_FileExists(arquivo))
  85.             {
  86.                 ShowPlayerDialog(playerid, DIALOG_IR, DIALOG_STYLE_INPUT, "{FFFF00}Ir para o Teleporte", "{FF0000}O Teleporte informado não está salvo em nosso Banco de Dados!\n\n{FFFFFF}Digite o nome do Teleporte que você deseja ir:", "Ir", "Cancelar");
  87.                 return 1;
  88.             }
  89.             x = DOF2_GetFloat(arquivo,"X");
  90.             y = DOF2_GetFloat(arquivo,"Y");
  91.             z = DOF2_GetFloat(arquivo,"Z");
  92.             angulo = DOF2_GetFloat(arquivo,"Angulo");
  93.             interior = DOF2_GetInt(arquivo,"Interior");
  94.             vw = DOF2_GetInt(arquivo, "VirtualWorld");
  95.             SetPlayerVirtualWorld(playerid, vw);
  96.             SetPlayerInterior(playerid,interior);
  97.             if (GetPlayerState(playerid) == 2)
  98.             {
  99.                 SetVehiclePos(GetPlayerVehicleID(playerid), x,y,z);
  100.                 SetVehicleZAngle(GetPlayerVehicleID(playerid), angulo);
  101.                 SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), vw);
  102.                 LinkVehicleToInterior(GetPlayerVehicleID(playerid), interior);
  103.             }
  104.             else
  105.             {
  106.                 SetPlayerPos(playerid, x,y,z);
  107.                 SetPlayerFacingAngle(playerid, angulo);
  108.             }
  109.             format(String, sizeof(String), "Você foi teleportado até o(a) %s", inputtext);
  110.             SendClientMessage(playerid, COR_BRANCO, String);
  111.             return 1;
  112.         }
  113.     }
  114.     if(dialogid == DIALOG_APAGAR)
  115.     {
  116.         if(response)
  117.         {
  118.             if(!DOF2_FileExists("Locais.txt")) DOF2_CreateFile("Locais.txt");
  119.             format(arquivo,sizeof(arquivo), "/Locais/%s.ini",inputtext);
  120.             format(arquivo2,sizeof(arquivo2), "Locais.txt");
  121.             if(!DOF2_FileExists(arquivo))
  122.             {
  123.                 ShowPlayerDialog(playerid, DIALOG_APAGAR, DIALOG_STYLE_INPUT, "{FFFF00}Apagar Teleporte", "{FF0000}Este Teleporte não está Registrado em nosso Banco de Dados\n\n{FFFFFF}Digite o nome do Teleporte que você deseja apagar:", "Apagar", "Cancelar");
  124.                 return 1;
  125.             }
  126.             DOF2_RemoveFile(arquivo);
  127.             DOF2_SetString(arquivo2,inputtext,"Apagado pelo Usuário");
  128.             DOF2_SaveFile();
  129.             SendClientMessage(playerid, COR_AMARELO,"Local apagado com sucesso!");
  130.             return 1;
  131.         }
  132.     }
  133.     if(dialogid == DIALOG_ATUALIZAR)
  134.     {
  135.         if(response)
  136.         {
  137.             format(arquivo,sizeof(arquivo), "/Locais/%s.ini",inputtext);
  138.             if(!DOF2_FileExists(arquivo))
  139.             {
  140.                 ShowPlayerDialog(playerid, DIALOG_ATUALIZAR, DIALOG_STYLE_INPUT, "{FFFF00}Atualizar Teleporte", "{FF0000}O Teleporte informado não está salvo em nosso Banco de Dados!\n\n{FFFFFF}Digite o nome do Teleporte que você deseja Atualizar:", "Atualizar", "Cancelar");
  141.                 return 1;
  142.             }
  143.             DOF2_RemoveFile(arquivo);
  144.             DOF2_CreateFile(arquivo);
  145.             GetPlayerPos(playerid, x, y, z);
  146.             GetPlayerFacingAngle(playerid, angulo);
  147.             DOF2_SetString(arquivo,"Nome",inputtext);
  148.             DOF2_SetFloat(arquivo,"X",x);
  149.             DOF2_SetFloat(arquivo,"Y",y);
  150.             DOF2_SetFloat(arquivo,"Z",z);
  151.             DOF2_SetFloat(arquivo,"Angulo",angulo);
  152.             DOF2_SetInt(arquivo,"Interior",GetPlayerInterior(playerid));
  153.             DOF2_SetInt(arquivo,"VirtualWorld",GetPlayerVirtualWorld(playerid));
  154.             DOF2_SaveFile();
  155.             SendClientMessage(playerid, COR_AMARELO,"Teleporte atualizado com sucesso!");
  156.             return 1;
  157.         }
  158.     }
  159.     return 1;
  160. }
  161.  
  162. CMD:criarteleporte(playerid, params[])
  163. {
  164.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_GRAD,"Você não está autorizado a usar este comando.");
  165.     ShowPlayerDialog(playerid, DIALOG_CRIAR, DIALOG_STYLE_INPUT, "{FFFF00}Criar Teleporte", "{FFFFFF}Digite o nome para o seu novo Teleporte:", "Criar", "Cancelar");
  166.     return 1;
  167. }
  168. CMD:irteleporte(playerid, params[])
  169. {
  170.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_GRAD,"Você não está autorizado a usar este comando.");
  171.     ShowPlayerDialog(playerid, DIALOG_IR, DIALOG_STYLE_INPUT, "{FFFF00}Ir para o Teleporte", "{FFFFFF}Digite o nome do Teleporte que você deseja ir:", "Ir", "Cancelar");
  172.     return 1;
  173. }  
  174. CMD:apagarteleporte(playerid, params[])
  175. {
  176.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_GRAD,"Você não está autorizado a usar este comando.");
  177.     ShowPlayerDialog(playerid, DIALOG_APAGAR, DIALOG_STYLE_INPUT, "{FFFF00}Apagar Teleporte", "{FFFFFF}Digite o nome do Teleporte que você deseja apagar:", "Apagar", "Cancelar");
  178.     return 1;
  179. }
  180. CMD:atualizarteleporte(playerid, params[])
  181. {
  182.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_GRAD,"Você não está autorizado a usar este comando.");
  183.     ShowPlayerDialog(playerid, DIALOG_ATUALIZAR, DIALOG_STYLE_INPUT, "{FFFF00}Atualizar Teleporte", "{FFFFFF}Digite o nome do Teleporte que você deseja Atualizar:", "Atualizar", "Cancelar");
  184.     return 1;
  185. }
  186. CMD:locais(playerid, params[])
  187. {
  188.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_GRAD,"Você não está autorizado a usar este comando.");
  189.     new loc[512];
  190.     if(!DOF2_FileExists("Locais.txt")) DOF2_CreateFile("Locais.txt");
  191.     new File:ftw=fopen("Locais.txt",io_read);
  192.     SendClientMessage(playerid, COR_AMARELO, "==================== LOCAIS ====================");
  193.     new l;
  194.     while(fread(ftw,loc))
  195.     {
  196.         l++;
  197.         if(l==0)
  198.         {
  199.             SendClientMessage(playerid,COR_BRANCO,"Nenhum Local Salvo no Banco de Dados");
  200.         }
  201.         else
  202.         {
  203.             SendClientMessage(playerid,COR_BRANCO,loc);
  204.         }
  205.     }
  206.     fclose(ftw);
  207.     return 1;
  208. }
  209. CMD:creditosteleporte(playerid, params[])
  210. {
  211.     ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Creditos do Sistema de Teleportes v2.0", "------------- Sistema de Teleportes -------------\n------------- Com Salvamento IN GAME -------------\nCriado por: Marcelodell ou Spark_DaSantos", "OK", "");
  212.     return 1;
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement