All pastes #989625 Raw Edit

Jemand

public text v1 · immutable
#989625 ·published 2008-04-19 15:45 UTC
rendered paste body
#include <a_samp>

new Incamper[MAX_PLAYERS];
new Float:camperPos[MAX_VEHICLES][3];
new sExplode[MAX_VEHICLES], tCount[MAX_VEHICLES];

new Float:difc[14][4] = {   //abstand vom standartobject (beginnend bei 0)
{-6.973633, -1.118774, 1.992187, 90.0},   //{x, y, z, roat:z}
{-6.973633, -2.635498, 1.992187, 90.0},
{2.689453, -1.699951, 1.992187, 270.0},
{2.689453, 1.042969, 1.992187, 270.0},
{-3.024659, -1.765014, 1.571715, 0.0},
{-3.910645, 2.677857, 1.992187, 0.0},
{-1.936768, 2.677857, 1.992187, 0.0},
{-0.936768, 2.477857, 1.992187, 0.0},
{-6.773633, -0.70813, 2.0, 90.0},
{-0.07251, 2.677857, 2.1, 0.0},
{0.843994, -2.640625, 1.992187, 180.0},
{2.363525, -2.940918, 1.992187, 180.0},
{-0.73584, -1.259179, 1.992187, 0.0},
{-0.6, -2.27, 4.14, 90.0}
};

public OnFilterScriptInit()
{
	print("------------------------------------------");
	print("Camper int FS");
	print("------- v1.0 by St3v3 (c) 2008 -------");
	print("------------------------------------------");
	return 1;
}

forward Explodecamper(vehicleid);

stock CreatecamperInt(vehicleid, Float:X, Float:Y, Float:Z)
{
	CreateObject(10148, X, Y, Z, 0.0, 0.0, 90.0);            // standart object
	CreateObject(2395, floatadd(X, difc[0][0]), floatadd(Y, difc[0][1]), floatsub(Z, difc[0][2]), 0.0, 0.0, difc[0][3]);  // weitere objecte (erste zahl = Reihe bei [new Float:difc[13][4]]; 2te Zahl = Spalte)
	CreateObject(2395, floatadd(X, difc[1][0]), floatadd(Y, difc[1][1]), floatsub(Z, difc[1][2]), 0.0, 0.0, difc[1][3]);
	CreateObject(1745, floatadd(X, difc[2][0]), floatadd(Y, difc[2][1]), floatsub(Z, difc[2][2]), 0.0, 0.0, difc[2][3]);  // weitere objecte (erste zahl = Reihe bei [new Float:difc[13][4]]; 2te Zahl = Spalte)
	CreateObject(1745, floatadd(X, difc[3][0]), floatadd(Y, difc[3][1]), floatsub(Z, difc[3][2]), 0.0, 0.0, difc[3][3]);
	CreateObject(643, floatadd(X, difc[4][0]), floatadd(Y, difc[4][1]), floatsub(Z, difc[4][2]), 0.0, 0.0, difc[4][3]);
	CreateObject(2013, floatadd(X, difc[5][0]), floatadd(Y, difc[5][1]), floatsub(Z, difc[5][2]), 0.0, 0.0, difc[5][3]);  // weitere objecte (erste zahl = Reihe bei [new Float:difc[13][4]]; 2te Zahl = Spalte)
	CreateObject(2017, floatadd(X, difc[6][0]), floatadd(Y, difc[6][1]), floatsub(Z, difc[6][2]), 0.0, 0.0, difc[6][3]);
	CreateObject(2147, floatadd(X, difc[7][0]), floatadd(Y, difc[7][1]), floatsub(Z, difc[7][2]), 0.0, 0.0, difc[7][3]);  // weitere objecte (erste zahl = Reihe bei [new Float:difc[13][4]]; 2te Zahl = Spalte)
	CreateObject(2296, floatadd(X, difc[8][0]), floatadd(Y, difc[8][1]), floatsub(Z, difc[8][2]), 0.0, 0.0, difc[8][3]);
	CreateObject(2336, floatadd(X, difc[9][0]), floatadd(Y, difc[9][1]), floatsub(Z, difc[9][2]), 0.0, 0.0, difc[9][3]);
	//neues
	CreateObject(2525, floatadd(X, difc[10][0]), floatadd(Y, difc[10][1]), floatsub(Z, difc[10][2]), 0.0, 0.0, difc[10][3]);  // weitere objecte (erste zahl = Reihe bei [new Float:difc[13][4]]; 2te Zahl = Spalte)
	CreateObject(2524, floatadd(X, difc[11][0]), floatadd(Y, difc[11][1]), floatsub(Z, difc[11][2]), 0.0, 0.0, difc[11][3]);
	CreateObject(2818, floatadd(X, difc[12][0]), floatadd(Y, difc[12][1]), floatsub(Z, difc[12][2]), 0.0, 0.0, difc[12][3]);

	camperPos[vehicleid][0] = X, camperPos[vehicleid][1] = Y, camperPos[vehicleid][2] = Z;
}

