Guest User

Filterscript Facções dinâmicas (Criador de organizações+HQ)

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