Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*||===========Creditos===========||
- || ||
- || Scripter: CH4øZ ||
- || Idea: Wheelmandts ||
- || ||
- || the_chaoz92@hotmail.com ||
- ||==============================||*/
- #include <a_samp>
- #include <YSI\y_ini>
- #include <sscanf2>
- #define MAX_TELEPORTS 1000
- //#define HELP//comment this line to disable help on cmds
- #define PATH "/TeleportsIG.sav"
- enum DD{
- bool:Exist=false,
- Float:PP[4],
- Int,
- Vw,
- wCar,
- Priv,
- Name[11],
- Owner[MAX_PLAYER_NAME],
- Frace[55]
- };
- new Tp[MAX_TELEPORTS][DD];
- new bool:Full = false;
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- public OnFilterScriptInit()
- {
- if(!fexist("/TeleportsIG.sav")){
- new File:Fhnd;
- Fhnd = fopen(PATH, io_write);
- if(Fhnd)fclose(Fhnd);
- else{
- print("Se produjo un error durante la creacion del archivo \"Teleports.sav\", y el filterscript no funcionara sin el mismo.");
- return CallLocalFunction("OnFilterScriptExit","");
- }
- }
- for(new i; i<MAX_TELEPORTS; i++)Tp[i][Name] = "a\0\0\0\0\0\0\0\0\0";
- INI_ParseFile(PATH, "LoadTeleports", .bPassTag=true);
- print("\n--------------------------------------");
- print(" In Game Teleport Maker v1.2.0 Loaded");
- return print("--------------------------------------\n");
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" In Game Teleport Maker v1.2.0 Unloaded");
- return print("--------------------------------------\n");
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(tir, 3, cmdtext);
- dcmd(tcrear, 6, cmdtext);
- dcmd(tlista, 6, cmdtext);
- dcmd(tborrar, 7, cmdtext);
- return 0;
- }
- dcmd_tcrear(playerid, params[]){
- if(Full)return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Ya no se pueden crear mas teleports.");
- new name[11], Opt[2], fr[55];
- if(sscanf(params, "s[11]D(0)D(0)S()[55]", name, Opt[0], Opt[1], fr)){
- SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tcrear {FFFF00}<nombre> {FFFFFF}(opcional){FFFF00}<auto> {FFFFFF}(opcional){FFFF00}<privado> {FFFFFF}(opcional){FFFF00}<mensaje>");
- #if defined HELP
- SendClientMessage(playerid, 0xFFFF00FF, "Parametros:");
- SendClientMessage(playerid, 0xFFFF00FF, " #Auto: {FFFFFF}permite el teleport con o sin auto ({00FF00}1{FFFFFF}={00FF00}si{FFFFFF}/{FF0000}0{FFFFFF}={FF0000}no).");
- SendClientMessage(playerid, 0xFFFF00FF, " #Privado: {FFFFFF}No figura en la lista del comando tlista({00FF00}1{FFFFFF}={00FF00}privado{FFFFFF}/{FF0000}0{FFFFFF}={FF0000}publico).");
- return SendClientMessage(playerid, 0xFFFF00FF, " #Mensaje: {FFFFFF}se enviara este mensaje cada vez q alguien llegue al teleport.");
- #else
- return 1;
- #endif
- }
- if(strlen(name) < 3)return SendClientMessage(playerid, 0xFF0000FF, "Error: El largo del nombre debe ser mayor a 3 caracteres.");
- for(new l; l<MAX_TELEPORTS; l++){
- if(!strcmp(Tp[l][Name], name, true) && Tp[l][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: El nombre ya ha sido utilizado.");
- else continue;
- }
- new i;
- for(i=0; i<=MAX_TELEPORTS; i++)if(!Tp[i][Exist])break;
- if(i==MAX_TELEPORTS){
- Full=true;
- if(Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Ya no se pueden crear mas teleports.");
- }
- new str[66];
- new INI:Fhnd;
- GetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- GetPlayerFacingAngle(playerid, Tp[i][PP][3]);
- Tp[i][Vw] = GetPlayerVirtualWorld(playerid);
- Tp[i][Int] = GetPlayerInterior(playerid);
- Fhnd = INI_Open(PATH);
- INI_SetTag(Fhnd, numstr(i));
- INI_WriteString(Fhnd, "Name", name);
- INI_WriteString(Fhnd, "Owner", pName(playerid));
- INI_WriteString(Fhnd, "Frace", fr);
- INI_WriteInt(Fhnd, "Car", Opt[0]);
- INI_WriteInt(Fhnd, "Priv", Opt[1]);
- INI_WriteFloat(Fhnd, "X", Tp[i][PP][0]);
- INI_WriteFloat(Fhnd, "Y", Tp[i][PP][1]);
- INI_WriteFloat(Fhnd, "Z", Tp[i][PP][2]);
- INI_WriteFloat(Fhnd, "A", Tp[i][PP][3]);
- INI_WriteInt(Fhnd, "vW", Tp[i][Vw]);
- INI_WriteInt(Fhnd, "Int", Tp[i][Int]);
- INI_Close(Fhnd);
- Tp[i][Exist] = true;
- Tp[i][Name] = name;
- Tp[i][Owner] = pName(playerid);
- Tp[i][Frace] = fr;
- Tp[i][wCar] = Opt[0];
- Tp[i][Priv] = Opt[1];
- format(str, sizeof(str), "Has creado un nuevo teleport, usa /ir \"%s\" para ir a el.", name);
- return SendClientMessage(playerid, 0xFFFF00FF, str);
- }
- dcmd_tir(playerid, params[]){
- if(!params[0] || strlen(params)>11)return SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tir <nombre>");
- new str[128], i;
- for(i=0; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], params, true))break;
- if(!Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: El teleport no existe.");
- if(!IsPlayerInAnyVehicle(playerid)){
- SetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- SetPlayerFacingAngle(playerid, Tp[i][PP][3]);
- SetPlayerInterior(playerid, Tp[i][Int]);
- SetPlayerVirtualWorld(playerid, Tp[i][Vw]);
- SetCameraBehindPlayer(playerid);
- }
- else{
- if(!Tp[i][wCar]){
- SetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- SetPlayerFacingAngle(playerid, Tp[i][PP][3]);
- SetPlayerInterior(playerid, Tp[i][Int]);
- SetPlayerVirtualWorld(playerid, Tp[i][Vw]);
- SetCameraBehindPlayer(playerid);
- }
- else{
- new Veh = GetPlayerVehicleID(playerid);
- SetVehiclePos(Veh, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- SetVehicleZAngle(Veh, Tp[i][PP][3]);
- PutPlayerInVehicle(playerid, Veh, 0);
- SetVehicleVirtualWorld(Veh, Tp[i][Vw]);
- LinkVehicleToInterior(Veh, Tp[i][Int]);
- SetCameraBehindPlayer(playerid);
- }
- }
- if(!strlen(Tp[i][Frace]))format(str, 128, "Has ido a \"%s\" creado por %s.", Tp[i][Name], Tp[i][Owner]);
- if(strlen(Tp[i][Frace])>1)format(str, 128, "\"%s\" por %s.", Tp[i][Frace], Tp[i][Owner]);
- return SendClientMessage(playerid, 0xFFFF00FF, str);
- }
- dcmd_tlista(playerid, params[]){
- #pragma unused params
- new str[128], count, X;
- for(new i; i<MAX_TELEPORTS; i++)if(Tp[i][Exist] && !Tp[i][Priv]){
- X++;
- count++;
- if(count == 1)format(str, 128, "%s", Tp[i][Name]);
- if(1 < count <= 5)format(str, 128, "%s - %s", str, Tp[i][Name]);
- if(count == 6){
- SendClientMessage(playerid, 0xFFFF00FF, str);
- count = 0;
- }
- }
- if(X && count)return SendClientMessage(playerid, 0xFFFF00FF, str);
- return SendClientMessage(playerid, 0xFFFFFFFF, "--No existen teleports--");
- }
- dcmd_tborrar(playerid, params[])
- {
- new name[11];
- if(sscanf(params, "s[11]", name))return SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tborrar <nombre>");
- new i;
- for(i=0; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], name, true))break;
- if(strcmp(Tp[i][Owner], pName(playerid), false) && !IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFF0000FF, "ERROR: No puedes eliminar el teleport");
- if(!Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: El teleport no existe.");
- DeleteTp(i);
- return SendClientMessage(playerid, 0x00FF00FF, "Server: Teleport borrado con exito.");
- }
- forward LoadTeleports(tag[], name[], value[]);
- public LoadTeleports(tag[], name[], value[])
- {
- new ID=strval(tag);
- Tp[ID][Exist] = true;
- if(!strcmp(name, "Name", true))format(Tp[ID][Name], 11, "%s", value);
- if(!strcmp(name, "Owner", true))format(Tp[ID][Owner], MAX_PLAYER_NAME, "%s", value);
- if(!strcmp(name, "Car", true))Tp[ID][wCar] = strval(value);
- if(!strcmp(name, "Priv", true))Tp[ID][Priv] = strval(value);
- if(!strcmp(name, "X", true))Tp[ID][PP][0] = floatstr(value);
- if(!strcmp(name, "Y", true))Tp[ID][PP][1] = floatstr(value);
- if(!strcmp(name, "Z", true))Tp[ID][PP][2] = floatstr(value);
- if(!strcmp(name, "A", true))Tp[ID][PP][3] = floatstr(value);
- if(!strcmp(name, "Vw", true))Tp[ID][Vw] = strval(value);
- if(!strcmp(name, "Int", true))Tp[ID][Int] = strval(value);
- if(ID==MAX_TELEPORTS)Full = true;
- }
- stock pName(playerid)
- {
- new name[MAX_PLAYER_NAME] = "INVALID PLAYER";
- if(!IsPlayerConnected(playerid))return name;
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
- stock DeleteTp(T_id)
- {
- Tp[T_id][Exist] = false;
- new INI:Fhnd;
- Fhnd = INI_Open(PATH);
- INI_DeleteTag(Fhnd, numstr(T_id));
- INI_Close(Fhnd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement