Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Teleport Maker [Checkpoints] - Save/Load [YINI]
- Credits to
- Romel, Y_Less
- Gagi for the GetCloset function.
- Commands:
- /createtele [id] [Name]
- Then you will go to place where you want the player to be teleported. Then type
- /finishtele [interior] [world]. Then done
- to end the teleport creating/cancel it. Do /canceltele.
- /deletemode - Enables Delete Mod/Disables Delete Mod
- /removetele - Remove the closset Teleport Checkpoints (You need to enable the Delete Mod First)
- /gototele [id] - Goto the Teleport ID
- /instruction
- /tcmds
- Note: Delete Mod allows you to walk through teleport checkpoints
- so that you will not be teleported!
- */
- #include <a_samp>
- #include <sscanf2>
- #include <YSI\y_ini>
- #include <YSI\y_commands>
- #include <streamer>
- #define FILTERSCRIPT
- #define DISTANCE_PER_TELE 20.0
- #define MAPICON_PER_TELE 35
- #define CPSIZE_PER_TELE 2.0
- #define TeleportFile "telefile/%i.ini" //Change the path if needed
- #define COLOR_RED 0xFF0000FF
- #define COLOR_RED2 0xE01B4CFF
- #define SCM SendClientMessage
- #define COL_YELLOW "{F5E618}"
- #define COL_GREEN "{2EAD15}"
- #define MAX_TELEPORTS 500 //More value, More AMX Size
- enum E_TELEPORT_DATA
- {
- Text3D:Label[128],
- Name[128],
- CP,
- Icon,
- World,
- Interior,
- Float:cX,
- Float:cY,
- Float:cZ,
- Float:pX,
- Float:pY,
- Float:pZ,
- Float:pA,
- pInterior,
- pWorld
- };
- new TeleData[MAX_TELEPORTS][E_TELEPORT_DATA];
- new tFile[256],
- Float:myPos[3],
- myWor,
- myInt,
- paname[128],
- paid,
- Process[MAX_PLAYERS],
- DeleteMod[MAX_PLAYERS],
- CurCP,
- CountT = 0,
- CurIcon;
- //==============================================================================
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n");
- print("[0.3x] Teleport Maker w/ Checkpoints - Save/Load [YINI]");
- print("Provides Label, Very Cool Teleport Maker Designer!");
- print("Loaded, with the includes of: Y_INI, Y_COMMAND, A_SAMP, SSCANF2, STREAMER");
- print("\n");
- for(new i = 0; i <= MAX_TELEPORTS; i++)
- {
- format(tFile, sizeof tFile, TeleportFile, i);
- if(fexist(tFile))
- {
- INI_ParseFile(tFile, "LoadTeleport", .bExtra = true, .extra = i);
- ReadTeleport(i);
- CountT += 1;
- }
- }
- printf("Total Teleports: %i", CountT);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n");
- print("[0.3x] Teleport Maker w/ Checkpoints - Save/Load [YINI]");
- print("Provides Label, Very Cool Teleport Maker Designer!");
- print("Unloaded, with the includes of: Y_INI, Y_COMMAND, A_SAMP, SSCANF2, STREAMER");
- print("\n");
- for(new i = 0; i < MAX_TELEPORTS; i++)
- {
- format(tFile, sizeof tFile, TeleportFile, i);
- if(fexist(tFile))
- {
- INI_ParseFile(tFile, "LoadTeleport", .bExtra = true, .extra = i);
- UnloadTeleport(i);
- }
- }
- return 1;
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- Process[playerid] = 0;
- DeleteMod[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Process[playerid] = 0;
- DeleteMod[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(DeleteMod[playerid] == 1) DeleteMod[playerid] = 0;
- if(Process[playerid] == 1)
- {
- DestroyDynamicCP(CurCP);
- DestroyDynamicMapIcon(CurIcon);
- Process[playerid] = 0;
- }
- return 1;
- }
- public OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- for(new i = 0; i < MAX_TELEPORTS; i++)
- {
- if(checkpointid == TeleData[i][CP])
- {
- if(DeleteMod[playerid] == 1)
- {
- SCM(playerid, -1, "/removetele, To remove this teleport checkpoint!");
- SCM(playerid, -1, "If you don't want to remove this, Skip this checkpoint");
- return 1;
- }
- if(!IsPlayerInAnyVehicle(playerid))
- {
- SetCameraBehindPlayer(playerid);
- SetPlayerInterior(playerid, TeleData[i][pInterior]);
- SetPlayerVirtualWorld(playerid, TeleData[i][pWorld]);
- SetPlayerPos(playerid, TeleData[i][pX], TeleData[i][pY], TeleData[i][pZ]);
- SetPlayerFacingAngle(playerid, TeleData[i][pA]);
- }
- }
- }
- if(checkpointid == CurCP) return 1;
- SCM(playerid, -1, "Teleported Successfully!");
- return 1;
- }
- forward LoadTeleport(id, name[], value[]);
- public LoadTeleport(id, name[], value[])
- {
- INI_String("TeleName", TeleData[id][Name], 128);
- INI_Int("TeleWorld", TeleData[id][World]);
- INI_Int("TeleInterior", TeleData[id][Interior]);
- INI_Float("TeleX", TeleData[id][cX]);
- INI_Float("TeleY", TeleData[id][cY]);
- INI_Float("TeleZ", TeleData[id][cZ]);
- INI_Float("PlayerX", TeleData[id][pX]);
- INI_Float("PlayerY", TeleData[id][pY]);
- INI_Float("PlayerZ", TeleData[id][pZ]);
- INI_Float("PlayerA", TeleData[id][pA]);
- INI_Int("PlayerWorld", TeleData[id][pWorld]);
- INI_Int("PlayerInterior", TeleData[id][pInterior]);
- return 1;
- }
- //==============================================================================
- YCMD:instructions(playerid, params[], help)
- {
- #pragma unused help
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be RCON admin");
- SCM(playerid, -1, "Teleport Maker [YINI] - Save/Load by Romel Instruction (v1.0):");
- SCM(playerid, COLOR_RED2, "To create teleports, /createtele, Make sure you're rcon login!");
- SCM(playerid, COLOR_RED2, "After typing the command, It will send a USAGE message ''USAGE: /createtele [ID] [Name]''");
- SCM(playerid, COLOR_RED2, "The ID will be the Teleport ID, and the Name will be the teleports name, example ''/createtele 0 My Teleport''");
- SCM(playerid, COLOR_RED2, "After doing that step, The create system, will ask you, to go to the position where player will be teleported when entered the checkpoint");
- SCM(playerid, COLOR_RED2, "If you're already in the position, Just do /finishtele, Oopppss the command usage is wrong. It must be ''/finishtele [interior] [world]''");
- SCM(playerid, COLOR_RED2, "Just do /finishtele 0 0 (Interior 0: Whole SAN ANDREAS INTERIOR) | (World 0: Main Virtual World), Now you can start your own one!");
- SCM(playerid, COLOR_RED2, "if you want to remove the previous teleport, Do /deletemode, Then go to the checkpoint position, Then type, /removetele");
- SCM(playerid, COLOR_RED2, "To go to the teleport checkpoint, do /gototele [ID], to cancel the teleport making, Just do /canceltele");
- return 1;
- }
- YCMD:tcmds(playerid, params[], help)
- {
- #pragma unused help
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be RCON admin");
- SCM(playerid, -1, "Teleport Maker [YINI] - Save/Load by Romel Commands (v1.0):");
- SCM(playerid, COLOR_RED2, "/createtele, /removetele, /gototele, /deletemode, /finishtele /canceltele");
- return 1;
- }
- YCMD:gototele(playerid, params[], help)
- {
- #pragma unused help
- new id;
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be RCON admin");
- if(sscanf(params, "i", id)) return SCM(playerid, COLOR_RED, "USAGE: /gototele [ID]");
- format(tFile, sizeof tFile, TeleportFile, id);
- if(!fexist(tFile)) return SCM(playerid, COLOR_RED, "ERROR: There is no Teleport on that id.");
- SetPlayerPos(playerid, TeleData[id][cX]+2, TeleData[id][cY], TeleData[id][cZ]);
- return 1;
- }
- YCMD:removetele(playerid, params[], help)
- {
- #pragma unused help
- #pragma unused params
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be RCON admin");
- new t = GetClosetTeleID(playerid);
- if(DeleteMod[playerid] == 0) return SCM(playerid, COLOR_RED, "ERROR: You must enable Delete Mod first before removing teleports!");
- if(t == -1) return SCM(playerid, COLOR_RED, "ERROR: There is no teleport checkpoint");
- format(tFile, sizeof tFile, TeleportFile, t);
- if(fexist(tFile))
- {
- fremove(tFile);
- DestroyDynamicCP(TeleData[t][CP]);
- DestroyDynamic3DTextLabel(TeleData[t][Label]);
- DestroyDynamicMapIcon(TeleData[t][Icon]);
- }
- return 1;
- }
- YCMD:deletemode(playerid, params[], help)
- {
- #pragma unused help
- if(DeleteMod[playerid] == 0)
- {
- DeleteMod[playerid] = 1;
- SCM(playerid, -1, "Delete Mod Enable!");
- SCM(playerid, -1, "You're now able to delete teleports with /removetele");
- SCM(playerid, -1, "Go to the Teleport Checkpoint then type /removetele");
- }
- else if(DeleteMod[playerid] == 1)
- {
- DeleteMod[playerid] = 0;
- SCM(playerid, COLOR_RED2, "Delete Mod Disable!");
- SCM(playerid, -1, "Removing Teleports has been cancelled, Due to Delete Mod Disabled!");
- }
- return 1;
- }
- YCMD:canceltele(playerid, params[], help)
- {
- #pragma unused help
- if(Process[playerid] == 1)
- {
- paid = -1;
- format(paname, sizeof paname, "None");
- DestroyDynamicCP(CurCP);
- DestroyDynamicMapIcon(CurIcon);
- Process[playerid] = 0;
- SCM(playerid, COLOR_RED2, "Cancelled Teleport Making Design");
- }
- else return SCM(playerid, COLOR_RED, "ERROR: You aren't creating Teleport!");
- return 1;
- }
- YCMD:createtele(playerid, params[], help)
- {
- #pragma unused help
- myInt = GetPlayerInterior(playerid),
- myWor = GetPlayerVirtualWorld(playerid);
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "ERROR: You must be RCON admin");
- if(sscanf(params, "is[128]", paid, paname)) return SCM(playerid, COLOR_RED, "USAGE: /createtele [ID] [Name]");
- if(paid >= MAX_TELEPORTS) return SCM(playerid, COLOR_RED, "ERROR: You have typed the wrong teleport id.");
- format(tFile, sizeof tFile, TeleportFile, paid);
- if(fexist(tFile)) return SCM(playerid, COLOR_RED, "ERROR: Teleport File on that id already exists!");
- GetPlayerPos(playerid, myPos[0], myPos[1], myPos[2]);
- Process[playerid] = 1;
- CurCP = CreateDynamicCP(myPos[0], myPos[1], myPos[2], CPSIZE_PER_TELE, myWor, myInt, -1, DISTANCE_PER_TELE);
- CurIcon = CreateDynamicMapIcon(myPos[0], myPos[1], myPos[2], MAPICON_PER_TELE, -1, myWor, myInt, -1, DISTANCE_PER_TELE);
- SCM(playerid, -1, "Next go to the place, Where player will be teleported when the checkpoint is entered");
- SCM(playerid, -1, "After you go to position, Type /finishtele");
- SCM(playerid, -1, "Or if you want to cancel this teleport designing then /canceltele");
- return 1;
- }
- YCMD:finishtele(playerid, params[], help)
- {
- #pragma unused help
- new
- Float:pMyPos[4],
- world,
- interior;
- if(Process[playerid] == 0) return SCM(playerid, COLOR_RED, "ERROR: You aren't designing any Teleports!");
- if(sscanf(params, "ii", interior, world)) return SCM(playerid, COLOR_RED, "USAGE: /finishtele [interior] [world]");
- format(tFile, sizeof tFile, TeleportFile, paid);
- GetPlayerPos(playerid, pMyPos[0], pMyPos[1], pMyPos[2]);
- GetPlayerFacingAngle(playerid, pMyPos[3]);
- new INI:file = INI_Open(tFile);
- INI_WriteString(file, "TeleName", paname);
- INI_WriteInt(file, "TeleWorld", myWor);
- INI_WriteInt(file, "TeleInterior", myInt);
- INI_WriteFloat(file, "TeleX", myPos[0]);
- INI_WriteFloat(file, "TeleY", myPos[1]);
- INI_WriteFloat(file, "TeleZ", myPos[2]);
- INI_WriteFloat(file, "PlayerX", pMyPos[0]);
- INI_WriteFloat(file, "PlayerY", pMyPos[1]);
- INI_WriteFloat(file, "PlayerZ", pMyPos[2]);
- INI_WriteFloat(file, "PlayerA", pMyPos[3]);
- INI_WriteInt(file, "PlayerWorld", world);
- INI_WriteInt(file, "PlayerInterior", interior);
- INI_Close(file);
- DestroyDynamicCP(CurCP); DestroyDynamicMapIcon(CurIcon);
- Process[playerid] = 0;
- SCM(playerid, -1, "Successfully created, Now going to reload all teleports!");
- for(new i = 0; i < MAX_TELEPORTS; i++)
- {
- format(tFile, sizeof tFile, TeleportFile, i);
- if(fexist(tFile))
- {
- INI_ParseFile(tFile, "LoadTeleport", .bExtra = true, .extra = i);
- ReadTeleport(i);
- }
- }
- return 1;
- }
- //==============================================================================
- forward GetClosetTeleID(playerid);
- public GetClosetTeleID(playerid)
- {
- new Float:Distance;
- for(new t; t<MAX_TELEPORTS; t++)
- {
- Distance = GetDistanceToTele(playerid, t);
- if(Distance < 2.0)
- {
- return t;
- }
- }
- return -1;
- }
- forward Float:GetDistanceToTele(playerid, t);
- public Float:GetDistanceToTele(playerid, t)
- {
- new Float:x1,
- Float:y1,
- Float:z1,
- Float:x2,
- Float:y2,
- Float:z2;
- GetPlayerPos(playerid, x1, y1, z1);
- x2 = TeleData[t][cX];
- y2 = TeleData[t][cY];
- z2 = TeleData[t][cZ];
- return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
- }
- stock ReadTeleport(i)
- {
- new string[500];
- format(string, sizeof(string), ""COL_YELLOW"Teleport to: {FFFFFF}%s\n"COL_GREEN"Set Interior to: {FFFFFF}%i\n"COL_GREEN"Set Virtual World to: {FFFFFF}%i\nCreated by Teleport Maker by Romel\n"COL_YELLOW"Step in to teleport!", TeleData[i][Name], TeleData[i][pInterior], TeleData[i][pWorld]);
- TeleData[i][Label] = CreateDynamic3DTextLabel(string, -1, TeleData[i][cX], TeleData[i][cY], TeleData[i][cZ], 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, TeleData[i][World], TeleData[i][Interior], -1, DISTANCE_PER_TELE);
- TeleData[i][CP] = CreateDynamicCP(TeleData[i][cX], TeleData[i][cY], TeleData[i][cZ], CPSIZE_PER_TELE, TeleData[i][World], TeleData[i][Interior], -1, DISTANCE_PER_TELE);
- TeleData[i][Icon] = CreateDynamicMapIcon(TeleData[i][cX], TeleData[i][cY], TeleData[i][cZ], MAPICON_PER_TELE, -1, TeleData[i][World], TeleData[i][Interior], -1, DISTANCE_PER_TELE);
- return 1;
- }
- stock UnloadTeleport(i)
- {
- DestroyDynamic3DTextLabel(TeleData[i][Label]);
- DestroyDynamicCP(TeleData[i][CP]);
- DestroyDynamicMapIcon(TeleData[i][Icon]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment