Advertisement
Chip7

[FS] Filterscript Facções dinâmicas (Criador de organizações

Oct 25th, 2013
1,465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 35.80 KB | None | 0 0
  1. /*
  2.  
  3.   VISITE NOSSO SITE: http://www.sampknd.com/
  4.   VISITE NOSSO FACEBOOK: http://www.facebook.com/SampKnd
  5.   SAMP KND MELHOR BLOG DE SAMP DO BRASIL
  6.  
  7. Comandos:
  8.     faction "criar e apagar [id]";
  9.     darlider;
  10.     lider "convidar [id], demitir [id], promover [id], rebaixar [id], info";
  11.     ingressar;
  12.     radio;
  13.     membros;
  14.     lideres;
  15.     editarfaccao "cargo, nome";
  16.     factions;
  17.     entrar;
  18.     sair;
  19.     sethq;
  20.     editarhq "mover";
  21. .
  22. salvamento add
  23. */
  24.  
  25. #include    <   a_samp    >
  26. #include    <   zcmd      >
  27. #include    <   sscanf2   >
  28. #include    <   streamer  >
  29. #include    <   dof2      >
  30.  
  31. #define     cor_erro        0xFF5959AA
  32. #define     cor_sucesso     0x05A529AA
  33.  
  34. #define     max_faction     50
  35. #define     max_HQ          50
  36. #define     max_players     MAX_PLAYERS
  37.  
  38. #define     local_h         "Faction/HQ/%d.ini"
  39. #define     local_f         "Faction/Factions/%d.ini"
  40. #define     local_p         "Faction/Player/%s.ini"
  41.  
  42. #define     erro_admin      "erro: você não possue cargo administrativo."
  43. #define     erro_id         "erro: jogador não conectado."
  44. #define     erro_faction    "erro: você não é dessa facção."
  45. #define     erro_lider      "erro: você não é um lider."
  46.  
  47. #define     nome_da_faccao  "faction_%d" //nomes gerados inicialmente.
  48. #define     f_cargo_1       "Cargo 1"
  49. #define     f_cargo_2       "Cargo 2"
  50. #define     f_cargo_3       "Cargo 3"
  51. #define     f_cargo_4       "Cargo 4"
  52. #define     f_cargo_5       "Cargo 5"
  53. #define     f_cargo_6       "Lider"
  54.  
  55. enum enum_faction
  56. {
  57.     Ativo,
  58.     Banco,
  59.     Nome[32],
  60.     Cargo_1[32],
  61.     Cargo_2[32],
  62.     Cargo_3[32],
  63.     Cargo_4[32],
  64.     Cargo_5[32],
  65.     Cargo_6[32],
  66.     HeadQ
  67. }
  68.  
  69. enum enum_player
  70. {
  71.     owner,
  72.     pfaction,
  73.     pcargo
  74. }
  75.  
  76. enum enum_convidado
  77. {
  78.     cativo,
  79.     cfaction
  80. }
  81.  
  82. enum enum_HQ
  83. {
  84.     ativo,
  85.     tipo,
  86.     factionid,
  87.     Float:x,
  88.     Float:y,
  89.     Float:z,
  90.     Float:intx,
  91.     Float:inty,
  92.     Float:intz,
  93.     Interior,
  94.     World,
  95.     Pickup[2],
  96.     Text3D:Label[2]
  97. }
  98.  
  99. new faction[max_faction][enum_faction];
  100. new player[max_players][enum_player];
  101. new convidado[max_players][enum_convidado];
  102. new HQ[max_HQ][enum_HQ];
  103.  
  104. new bool:InHQ = false;
  105.  
  106. public OnGameModeInit()
  107. {
  108.     LoadFaction();
  109.     LoadHQ();
  110.     CreateInt();
  111.     return 1;
  112. }
  113.  
  114. public OnGameModeExit()
  115. {
  116.     DOF2_Exit();
  117.     return 1;
  118. }
  119.  
  120. public OnPlayerConnect(playerid)
  121. {
  122.     LoadPlayer(playerid);
  123.     return 1;
  124. }
  125.  
  126. public OnPlayerDisconnect(playerid)
  127. {
  128.     SavePlayer(playerid);
  129.     return 1;
  130. }
  131.  
  132. command(membros, playerid, params[])
  133. {
  134.     if(player[playerid][pfaction] == 0) return SendClientMessage(playerid, cor_erro, "erro: você não está em nenhuma facção!");
  135.     new _string[128], faction_id = player[playerid][pfaction];
  136.     SendClientMessage(playerid, cor_sucesso, "Membros online:");
  137.     for(new i = 0; i < max_players; i++)
  138.     {
  139.         if(player[i][pfaction] == faction_id)
  140.         {
  141.             format(_string, sizeof(_string), "%s (ID: %d) Cargo: %s (%d)", GetName(i), i, GetRankName(i), player[playerid][pcargo]);
  142.             SendClientMessage(playerid, cor_sucesso, _string);
  143.         }
  144.     }
  145.     return 1;
  146. }
  147.  
  148. command(lideres, playerid, params[])
  149. {
  150.     new faction_id, _string[128];
  151.     SendClientMessage(playerid, cor_sucesso, "Lideres online:");
  152.     for(new i = 0; i < max_players; i++)
  153.     {
  154.         if(player[i][pcargo] == 6)
  155.         {
  156.             faction_id = player[i][pfaction];
  157.             format(_string, sizeof(_string), "%s (ID: %d) Facção: %s", GetName(i), i, GetFactionName(faction_id));
  158.             SendClientMessage(playerid, cor_sucesso, _string);
  159.         }
  160.     }
  161.     return 1;
  162. }
  163.  
  164. command(faccoes, playerid, params[])
  165. {
  166.     new _string[128];
  167.     SendClientMessage(playerid, cor_sucesso, "Facçoes:");
  168.     for(new i = 0; i < max_players; i++)
  169.     {
  170.         if(faction[i][Ativo] == 0) continue;
  171.         format(_string, 128, "Nome: %s ID:", GetFactionName(i), i);
  172.         SendClientMessage(playerid, cor_sucesso, _string);
  173.     }
  174.     return 1;
  175. }
  176.  
  177. command(faccao, playerid, params [])
  178. {
  179.     new _string[128], subcmd[32], id;
  180.     if(sscanf(params, "s[32]I(-1)", subcmd, id))
  181.     {
  182.         SendClientMessage(playerid, cor_sucesso, "[opcoes]");
  183.         SendClientMessage(playerid, cor_erro, "[subcomandos] criar");
  184.         SendClientMessage(playerid, cor_erro, "[subcomandos] apagar [id]");
  185.         return 1;
  186.     }
  187.     if(!strcmp(subcmd, "criar", true))
  188.     {
  189.         if(!IsPlayerAdmin(playerid)) return 1;
  190.         new Y; Y = max_faction+1;
  191.         for(new X = 0; X < max_faction; X++)
  192.         {
  193.             if(X == 0) continue;
  194.             if(faction[X][Ativo] == 1) continue;
  195.             Y = X;
  196.             break;
  197.         }
  198.         if(Y > max_faction) return SendClientMessage(playerid, cor_erro, "erro: o maximo de facções foi atingido.");
  199.  
  200.         faction[Y][Ativo] = 1;
  201.         faction[Y][Banco] = 50000;
  202.         format(faction[Y][Nome], 32, nome_da_faccao, Y);
  203.        
  204.         format(faction[Y][Cargo_1], 32, f_cargo_1);
  205.         format(faction[Y][Cargo_2], 32, f_cargo_2);
  206.         format(faction[Y][Cargo_3], 32, f_cargo_3);
  207.         format(faction[Y][Cargo_4], 32, f_cargo_4);
  208.         format(faction[Y][Cargo_5], 32, f_cargo_5);
  209.         format(faction[Y][Cargo_6], 32, f_cargo_6);
  210.         format(_string, 128, "admin: Você acaba de criar uma facção (id: %d, nome:%s).",Y, GetFactionName(Y));
  211.         SendClientMessage(playerid, cor_sucesso, _string);
  212.         SendClientMessage(playerid, cor_sucesso, "admin: Para você setar essa facção a um jogador use /darlider [id do jogador].");
  213.         SendClientMessage(playerid, cor_sucesso, "admin: Para você setar uma HQ para essa facção use /sethq [factionid] [tipo].");//v2
  214.  
  215.         new Local[128];
  216.         format(Local, 128, local_f, Y);
  217.         DOF2_CreateFile(Local);
  218.         DOF2_SetInt(Local, "ativo", 1);
  219.         DOF2_SetInt(Local, "banco", faction[Y][Banco]);
  220.         DOF2_SetString(Local, "Nome", faction[Y][Nome]);
  221.         DOF2_SetString(Local, "Cargo_1", faction[Y][Cargo_1]);
  222.         DOF2_SetString(Local, "Cargo_2", faction[Y][Cargo_2]);
  223.         DOF2_SetString(Local, "Cargo_3", faction[Y][Cargo_3]);
  224.         DOF2_SetString(Local, "Cargo_4", faction[Y][Cargo_4]);
  225.         DOF2_SetString(Local, "Cargo_5", faction[Y][Cargo_5]);
  226.         DOF2_SetString(Local, "Cargo_6", faction[Y][Cargo_6]);
  227.         DOF2_SaveFile();
  228.         return 1;
  229.     }
  230.     if(!strcmp(subcmd, "apagar", true))
  231.     {
  232.         faction[id][Ativo] = 0;
  233.         faction[id][Banco] = 0;
  234.         faction[id][Nome] = 0;
  235.        
  236.         faction[id][Cargo_1] = 0;
  237.         faction[id][Cargo_2] = 0;
  238.         faction[id][Cargo_3] = 0;
  239.         faction[id][Cargo_4] = 0;
  240.         faction[id][Cargo_5] = 0;
  241.         faction[id][Cargo_6] = 0;
  242.         format(_string, 128, local_f, id);
  243.         DOF2_RemoveFile(_string);
  244.         format(_string, 128, "admin: você apagou a facção %d.");
  245.         SendClientMessage(playerid, cor_sucesso, _string);
  246.         return 1;
  247.     }
  248.     return 1;
  249. }
  250.  
  251. command(darlider, playerid, params [])
  252. {
  253.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cor_erro, erro_admin);
  254.     new _string[128], jogador, faction_id;
  255.     if(sscanf(params, "ud", jogador, faction_id)) return SendClientMessage(playerid, cor_erro, "comando: darlider [id/nome] [factionid].");
  256.     if(!IsPlayerConnected(jogador)) return SendClientMessage(playerid, cor_erro, erro_id);
  257.     if(player[jogador][pfaction] > 0) return SendClientMessage(playerid, cor_erro, erro_faction);
  258.     if(player[jogador][pcargo] == 6) return SendClientMessage(playerid, cor_erro, "erro: esse jogador ja é um lider.");
  259.     player[jogador][pfaction] = faction_id;
  260.     player[jogador][pcargo] = 6;
  261.     format(_string, 128, "faction: %s (%d) recebeu um lider.", GetFactionName(faction_id), faction_id);
  262.     SendClientMessageToAll(cor_sucesso, _string);
  263.     SendClientMessageToAll(cor_sucesso, "faction: Veja o novo lider em /lideres.");
  264.     return 1;
  265. }
  266.  
  267. command(lider, playerid, params [])
  268. {
  269.     new _string[128];
  270.     new subcmd[32], id;
  271.     if(player[playerid][pcargo] < 6) return SendClientMessage(playerid, cor_erro, "faction: cargo insuficiente para completar a tarefa.");
  272.     if(sscanf(params, "s[32]I(-1)", subcmd, id))
  273.     {
  274.         SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  275.         SendClientMessage(playerid, cor_erro, "[subcomandos] convidar [id], promover [id], rebaixar [id]");
  276.         SendClientMessage(playerid, cor_erro, "[subcomandos] demitir [id], info (exibe informações para os membros)");
  277.         SendClientMessage(playerid, cor_erro, "[outros] você ainda pode fazer outras alterações como os nomes dos cargos e o da facção;");
  278.         SendClientMessage(playerid, cor_erro, "[outros] para que você possa fazer ediçoes use /editarfaccao.");
  279.         return 1;
  280.     }
  281.     if(!strcmp(subcmd, "convidar", true))
  282.     {
  283.         if(id == -1)
  284.         {
  285.             SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  286.             SendClientMessage(playerid, cor_erro, "[subcomandos] convidar [id], promover [id], rebaixar [id]");
  287.             SendClientMessage(playerid, cor_erro, "[subcomandos] demitir [id], info (exibe informações para os membros)");
  288.             SendClientMessage(playerid, cor_erro, "[outros] você ainda pode fazer outras alterações como os nomes dos cargos e o da facção;");
  289.             SendClientMessage(playerid, cor_erro, "[outros] para que você possa fazer ediçoes use /editarfaccao.");
  290.             return 1;
  291.         }
  292.         if(!IsPlayerConnected(id)) return 1;
  293.         if(player[playerid][pfaction] != player[id][pfaction]) return 1;
  294.         new fac = player[playerid][pfaction];
  295.         convidado[id][cativo] = 1;
  296.         convidado[id][cfaction] = player[playerid][pfaction];
  297.        
  298.         format(_string, 128, "Você enviou um convite de sua facção para %s.", GetName(id));
  299.         SendClientMessage(playerid, -1, _string);
  300.         format(_string, 128, "Você foi convidado para participar da facção %s por %s.", GetFactionName(fac), GetName(playerid));
  301.         SendClientMessage(playerid, -1, _string);
  302.         return 1;
  303.     }
  304.     if(!strcmp(subcmd, "demitir", true))
  305.     {
  306.         if(id == -1)
  307.         {
  308.             SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  309.             SendClientMessage(playerid, cor_erro, "[subcomandos] convidar [id], promover [id], rebaixar [id]");
  310.             SendClientMessage(playerid, cor_erro, "[subcomandos] demitir [id], info (exibe informações para os membros)");
  311.             SendClientMessage(playerid, cor_erro, "[outros] você ainda pode fazer outras alterações como os nomes dos cargos e o da facção;");
  312.             SendClientMessage(playerid, cor_erro, "[outros] para que você possa fazer ediçoes use /editarfaccao.");
  313.             return 1;
  314.         }
  315.         if(!IsPlayerConnected(id)) return 1;
  316.         if(player[playerid][pfaction] != player[id][pfaction]) return 1;
  317.         format(_string, 128, "O membro %s foi demitido.", GetName(id));
  318.         SendFactionMessage(player[id][pfaction], cor_erro, _string);
  319.         player[id][pfaction] = 0;
  320.         player[id][pcargo] = 0;
  321.         return 1;
  322.     }
  323.     if(!strcmp(subcmd, "promover", true))
  324.     {
  325.         if(id == -1)
  326.         {
  327.             SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  328.             SendClientMessage(playerid, cor_erro, "[subcomandos] convidar [id], promover [id], rebaixar [id]");
  329.             SendClientMessage(playerid, cor_erro, "[subcomandos] demitir [id], info (exibe informações para os membros)");
  330.             SendClientMessage(playerid, cor_erro, "[outros] você ainda pode fazer outras alterações como os nomes dos cargos e o da facção;");
  331.             SendClientMessage(playerid, cor_erro, "[outros] para que você possa fazer ediçoes use /editarfaccao.");
  332.             return 1;
  333.         }
  334.         if(!IsPlayerConnected(id)) return 1;
  335.         if(player[playerid][pfaction] != player[id][pfaction]) return 1;
  336.         if(player[id][pcargo] == 6) return SendClientMessage(playerid, -1, "Esse membro ja possue o cargo maximo.");
  337.         format(_string, 128, "O membro %s foi promovido.", GetName(id));
  338.         SendFactionMessage(player[id][pfaction], -1, _string);
  339.         format(_string, 128, "Cargo: %d.", player[id][pcargo]);
  340.         SendFactionMessage(player[id][pfaction], -1, _string);
  341.         player[id][pcargo]++;
  342.         return 1;
  343.     }
  344.     if(!strcmp(subcmd, "rebaixar", true))
  345.     {
  346.         if(id == -1)
  347.         {
  348.             SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  349.             SendClientMessage(playerid, cor_erro, "[subcomandos] convidar [id], promover [id], rebaixar [id]");
  350.             SendClientMessage(playerid, cor_erro, "[subcomandos] demitir [id], info (exibe informações para os membros)");
  351.             SendClientMessage(playerid, cor_erro, "[outros] você ainda pode fazer outras alterações como os nomes dos cargos e o da facção;");
  352.             SendClientMessage(playerid, cor_erro, "[outros] para que você possa fazer ediçoes use /editarfaccao.");
  353.             return 1;
  354.         }
  355.         if(!IsPlayerConnected(id)) return 1;
  356.         if(player[playerid][pfaction] != player[id][pfaction]) return 1;
  357.         if(player[id][pcargo] == 1) return SendClientMessage(playerid, cor_erro, "Esse membro ja possue o menor cargo use /lider demitir [id].");
  358.         format(_string, 128, "O membro %s foi rebaixado.", GetName(id));
  359.         SendFactionMessage(player[id][pfaction], cor_erro, _string);
  360.         format(_string, 128, "Cargo: %d." ,player[id][pcargo]--);
  361.         SendFactionMessage(player[id][pfaction], -1, _string);
  362.         player[id][pcargo]--;
  363.         return 1;
  364.     }
  365.     if(!strcmp(subcmd, "info", true))
  366.     {
  367.         new minhafac = player[playerid][pfaction];
  368.         format(_string, 128, "Nome da facção: %s", GetFactionName(minhafac));
  369.         SendClientMessage(playerid, cor_sucesso, _string);//
  370. //      format(_string, 128, "Tipo da facção: %d", faction[minhafac][Tipo]); V2.0
  371. //      SendClientMessage(playerid, cor_sucesso, _string);
  372.         format(_string, 128, "Cofre da facção: %d", faction[minhafac][Banco]);
  373.         SendClientMessage(playerid, cor_sucesso, _string);//
  374.         format(_string, 128, "Cargo 1: %s", faction[minhafac][Cargo_1]);
  375.         SendClientMessage(playerid, cor_sucesso, _string);//
  376.         format(_string, 128, "Cargo 2: %s", faction[minhafac][Cargo_2]);
  377.         SendClientMessage(playerid, cor_sucesso, _string);//
  378.         format(_string, 128, "Cargo 3: %s", faction[minhafac][Cargo_3]);
  379.         SendClientMessage(playerid, cor_sucesso, _string);//
  380.         format(_string, 128, "Cargo 4: %s", faction[minhafac][Cargo_4]);
  381.         SendClientMessage(playerid, cor_sucesso, _string);//
  382.         format(_string, 128, "Cargo 5: %s", faction[minhafac][Cargo_5]);
  383.         SendClientMessage(playerid, cor_sucesso, _string);//
  384.         format(_string, 128, "Cargo 6: %s", faction[minhafac][Cargo_6]);
  385.         SendClientMessage(playerid, cor_sucesso, _string);//
  386.     }
  387.     return 1;
  388. }
  389.  
  390. command(editarfaccao, playerid, params [])
  391. {
  392.     new _string[128], subcmd[32], id, nome[32];
  393.     new faction_id = player[playerid][pfaction];
  394.     if(player[playerid][pcargo] < 6) return SendClientMessage(playerid, cor_erro, "faction: cargo insuficiente para completar a tarefa.");
  395.     if(sscanf(params, "s[32]sI(-1)", subcmd, nome, id))
  396.     {
  397.         SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  398.         SendClientMessage(playerid, cor_erro, "[subcomandos] cargo [nome] [cargo 1-6].");
  399.         SendClientMessage(playerid, cor_erro, "[subcomandos] nome [nome].");
  400.         SendClientMessage(playerid, cor_erro, "[exemplo] /editarfaccao cargo Insider 1 (seta o nome insider para o cargo 1).");
  401.         SendClientMessage(playerid, cor_erro, "[exemplo] /editarfaccao nome Riffas. (seta o nome Riffas para a facção).");
  402.         SendClientMessage(playerid, cor_erro, "[aviso] caso voce use espaços no nome da facção como Los Vagos, no lugar de espaço use ( _ ).");
  403.         SendClientMessage(playerid, cor_erro, "[exemplo]/editarfaccao Los_Vagos (o simbolo _ não aparecera).");
  404.         SendClientMessage(playerid, cor_erro, "[aviso] use no maximo 32 caracteres.");
  405.         return 1;
  406.     }
  407.     if(!strcmp(subcmd, "cargo", true))
  408.     {
  409.         if(id == -1)
  410.         {
  411.             SendClientMessage(playerid, cor_erro, "________________________[Oções]________________________");
  412.             SendClientMessage(playerid, cor_erro, "[subcomandos] cargo [cargo].");
  413.             SendClientMessage(playerid, cor_erro, "[subcomandos] nome [nome].");
  414.             SendClientMessage(playerid, cor_erro, "[aviso] use no maximo 32 caracteres.");
  415.         }
  416.         format(_string, sizeof(_string), local_f, faction_id);
  417.         switch(id)
  418.         {
  419.             case 1:
  420.                 format(faction[faction_id][Cargo_1], 32, "%s", nome),
  421.                 DOF2_SetString(_string, "Cargo_1", faction[faction_id][Cargo_1]),
  422.                 DOF2_SaveFile();
  423.             case 2:
  424.                 format(faction[faction_id][Cargo_2], 32, "%s", nome),
  425.                 DOF2_SetString(_string, "Cargo_2", faction[faction_id][Cargo_2]),
  426.                 DOF2_SaveFile();
  427.             case 3:
  428.                 format(faction[faction_id][Cargo_3], 32, "%s", nome),
  429.                 DOF2_SetString(_string, "Cargo_3", faction[faction_id][Cargo_3]),
  430.                 DOF2_SaveFile();
  431.             case 4:
  432.                 format(faction[faction_id][Cargo_4], 32, "%s", nome),
  433.                 DOF2_SetString(_string, "Cargo_4", faction[faction_id][Cargo_4]),
  434.                 DOF2_SaveFile();
  435.             case 5:
  436.                 format(faction[faction_id][Cargo_5], 32, "%s", nome),
  437.                 DOF2_SetString(_string, "Cargo_5", faction[faction_id][Cargo_5]),
  438.                 DOF2_SaveFile();
  439.             case 6:
  440.                 format(faction[faction_id][Cargo_6], 32, "%s", nome),
  441.                 DOF2_SetString(_string, "Cargo_6", faction[faction_id][Cargo_6]),
  442.                 DOF2_SaveFile();
  443.             case 7 .. 999: return SendClientMessage(playerid, cor_erro, "faction: cargos de 1 a 6.");
  444.         }
  445.         format(_string, 128, "faction: você alterou o cargo: %d para: %s.", id, nome);
  446.         SendClientMessage(playerid, cor_sucesso, _string);
  447.         return 1;
  448.     }
  449.     if(!strcmp(subcmd, "nome", true))
  450.     {
  451.         new HeadID;
  452.         format(faction[faction_id][Nome], 32, "%s", nome);
  453.         format(_string, 128, "faction: você alterou o nome da faccao para: %s.", nome);
  454.         SendClientMessage(playerid, cor_sucesso, _string);
  455.         format(_string, sizeof(_string), local_f, faction_id);
  456.         DOF2_SetString(_string, "Nome", faction[faction_id][Nome]);
  457.         DOF2_SaveFile();
  458.  
  459.         Delete3DTextLabel(HQ[HeadID][Label][0]);
  460.         Delete3DTextLabel(HQ[HeadID][Label][1]);
  461.        
  462.         HeadID = faction[faction_id][HeadQ];
  463.         format(_string, 128, "Faction: %s\nID: %d\nEntrada", GetFactionName(HQ[HeadID][factionid]), HeadID);
  464.         HQ[HeadID][Label][0] = Create3DTextLabel(_string, -1, HQ[HeadID][x], HQ[HeadID][y], HQ[HeadID][z]-0.2, 5.0, 0);
  465.         format(_string, 128, "Faction: %s\nID: %d\nSaida", GetFactionName(HQ[HeadID][factionid]), HeadID);
  466.         HQ[HeadID][Label][1] = Create3DTextLabel(_string, -1, HQ[HeadID][intx], HQ[HeadID][inty], HQ[HeadID][intz]-0.2, 5.0, HQ[HeadID][World]);
  467.         return 1;
  468.     }
  469.     return 1;
  470. }
  471.  
  472. command(editarhq, playerid, params [])
  473. {
  474.     if(InHQ == true) return 1;
  475.     new faction_id, hq_id, subcmd[32], _string[128];
  476.     if(player[playerid][pcargo] < 6) return SendClientMessage(playerid, cor_erro, "faction: cargo insuficiente para completar a tarefa.");
  477.     if(sscanf(params, "s[32]", subcmd))
  478.     {
  479.         SendClientMessage(playerid, cor_erro, "[opcoes]");
  480.         SendClientMessage(playerid, cor_erro, "[subcomandos] mover.");
  481.         SendClientMessage(playerid, cor_sucesso, "[aviso] ao digitar '/editarhq mover' a entrada do HQ sera posta em sua posição.");
  482.         return 1;
  483.     }
  484.     if(!strcmp(subcmd, "nome", true))
  485.     {
  486.         new Float:mX, Float:mY, Float:mZ;
  487.         GetPlayerPos(playerid, mX, mY, mZ);
  488.  
  489.         faction_id = player[playerid][pfaction];
  490.         hq_id = faction[faction_id][HeadQ];
  491.         HQ[hq_id][x] = mX, HQ[hq_id][x] = mY, HQ[hq_id][x] = mZ;
  492.  
  493.         new Local[128];
  494.         format(Local, 128, local_h, hq_id);
  495.         DOF2_SetFloat(Local, "x", HQ[hq_id][x]);
  496.         DOF2_SetFloat(Local, "y", HQ[hq_id][y]);
  497.         DOF2_SetFloat(Local, "z", HQ[hq_id][z]);
  498.         DOF2_SaveFile();
  499.  
  500.         Delete3DTextLabel(HQ[hq_id][Label][0]);
  501.         Delete3DTextLabel(HQ[hq_id][Label][1]);
  502.         DestroyPickup(HQ[hq_id][Pickup][0]);
  503.         DestroyPickup(HQ[hq_id][Pickup][1]);
  504.        
  505.         HQ[hq_id][Pickup][0] =  CreatePickup(19198, 1, HQ[hq_id][x], HQ[hq_id][y], HQ[hq_id][z]+0.2, 0);
  506.         HQ[hq_id][Pickup][1] =  CreatePickup(19198, 1, HQ[hq_id][intx], HQ[hq_id][inty], HQ[hq_id][intz]+0.2, HQ[hq_id][World]);
  507.  
  508.         format(_string, 128, "Faction: %s\nID: %d\nEntrada", GetFactionName(HQ[hq_id][factionid]), hq_id);
  509.         HQ[hq_id][Label][0] = Create3DTextLabel(_string, -1, HQ[hq_id][x], HQ[hq_id][y], HQ[hq_id][z]-0.2, 5.0, 0);
  510.         format(_string, 128, "Faction: %s\nID: %d\nSaida", GetFactionName(HQ[hq_id][factionid]), hq_id);
  511.         HQ[hq_id][Label][1] = Create3DTextLabel(_string, -1, HQ[hq_id][intx], HQ[hq_id][inty], HQ[hq_id][intz]-0.2, 5.0, HQ[hq_id][World]);
  512.         return 1;
  513.     }
  514.     return 1;
  515. }
  516.  
  517. command(radio, playerid, params [])
  518. {
  519.     new texto[200], _string[200];
  520.     if(sscanf(params, "s", texto)) return SendClientMessage(playerid, cor_erro, "erro: comando: /radio [texto]");
  521.     if(player[playerid][pfaction] == 0) return SendClientMessage(playerid, cor_erro, "erro: você não possue uma facção.");
  522.     format(_string, 200, "R: %s: %s: %s.", GetRankName(playerid), GetName(playerid), texto);
  523.     SendFactionMessage(player[playerid][pfaction], -1, _string);
  524.     return 1;
  525. }
  526.  
  527. command(ingressar, playerid, params [])
  528. {
  529.     new _string[128];
  530.     if(convidado[playerid][cativo] == 0) return SendClientMessage(playerid, -1, "Você ainda não foi convidado por nenhuma facção");
  531.     player[playerid][pfaction] = convidado[playerid][cfaction];
  532.     player[playerid][pcargo] = 1;
  533.     SendClientMessage(playerid, -1, "Bem vindo, tenha um bom jogo.");
  534.     format(_string, 128, "O jogador %s se juntou a facção.", GetName(playerid));
  535.     SendFactionMessage(player[playerid][pfaction], -1, _string);
  536.     convidado[playerid][cativo] = 0;
  537.     convidado[playerid][cfaction] = 0;
  538.     return 1;
  539. }
  540.  
  541. //hq
  542. command(sethq, playerid, params [])
  543. {
  544.     new Local[128];
  545.     new a = max_HQ+1, _string[128];
  546.     new Float:mX, Float:mY, Float:mZ, _factionid, interior;
  547.     if(sscanf(params, "d", _factionid/*, interior*/)) return SendClientMessage(playerid, -1, "comando: sethq: [factionid]");
  548.     for(new i = 0; i < max_HQ; i++)
  549.     {
  550.         if(i == 0) continue;
  551.         if(HQ[i][ativo] == 1) continue;
  552.         a = i;
  553.     }
  554.     if(a > max_HQ) return 1;
  555.     GetPlayerPos(playerid, mX, mY, mZ);
  556.     HQ[a][ativo] = 1;
  557.     HQ[a][tipo] = interior;
  558.     HQ[a][factionid] = _factionid;
  559.     HQ[a][x] = mX;
  560.     HQ[a][y] = mY;
  561.     HQ[a][z] = mZ;
  562.     HQ[a][Interior] = 0;
  563.     HQ[a][World] = a;
  564.     faction[_factionid][HeadQ] = a;
  565.     switch(interior)
  566.     {
  567.         case 1:
  568.         HQ[a][intx] = 1901.4934, HQ[a][inty] = -1853.3789, HQ[a][intz] = 1501.5160;
  569.         case 2:
  570.         HQ[a][intx] = 1901.4934, HQ[a][inty] = -1853.3789, HQ[a][intz] = 1501.5160;
  571.     }
  572.     HQ[a][Pickup][0] =  CreatePickup(19198, 1, HQ[a][x], HQ[a][y], HQ[a][z]+0.2, 0);
  573.     HQ[a][Pickup][1] =  CreatePickup(19198, 1, HQ[a][intx], HQ[a][inty], HQ[a][intz]+0.2, HQ[a][World]);
  574.  
  575.     format(_string, 128, "Faction: %s\nID: %d\nEntrada", GetFactionName(HQ[a][factionid]), a);
  576.     HQ[a][Label][0] = Create3DTextLabel(_string, -1, HQ[a][x], HQ[a][y], HQ[a][z]-0.2, 5.0, 0);
  577.     format(_string, 128, "Faction: %s\nID: %d\nSaida", GetFactionName(HQ[a][factionid]), a);
  578.     HQ[a][Label][1] = Create3DTextLabel(_string, -1, HQ[a][intx], HQ[a][inty], HQ[a][intz]-0.2, 5.0, HQ[a][World]);
  579.  
  580.     format(Local, 128, local_h, a);
  581.     DOF2_CreateFile(Local);
  582.     DOF2_SetInt(Local, "ativo", 1);
  583.     DOF2_SetInt(Local, "tipo", interior);
  584.     DOF2_SetInt(Local, "factionid", _factionid);
  585.     DOF2_SetFloat(Local, "x", HQ[a][x]);
  586.     DOF2_SetFloat(Local, "y", HQ[a][y]);
  587.     DOF2_SetFloat(Local, "z", HQ[a][z]);
  588.     DOF2_SetFloat(Local, "intx", HQ[a][intx]);
  589.     DOF2_SetFloat(Local, "inty", HQ[a][inty]);
  590.     DOF2_SetFloat(Local, "intz", HQ[a][intz]);
  591.     DOF2_SetInt(Local, "interior", interior);
  592.     DOF2_SetInt(Local, "world", a);
  593.     format(Local, 128, local_f, _factionid);
  594.     DOF2_SetInt(Local, "HQ", a);
  595.     DOF2_SaveFile();
  596.     return 1;
  597. }
  598.  
  599. command(entrar, playerid, params [])
  600. {
  601.     new H = max_HQ+1;
  602.     for(new a = 0; a < max_HQ; a++)
  603.     {
  604.         if(IsPlayerInRangeOfPoint(playerid, 1.0, HQ[a][x], HQ[a][y], HQ[a][z]))
  605.         {
  606.             H = a;
  607.             break;
  608.         }
  609.     }
  610.     if(H > max_HQ) return 1;
  611.     if(player[playerid][pfaction] != HQ[H][factionid]) return SendClientMessage(playerid, cor_erro, "faction: você não é dessa facção.");
  612.     SetPlayerInterior(playerid, HQ[H][Interior]);
  613.     SetPlayerVirtualWorld(playerid, HQ[H][World]);
  614.     SetPlayerPos(playerid, HQ[H][intx], HQ[H][inty], HQ[H][intz]+0.1);
  615.     InHQ = true;
  616.     return 1;
  617. }
  618.  
  619. CMD:sair(playerid)
  620. {
  621.     for(new i = 0; i < max_HQ; i++)
  622.     {
  623.         if(IsPlayerInRangeOfPoint(playerid, 2.0, HQ[i][intx], HQ[i][inty], HQ[i][intz]))
  624.         {
  625.             if(GetPlayerVirtualWorld(playerid) == HQ[i][World])
  626.             {
  627.                 SetPlayerPos(playerid, HQ[i][x], HQ[i][y], HQ[i][z]);
  628.                 SetPlayerInterior(playerid, 0);
  629.                 SetPlayerVirtualWorld(playerid, 0);
  630.                 InHQ = false;
  631.             }
  632.         }
  633.     }
  634.     return 1;
  635. }
  636.  
  637. stock GetFactionName(fac)
  638. {
  639.     new fnome[32];
  640.     format(fnome, 32, "%s", faction[fac][Nome]);
  641.     for(new i = 0; i < 32; i++)
  642.     {
  643.         if(fnome[i] == '_') fnome[i] = ' ';
  644.     }
  645.     return fnome;
  646. }
  647.  
  648. stock GetName(playerid)
  649. {
  650.     new nome[MAX_PLAYER_NAME];
  651.     GetPlayerName(playerid, nome, sizeof(nome));
  652.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  653.     {
  654.         if(nome[i] == '_') nome[i] = ' ';
  655.     }
  656.     return nome;
  657. }
  658.  
  659. stock SendFactionMessage(fac, color, message [])
  660. {
  661.     for(new i = 0; i < max_players; i++)
  662.     {
  663.         if(player[i][pfaction] == fac)
  664.         {
  665.             SendClientMessage(i, color, message);
  666.         }
  667.     }
  668.     return 1;
  669. }
  670.  
  671. stock GetRankName(playerid)
  672. {
  673.     new _string[32];
  674.     new faction_id = player[playerid][pfaction];
  675.     if(player[playerid][pcargo] == 1)
  676.     {
  677.         format(_string, 32, faction[faction_id][Cargo_1]);
  678.     }
  679.     if(player[playerid][pcargo] == 2)
  680.     {
  681.         format(_string, 32, faction[faction_id][Cargo_2]);
  682.     }
  683.     if(player[playerid][pcargo] == 3)
  684.     {
  685.         format(_string, 32, faction[faction_id][Cargo_3]);
  686.     }
  687.     if(player[playerid][pcargo] == 4)
  688.     {
  689.         format(_string, 32, faction[faction_id][Cargo_4]);
  690.     }
  691.     if(player[playerid][pcargo] == 5)
  692.     {
  693.         format(_string, 32, faction[faction_id][Cargo_5]);
  694.     }
  695.     if(player[playerid][pcargo] == 6)
  696.     {
  697.         format(_string, 32, faction[faction_id][Cargo_6]);
  698.     }
  699.     return _string;
  700. }
  701.  
  702. stock LoadFaction()
  703. {
  704.     new Local[128];
  705.     for(new i; i < max_faction; i++)
  706.     {
  707.         format(Local, sizeof(Local), local_f, i);
  708.         if(DOF2_FileExists(Local))
  709.         {
  710.             faction[i][Ativo] = DOF2_GetInt(Local, "ativo");
  711.             faction[i][Banco] = DOF2_GetInt(Local, "banco");
  712.             format(faction[i][Nome], 32, DOF2_GetString(Local, "Nome"));
  713.             format(faction[i][Cargo_1], 32, DOF2_GetString(Local, "Cargo_1"));
  714.             format(faction[i][Cargo_2], 32, DOF2_GetString(Local, "Cargo_2"));
  715.             format(faction[i][Cargo_3], 32, DOF2_GetString(Local, "Cargo_3"));
  716.             format(faction[i][Cargo_4], 32, DOF2_GetString(Local, "Cargo_4"));
  717.             format(faction[i][Cargo_5], 32, DOF2_GetString(Local, "Cargo_5"));
  718.             format(faction[i][Cargo_6], 32, DOF2_GetString(Local, "Cargo_6"));
  719.         }
  720.     }
  721.     return 1;
  722. }
  723.  
  724. stock LoadHQ()
  725. {
  726.     new Local[128], _string[128];
  727.     for(new i; i < max_HQ; i++)
  728.     {
  729.         format(Local, sizeof(Local), local_h, i);
  730.         if(DOF2_FileExists(Local))
  731.         {
  732.             HQ[i][ativo] = DOF2_GetInt(Local, "ativo");
  733.             HQ[i][factionid] = DOF2_GetInt(Local, "factionid");
  734.             HQ[i][x] = DOF2_GetFloat(Local, "x");
  735.             HQ[i][y] = DOF2_GetFloat(Local, "y");
  736.             HQ[i][z] = DOF2_GetFloat(Local, "z");
  737.             HQ[i][intx] = DOF2_GetFloat(Local, "intx");
  738.             HQ[i][inty] = DOF2_GetFloat(Local, "inty");
  739.             HQ[i][intz] = DOF2_GetFloat(Local, "intz");
  740.             HQ[i][Interior] = DOF2_GetInt(Local, "interior");
  741.             HQ[i][World] = DOF2_GetInt(Local, "world");
  742.  
  743.             HQ[i][Pickup][0] =  CreatePickup(19198, 1, HQ[i][x], HQ[i][y], HQ[i][z]+0.2, 0);
  744.             HQ[i][Pickup][1] =  CreatePickup(19198, 1, HQ[i][intx], HQ[i][inty], HQ[i][intz]+0.2, HQ[i][World]);
  745.  
  746.             format(_string, 128, "Faction: %s\nID: %d\nEntrada", GetFactionName(HQ[i][factionid]), i);
  747.             HQ[i][Label][0] = Create3DTextLabel(_string, -1, HQ[i][x], HQ[i][y], HQ[i][z]-0.2, 5.0, 0);
  748.             format(_string, 128, "Faction: %s\nID: %d\nSaida", GetFactionName(HQ[i][factionid]), i);
  749.             HQ[i][Label][1] = Create3DTextLabel(_string, -1, HQ[i][intx], HQ[i][inty], HQ[i][intz]-0.2, 5.0, HQ[i][World]);
  750.         }
  751.     }
  752.     return 1;
  753. }
  754.  
  755. stock LoadPlayer(playerid)
  756. {
  757.     new Local[128];
  758.     format(Local, sizeof(Local), local_p, GetName(playerid));
  759.     if(DOF2_FileExists(Local))
  760.     {
  761.         player[playerid][pfaction] = DOF2_GetInt(Local, "pfaction");
  762.         player[playerid][pcargo] = DOF2_GetInt(Local, "pcargo");
  763.  
  764.         convidado[playerid][cativo] = DOF2_GetInt(Local, "cativo");
  765.         convidado[playerid][cfaction] = DOF2_GetInt(Local, "cfaction");
  766.     }
  767.     else
  768.     {
  769.         format(Local, sizeof(Local), local_p, GetName(playerid));
  770.         DOF2_CreateFile(Local);
  771.         DOF2_SetInt(Local, "pfaction", 0);
  772.         DOF2_SetInt(Local, "pcargo", 0);
  773.  
  774.         DOF2_SetInt(Local, "cativo", 0);
  775.         DOF2_SetInt(Local, "cfaction", 0);
  776.     }
  777.     return 1;
  778. }
  779.  
  780. stock SavePlayer(playerid)
  781. {
  782.     new Local[128];
  783.     format(Local, sizeof(Local), local_p, GetName(playerid));
  784.     DOF2_SetInt(Local, "pfaction", player[playerid][pfaction]);
  785.     DOF2_SetInt(Local, "pcargo", player[playerid][pcargo]);
  786.  
  787.     DOF2_SetInt(Local, "cativo", convidado[playerid][cativo]);
  788.     DOF2_SetInt(Local, "cfaction", convidado[playerid][cfaction]);
  789.     DOF2_SaveFile();
  790.     return 1;
  791. }
  792.  
  793. stock CreateInt()
  794. {
  795.     //int by: Killerbillty - [url]http://forum.sa-mp.com/member.php?u=201864;[/url]
  796.     CreateDynamicObject(19448, 1896.77, -1850.19, 1500.43,   0.00, 90.00, 0.00);
  797.     CreateDynamicObject(19448, 1896.77, -1859.82, 1500.43,   0.00, 90.00, 0.00);
  798.     CreateDynamicObject(19448, 1900.27, -1850.19, 1500.43,   0.00, 90.00, 0.00);
  799.     CreateDynamicObject(19448, 1900.27, -1859.82, 1500.43,   0.00, 90.00, 0.00);
  800.     CreateDynamicObject(19463, 1895.11, -1850.19, 1502.26,   0.00, 0.00, 0.00);
  801.     CreateDynamicObject(19463, 1899.85, -1847.34, 1502.26,   0.00, 0.00, 90.00);
  802.     CreateDynamicObject(19463, 1901.93, -1850.19, 1502.26,   0.00, 0.00, 0.00);
  803.     CreateDynamicObject(19371, 1901.93, -1856.61, 1502.26,   0.00, 0.00, 0.00);
  804.     CreateDynamicObject(19463, 1893.95, -1854.92, 1502.26,   0.00, 0.00, 90.00);
  805.     CreateDynamicObject(19398, 1898.68, -1856.61, 1502.26,   0.00, 0.00, 0.00);
  806.     CreateDynamicObject(19398, 1900.32, -1858.12, 1502.26,   0.00, 0.00, 90.00);
  807.     CreateDynamicObject(19395, 1898.66, -1856.60, 1502.26,   0.00, 0.00, 0.00);
  808.     CreateDynamicObject(19367, 1896.98, -1854.93, 1502.26,   0.00, 0.00, 90.00);
  809.     CreateDynamicObject(19367, 1896.98, -1858.12, 1502.26,   0.00, 0.00, 90.00);
  810.     CreateDynamicObject(1491, 1898.68, -1857.34, 1500.50,   0.00, 0.00, 90.00);
  811.     CreateDynamicObject(1491, 1899.53, -1858.14, 1500.50,   0.00, 0.00, 0.00);
  812.     CreateDynamicObject(19367, 1895.32, -1856.60, 1502.26,   0.00, 0.00, 0.00);
  813.     CreateDynamicObject(19397, 1900.31, -1858.14, 1502.26,   0.00, 0.00, 90.00);
  814.     CreateDynamicObject(19461, 1893.89, -1858.14, 1502.26,   0.00, 0.00, 90.00);
  815.     CreateDynamicObject(19461, 1895.11, -1863.04, 1502.26,   0.00, 0.00, 0.00);
  816.     CreateDynamicObject(19461, 1901.93, -1863.04, 1502.26,   0.00, 0.00, 0.00);
  817.     CreateDynamicObject(19459, 1898.06, -1864.54, 1502.26,   0.00, 0.00, 90.00);
  818.     CreateDynamicObject(1535, 1901.91, -1854.16, 1500.49,   0.00, 0.00, 90.00);
  819.     CreateDynamicObject(19380, 1900.25, -1850.22, 1503.94,   0.00, 90.00, 0.00);
  820.     CreateDynamicObject(19380, 1900.25, -1859.85, 1503.94,   0.00, 90.00, 0.00);
  821.     CreateDynamicObject(2074, 1898.91, -1851.15, 1503.62,   0.00, 0.00, 0.00);
  822.     CreateDynamicObject(2074, 1898.61, -1861.30, 1503.62,   0.00, 0.00, 0.00);
  823.     CreateDynamicObject(3034, 1895.20, -1860.85, 1502.49,   0.00, 0.00, 90.00);
  824.     CreateDynamicObject(14384, 1898.65, -1851.03, 1502.01,   0.00, 0.00, 90.00);
  825.     CreateDynamicObject(19426, 1895.24, -1853.05, 1501.52,   0.00, 90.00, 90.00);
  826.     CreateDynamicObject(19426, 1895.24, -1848.49, 1501.52,   0.00, 90.00, 90.00);
  827.     CreateDynamicObject(19426, 1896.96, -1847.49, 1501.52,   0.00, 90.00, 0.00);
  828.     CreateDynamicObject(1647, 1896.55, -1854.38, 1501.44,   0.00, 0.00, 90.00);
  829.     CreateDynamicObject(19426, 1895.14, -1851.17, 1501.34,   0.00, 90.00, 90.00);
  830.     CreateDynamicObject(1626, 1898.16, -1847.96, 1501.71,   0.00, 0.00, 90.00);
  831.     CreateDynamicObject(2523, 1898.03, -1857.53, 1500.51,   0.00, 0.00, 180.00);
  832.     CreateDynamicObject(2528, 1895.92, -1857.22, 1500.51,   0.00, 0.00, 90.00);
  833.     CreateDynamicObject(2526, 1897.10, -1855.46, 1500.51,   0.00, 0.00, 180.00);
  834.     CreateDynamicObject(2740, 1896.98, -1856.55, 1503.71,   0.00, 0.00, 0.00);
  835.     CreateDynamicObject(2635, 1901.27, -1848.07, 1500.93,   0.00, 0.00, 0.00);
  836.     CreateDynamicObject(1722, 1901.49, -1849.36, 1500.51,   0.00, 0.00, 25.00);
  837.     CreateDynamicObject(1722, 1899.95, -1847.81, 1500.51,   0.00, 0.00, -100.00);
  838.     CreateDynamicObject(2831, 1901.16, -1848.22, 1501.36,   0.00, 0.00, 80.00);
  839.     CreateDynamicObject(2313, 1901.49, -1850.50, 1500.51,   0.00, 0.00, -90.00);
  840.     CreateDynamicObject(1781, 1901.82, -1851.18, 1501.02,   0.00, 0.00, -87.00);
  841.     CreateDynamicObject(1712, 1899.09, -1852.00, 1500.50,   0.00, 0.00, 90.00);
  842.     CreateDynamicObject(2830, 1895.66, -1850.62, 1501.43,   0.00, 0.00, 0.00);
  843.     CreateDynamicObject(2894, 1901.44, -1851.81, 1501.01,   0.00, 0.00, -95.00);
  844.     CreateDynamicObject(2258, 1901.83, -1850.94, 1502.73,   0.00, 0.00, -90.00);
  845.     CreateDynamicObject(2847, 1900.84, -1851.78, 1500.52,   0.00, 0.00, 90.00);
  846.     CreateDynamicObject(1742, 1901.96, -1855.45, 1500.51,   0.00, 0.00, -90.00);
  847.     CreateDynamicObject(2573, 1901.39, -1861.24, 1500.51,   0.00, 0.00, -90.00);
  848.     CreateDynamicObject(1794, 1898.67, -1861.44, 1500.51,   0.00, 0.00, 90.00);
  849.     CreateDynamicObject(2576, 1898.38, -1863.94, 1500.51,   0.00, 0.00, -180.00);
  850.     CreateDynamicObject(2817, 1899.89, -1861.48, 1500.51,   0.00, 0.00, 90.00);
  851.     CreateDynamicObject(14869, 1895.62, -1859.07, 1501.21,   0.00, 0.00, 180.00);
  852.     CreateDynamicObject(2238, 1895.34, -1859.64, 1501.77,   0.00, 0.00, 0.00);
  853.     CreateDynamicObject(19174, 1897.64, -1858.22, 1502.68,   0.00, 0.00, 0.00);
  854.     CreateDynamicObject(2844, 1896.45, -1857.28, 1500.52,   0.00, 0.00, 0.00);
  855.     CreateDynamicObject(2819, 1896.35, -1860.49, 1501.18,   0.00, 0.00, -90.00);
  856.     return 1;
  857. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement