SA-MP Forums Archive
Teleport to nearest CP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Teleport to nearest CP (/showthread.php?tid=638262)



Teleport to nearest CP - ItzColaBoi - 29.07.2017

So the point of the story is that im trying to make a player teleport to nearest CP once he types /downroof.The hardest part is to make sure that player will teleport to nearest checkpoint once he interacts with organization checkpoint which gives him a dialog with roof teleport.So once the player types /downroof it auto tp's him down there since its the nearest CP.Im a newbie to scripting its kinda hard, no success yet.Check this command that has ability to add organization rooftop teleport, idk if it will be helpful..

Код:
CMD:addorgroof(playerid, params[])
{
	new giveplayerid, string[256];
	if (adlvl[playerid] < 6) return 0;
	if (sscanf(params, "d", giveplayerid)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /addorgroof [orgid]");
	format(string, 10, "org%d", giveplayerid);
	if (!dini_Exists(AddDirFile(dir_orgfiles, string))) return SendClientMessage2(playerid, COLOR_RED, "Error: Invalid organization id.");
	if (GetPlayerInterior(playerid) != 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You are in an interior.");
	new Float:x, Float:y, Float:z, Float:a;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngleFix(playerid, a);
	dini_FloatSet(AddDirFile(dir_orgfiles, string), "roofX", x);
	dini_FloatSet(AddDirFile(dir_orgfiles, string), "roofY", y);
	dini_FloatSet(AddDirFile(dir_orgfiles, string), "roofZ", z);
	dini_FloatSet(AddDirFile(dir_orgfiles, string), "roofA", a);
	SendPlayerFormattedText(playerid, COLOR_SILVER, "Roof positon for %s has been changed.", dini_Get(AddDirFile(dir_orgfiles, string), "name"), "");
	return 1;
}