Código:
//criado por ANDREX nao retire os creditos , voce voce so estara enganando a si propio
#include <a_samp>
#include <zcmd>
#include <dini>
#define DIALOG_NOME_TP 1000 //mude caso voce ja use essa numerwcao na gm para naodar conflito
#define DIALOG_LISTA_TP 1001
// Comando para criar teleporte
CMD:tele(playerid, params[]){
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,0x00FFFF,"[!] voce nao e um adminstrador");
ShowPlayerDialog(playerid, DIALOG_NOME_TP, DIALOG_STYLE_INPUT, "Criar Teleporte", "Digite o nome para o novo teleporte:", "Salvar", "Cancelar");
return 1;
}
// Comando para mostrar todos teleportes salvos
CMD:teleportes(playerid, params[]){
new File:handle, line[64], lista[1024] = "";
new count = 0;
new item[96];
handle = fopen("teleportes/lista.txt", io_read);
if(!handle) return SendClientMessage(playerid, -1, "Nenhum teleporte criado ainda.");
while(fread(handle, line)){
line[strlen(line)-1] = '\0'; // remove \n
// Limita a 120 teleportes no dialog
if(count >= 120) break;
count++;
format(item, sizeof(item), "%d. %s\n", count, line);
if(strlen(lista) + strlen(item) < sizeof(lista)){
strcat(lista, item, sizeof(lista));
}
else break;
}
fclose(handle);
if(count == 0) return SendClientMessage(playerid, -1, "Nenhum teleporte encontrado.");
ShowPlayerDialog(playerid, DIALOG_LISTA_TP, DIALOG_STYLE_LIST, "Teleportes Disponíveis", lista, "Ir", "Cancelar");
return 1;
}
// Manipula dialogs
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
if(dialogid == DIALOG_NOME_TP){
if(!response || isnull(inputtext)){
SendClientMessage(playerid, -1, "Criação de teleporte cancelada.");
return 1;
}
new file[64];
format(file, sizeof(file), "teleportes/%s.ini", inputtext);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
dini_Create(file);
dini_FloatSet(file, "X", x);
dini_FloatSet(file, "Y", y);
dini_FloatSet(file, "Z", z);
// Adicionar à lista.txt se ainda não existir
new listfile[] = "teleportes/lista.txt";
new File:check = fopen(listfile, io_read);
new exists = 0;
new line[64];
if(check){
while(fread(check, line)){
line[strlen(line)-1] = '\0';
if(strcmp(line, inputtext, true) == 0){
exists = 1;
break;
}
}
fclose(check);
}
if(!exists){
new File:add = fopen(listfile, io_append);
if(add){
fwrite(add, inputtext);
fwrite(add, "\n");
fclose(add);
}
}
new msg[64];
format(msg, sizeof(msg), "Teleporte '%s' criado com sucesso!", inputtext);
SendClientMessage(playerid, -1, msg);
return 1;
}
if(dialogid == DIALOG_LISTA_TP){
if(!response) return 1;
new name[64], file[64], line, File:handle;
handle = fopen("teleportes/lista.txt", io_read);
if(!handle) return SendClientMessage(playerid, 0x00FFFF, "[!]Erro ao ler a lista de teleportes.");
while(fread(handle, name)){
name[strlen(name)-1] = '\0'; // remove '\n'
if(line == listitem){
format(file, sizeof(file), "teleportes/%s.ini", name);
if(!fexist(file)){
SendClientMessage(playerid, -1, "Este teleporte não existe mais.");
fclose(handle);
return 1;
}
new Float:x = dini_Float(file, "X");
new Float:y = dini_Float(file, "Y");
new Float:z = dini_Float(file, "Z");
SetPlayerPos(playerid, x, y, z);
new msg[64];
format(msg, sizeof(msg), "Teleportado para '%s'.", name);
SendClientMessage(playerid, -1, msg);
break;
}
line++;
}
fclose(handle);
return 1;
}
return 0;
}
um comando simples para quando um jogador estiver logado na rcon usar /tele ele cria o nome do local onde ele quer e automaticamente é criado as coordenadas dentro de uma pasta chamada teleportes aí quando o player quiser apertar o nome /teleportes vai aparecer a lista de teleportes com o nome do que o player admin criou e ao ser clicado ele se teletransportar o local quem quiser adaptar e ao invés de usar a função nativa a SetPayerPos pode usar para ficar como SetPlayerCheckpoint assim se torna um GPS ao invés de um teleporte aí vocês que sabem espero que esse código ajuda alguma pessoa aí pois criei para meu servidor freeroam lembrando tudo fica salvo na pasta teleportes aoviniciar o servidor continuará tudo salvo usei a include Dini para salvar