stock SetPlayerPosIncamper(playerid, camperid)  //position beim einsteigen in camper
{
	SetPlayerPos(playerid, camperPos[camperid][0],
	floatsub(camperPos[camperid][1], 0.0),  //genaue position
	floatsub(camperPos[camperid][2], 0.0)); // genaue Position
	SetPlayerFacingAngle(playerid, 0.0);     // FacingAngel
	SetCameraBehindPlayer(playerid);         // Camera Position
}

stock camperExists(vehicleid)  //position beim verlassen des Campers
{
	if (floatsqroot(floatadd(camperPos[vehicleid][0], floatadd(camperPos[vehicleid][1], camperPos[vehicleid][2]))))
	{
		return 1;
	}
	return 0;
}

stock randomEx(randval)
{
	new rand1 = random(2), rand2;
	if (!rand1) rand2 -= random(randval);
	else rand2 += random(randval);
	return rand2;
}

public OnPlayerConnect(playerid)
{
	Incamper[playerid] = 0;
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if (GetVehicleModel(vehicleid) == 508 && ispassenger)
	{
		if (!camperExists(vehicleid))
		{
			CreatecamperInt(vehicleid, float(randomEx(3000)), float(randomEx(3000)), float(random(100)+800));
		}
		SetPlayerPosIncamper(playerid, vehicleid);
		Incamper[playerid] = vehicleid;
	}
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (newkeys & 16 && Incamper[playerid])
	{
		new Float:X, Float:Y, Float:Z, Float:A;
		GetVehiclePos(Incamper[playerid], X, Y, Z);
		GetVehicleZAngle(Incamper[playerid], A);
		X += (5 * floatsin(-floatsub(A, 45.0), degrees)),
		Y += (5 * floatcos(-floatsub(A, 45.0), degrees));
		SetPlayerInterior(playerid, 0);
		SetPlayerPos(playerid, X, Y, floatsub(Z, 0.0));
		SetPlayerFacingAngle(playerid, A);
		SetCameraBehindPlayer(playerid);
		Incamper[playerid] = 0;
	}
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	Incamper[playerid] = 0;
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	if (GetVehicleModel(vehicleid) == 508 && camperExists(vehicleid))
	{
		CreateExplosion(camperPos[vehicleid][0], camperPos[vehicleid][1], camperPos[vehicleid][2], 2, 15.0);
		sExplode[vehicleid] = SetTimerEx("Explodecamper", 700, 1, "d", vehicleid);
		tCount[vehicleid] = true;
	}
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	tCount[vehicleid] = false;
	return 1;
}

public Explodecamper(vehicleid)
{
	KillTimer(sExplode[vehicleid]);
	if (tCount[vehicleid])
	{
		CreateExplosion(camperPos[vehicleid][0], camperPos[vehicleid][1], camperPos[vehicleid][2], 2, 15.0);
		sExplode[vehicleid] = SetTimerEx("Explodecamper", random(1300)+100, 1, "d", vehicleid);
	}
}