All pastes #562772 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-12 22:11 UTC
rendered paste body
#include <a_samp>

#define COLOR_YELLOW 0xFFFF00AA

new NearObject[MAX_PLAYERS];

enum ObjectInfo
{
	modelid,
	LODmodel,
	Float:X,
	Float:Y,
	Float:Z,
	Float:rX,
	Float:rY,
	Float:rZ
}

new Float:ObjectsAndLODObjects[1][ObjectInfo] =
{
	{3589,3592,2431.76,-1674.83,15.2906,0.0,0.0,0.0} //House & LOD House
};

forward DynamicLODObjectTimer();

main()
{
	print("\n-------------------------------------");
	print("    Dynamic LOD Objects Test Script    ");
	print("-------------------------------------\n");
}

public OnGameModeInit()
{
	SetGameModeText("Test Script");
    AddPlayerClass(105,2517.6182,-1661.7655,14.2038,98.6277,0,0,22,1000,0,0);
	SetTimer("DynamicLODObjectTimer",500,1);
	/*for(new i = 0; i < sizeof(ObjectsAndLODObjects); i++)
	{
		CreateObject(ObjectsAndLODObjects[i][modelid],ObjectsAndLODObjects[i][X],ObjectsAndLODObjects[i][Y],ObjectsAndLODObjects[i][Z],ObjectsAndLODObjects[i][rX],ObjectsAndLODObjects[i][rY],ObjectsAndLODObjects[i][rZ]);
	}*/
	//CreateObject(3592,2431.76,-1674.83,15.2903,0,0,0); //The LOD object for the house
	CreateObject(17514,2430.74,-1678.73,13.1484,180,180,0); //hedge walls
	CreateObject(1211,2426.95,-1665.25,12.9219,0.509539,0.0142679,359.783); //fire hydrant
	return 1;
}

public OnGameModeExit()
{
	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 OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	NearObject[playerid] = -1;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerInfoChange(playerid)
{
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public DynamicLODObjectTimer()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
   	{
		if(IsPlayerConnected(i))
		{
		    for(new j = 0; j < sizeof(ObjectsAndLODObjects); j++)
		    {
				//GetObjectPos(j,ObjectsAndLODObjects[j][X],ObjectsAndLODObjects[j][Y],ObjectsAndLODObjects[j][Z]); //is this line needed?
				if(GetPlayerDistanceToPointEx(i,ObjectsAndLODObjects[j][X],ObjectsAndLODObjects[j][Y],ObjectsAndLODObjects[j][Z]) > 40.0)
				{
				    if(NearObject[i] != j)
				    {
			 			DestroyObject(j);
						SendClientMessage(i,COLOR_YELLOW,"1");
						CreateObject(ObjectsAndLODObjects[j][LODmodel],
									ObjectsAndLODObjects[j][X],
									ObjectsAndLODObjects[j][Y],
									ObjectsAndLODObjects[j][Z],
									ObjectsAndLODObjects[j][rX],
									ObjectsAndLODObjects[j][rY],
									ObjectsAndLODObjects[j][rY]);
						SendClientMessage(i,COLOR_YELLOW,"2");
					}
					NearObject[i] = j;
				}
				else if(NearObject[i] == j)
				{
					NearObject[i] = -1;
					DestroyObject(j);
					SendClientMessage(i,COLOR_YELLOW,"3");
 					CreateObject(ObjectsAndLODObjects[j][modelid],
								ObjectsAndLODObjects[j][X],
								ObjectsAndLODObjects[j][Y],
								ObjectsAndLODObjects[j][Z],
								ObjectsAndLODObjects[j][rX],
								ObjectsAndLODObjects[j][rY],
								ObjectsAndLODObjects[j][rY]);
	    			SendClientMessage(i,COLOR_YELLOW,"4");
				}
			}
		}
	}
}

GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z)
{
	new Float:x1,Float:y1,Float:z1;
	new Float:tmpdis;
	GetPlayerPos(playerid,x1,y1,z1);
	tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2)+floatpower(floatabs(floatsub(z,z1)),2));
	return floatround(tmpdis);
}