Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <mpa>
- enum pd
- {
- bool:telemapping,
- Float:pointer[2],
- Text:textid
- }
- new pi[MAX_PLAYERS][pd];
- new mapobj[4];
- public OnFilterScriptInit()
- {
- print("Telemap script by Hiddos loaded.");
- mapobj[0] = CreateObject(16007 + 3164,-2447.47216797,937.39990234,50.370,0.00000000,0.00000000,0.00000000);
- mapobj[1] = CreateObject(16006 + 3164,-2448.96875000,937.39990234,50.370,0.00000000,0.00000000,0.00000000);
- mapobj[2] = CreateObject(16005 + 3164,-2447.47216797,938.89892578,50.370,0.00000000,0.00000000,0.00000000);
- mapobj[3] = CreateObject(16004 + 3164,-2448.96875000,938.89892578,50.370,0.00000000,0.00000000,0.00000000);
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(pi[i][telemapping] == true)
- {
- TextDrawDestroy(pi[i][textid]);
- SetCameraBehindPlayer(i);
- TogglePlayerControllable(i, true);
- }
- }
- DestroyObject(mapobj[0]);
- DestroyObject(mapobj[1]);
- DestroyObject(mapobj[2]);
- DestroyObject(mapobj[3]);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, 0xFFFF00FF, "This server runs the telemap script by Hiddos. Give it a go! /telehelp");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(pi[playerid][telemapping])
- {
- pi[playerid][telemapping] = false;
- TextDrawDestroy(pi[playerid][textid]);
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/telemap", true))
- {
- if(!pi[playerid][telemapping])
- {
- pi[playerid][telemapping] = true;
- SetPlayerCameraPos(playerid, -2448.228149415, 938.1492406, 53.370);
- SetPlayerCameraLookAt(playerid, -2448.228149415, 938.14941406, 50.370);
- TogglePlayerControllable(playerid, false);
- pi[playerid][textid] = TextDrawCreate(320.000000, 217.000000, ".");
- TextDrawBackgroundColor(pi[playerid][textid], 255);
- TextDrawFont(pi[playerid][textid], 0);
- TextDrawLetterSize(pi[playerid][textid], 0.349999, 1.000000);
- TextDrawColor(pi[playerid][textid], -65281);
- TextDrawSetOutline(pi[playerid][textid], 1);
- TextDrawSetProportional(pi[playerid][textid], 0);
- TextDrawShowForPlayer(playerid, pi[playerid][textid]);
- pi[playerid][pointer][0] = 320;
- pi[playerid][pointer][1] = 217;
- }
- else
- {
- pi[playerid][telemapping] = false;
- TextDrawDestroy(pi[playerid][textid]);
- SetCameraBehindPlayer(playerid);
- TogglePlayerControllable(playerid, true);
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/telehelp", true))
- {
- SendClientMessage(playerid, 0xFFFF00FF, "Telehelp by Hiddos:");
- SendClientMessage(playerid, 0x00FF00FF, "Use /telemap to open the map.");
- SendClientMessage(playerid, 0x00FF00FF, "Use the arrow keys to move around, and the jump key to teleport.");
- SendClientMessage(playerid, 0x00FF00FF, "Press /telemap again to close it.");
- return 1;
- }
- return 0;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & 32 && pi[playerid][telemapping] == true)
- {
- new Float:pos[3];
- pos[0] = pi[playerid][pointer][0];
- pos[1] = pi[playerid][pointer][1];
- pos[1] = 434.0 - pos[1];
- pos[0] -= (320.0);
- pos[1] -= (217.0);
- pos[0] *= (6.55022 * 2);
- pos[1] *= (7.00935 * 2);
- GetPointZPos(pos[0], pos[1], pos[2]);
- TogglePlayerControllable(playerid, true);
- SetCameraBehindPlayer(playerid);
- SetPlayerPos(playerid, pos[0], pos[1], pos[2] + 2.5);
- TextDrawDestroy(pi[playerid][textid]);
- pi[playerid][telemapping] = false;
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(pi[playerid][telemapping] == false) return 1;
- new keys[3]; //UD LR
- GetPlayerKeys(playerid, keys[0], keys[1], keys[2]);
- if(!keys[1] && !keys[2]) return 1;
- #define MOVE_VALUE 1.75
- if(keys[1] > 0 && pi[playerid][pointer][1] < 431) pi[playerid][pointer][1] += MOVE_VALUE;
- else if(keys[1] < 0 && pi[playerid][pointer][1] > 3) pi[playerid][pointer][1] -= MOVE_VALUE;
- if(keys[2] > 0 && pi[playerid][pointer][0] < 549) pi[playerid][pointer][0] += MOVE_VALUE;
- else if(keys[2] < 0 && pi[playerid][pointer][0] > 91) pi[playerid][pointer][0] -= MOVE_VALUE;
- TextDrawDestroy(pi[playerid][textid]);
- pi[playerid][textid] = TextDrawCreate(pi[playerid][pointer][0], pi[playerid][pointer][1], ".");
- TextDrawBackgroundColor(pi[playerid][textid], 255);
- TextDrawFont(pi[playerid][textid], 0);
- TextDrawLetterSize(pi[playerid][textid], 0.349999, 1.000000);
- TextDrawColor(pi[playerid][textid], -65281);
- TextDrawSetOutline(pi[playerid][textid], 1);
- TextDrawSetProportional(pi[playerid][textid], 0);
- TextDrawShowForPlayer(playerid, pi[playerid][textid]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement