Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ||===========Credits============||
- ||The_Chaoz Scripting ||
- ||Wheelmandts main idea ||
- ||Y_Less y_ini, sscanf plugin ||
- ||Zeex zcmd ||
- || ||
- ||==============================||*/
- #define FILTERSCRIPT
- #include <a_samp>
- #include <YSI\y_ini>
- #include <sscanf2>
- #include <zcmd>
- #define PUBLIC:%0(%1) forward %0(%1); public %0(%1)
- #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;
- public OnFilterScriptInit()
- {
- if(!fexist("/TeleportsIG.sav")){
- new File:Fhnd;
- Fhnd = fopen(PATH, io_write);
- if(Fhnd)fclose(Fhnd);
- }
- 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 v2.0.1 Loaded");
- return print("----------------------------------------\n");
- }
- public OnFilterScriptExit()
- {
- print("\n------------------------------------------");
- print(" In Game Teleport Maker v2.0.1 Unloaded");
- return print("------------------------------------------\n");
- }
- public OnPlayerCommandReceived(playerid, cmdtext[]){
- if(strcmp(cmdtext, "/tcrear", true, 6) && strcmp(cmdtext, "/tlista", true, 6) && strcmp(cmdtext, "/tborrar", true, 7))
- CallLocalFunction("ExecuteTeleport", "si", cmdtext[1], playerid);
- return 1;
- }
- public OnPlayerCommandPerformed(playerid, cmdtext[], success){
- new i;
- for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], cmdtext[1], true))break;
- if(Tp[i][Exist])success = 1;
- return (success) ? (1) : (0);
- }
- CMD: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]I(0)I(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.");
- new i;
- for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], name, true) && Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "Error: El nombre ya ha sido utilizado.");
- 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 \"/%s\" para ir a el.", name);
- return SendClientMessage(playerid, 0xFFFF00FF, str);
- }
- CMD: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--");
- }
- CMD:tborrar(playerid, params[])
- {
- new name[11];
- if(sscanf(params, "s[11]", name))return SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tborrar <nombre>");
- new i;
- for(; 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.");
- }
- PUBLIC:ExecuteTeleport(name[], forplayer)
- {
- new str[128], i;
- for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], name, true))break;
- if(!Tp[i][Exist])return 0;
- if(!IsPlayerInAnyVehicle(forplayer)){
- SetPlayerPos(forplayer, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- SetPlayerFacingAngle(forplayer, Tp[i][PP][3]);
- SetPlayerInterior(forplayer, Tp[i][Int]);
- SetPlayerVirtualWorld(forplayer, Tp[i][Vw]);
- SetCameraBehindPlayer(forplayer);
- }
- else{
- if(!Tp[i][wCar]){
- SetPlayerPos(forplayer, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- SetPlayerFacingAngle(forplayer, Tp[i][PP][3]);
- SetPlayerInterior(forplayer, Tp[i][Int]);
- SetPlayerVirtualWorld(forplayer, Tp[i][Vw]);
- SetCameraBehindPlayer(forplayer);
- }
- else{
- new Veh = GetPlayerVehicleID(forplayer);
- SetVehiclePos(Veh, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
- SetVehicleZAngle(Veh, Tp[i][PP][3]);
- PutPlayerInVehicle(forplayer, Veh, 0);
- SetVehicleVirtualWorld(Veh, Tp[i][Vw]);
- LinkVehicleToInterior(Veh, Tp[i][Int]);
- SetCameraBehindPlayer(forplayer);
- }
- }
- if(!strlen(Tp[i][Frace]))format(str, 128, "Has ido a \"%s\" creado por %s.", Tp[i][Name], Tp[i][Owner]);
- else format(str, 128, "\"%s\" por %s.", Tp[i][Frace], Tp[i][Owner]);
- SendClientMessage(forplayer, 0xFFFF00FF, str);
- return 1;
- }
- 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;
- }
- pName(playerid)
- {
- new name[MAX_PLAYER_NAME] = "INVALID PLAYER";
- if(!IsPlayerConnected(playerid))return name;
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
- 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