#include <a_samp>
/* Configuraзгo: Valor: */
#define MAX_OBJECTOS 2500
#define MIN_INTERVAL 0500
#define MAX_DISTANCE 300.0
/* */
#define Loop(%0,%1) for(new %0; %0 < %1; ++%0)
#define Function%0(%1) forward %0(%1); \
public %0(%1)
enum ObjetoI
{
Model,
Virtual,
Interior,
Float:Draw,
Float:X,
Float:Y,
Float:Z,
Float:rX,
Float:rY,
Float:rZ,
bool:Criado,
bool:Movendo
}
enum ObjetoD
{
Float:X,
Float:Y,
Float:Z,
Float:rX,
Float:rY,
Float:rZ,
Float:Velocidade
}
new ObjetoInfo[MAX_OBJECTOS][ObjetoI], ObjetoData[MAX_OBJECTOS][ObjetoD], ObjectPlayer[MAX_PLAYERS][MAX_OBJECTOS];
new ObjetosCriados[MAX_PLAYERS];
/*
function
**** - Creates an object defined
return
**** - Returns the id of the created object
parameters
**** - Model, Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz, Float: speed, virtualworld, interior
comments
**** - no
*/
stock CreateObjectEx(model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:draw = MAX_DISTANCE, virtualworld = 0, interior = 0)
{
new objid;
while(objid < MAX_OBJECTOS)
{
static bool:AntiFlood;
if(objid == MAX_OBJECTOS-1 && AntiFlood == false) printf("Limite de %d objetos exedido. Aumente o limite ou retire objetos.", MAX_OBJECTOS), AntiFlood = true;
if(ObjetoInfo[objid][Criado] == false)
{
ObjetoInfo[objid][Criado] = true;
ObjetoInfo[objid][Model] = model;
ObjetoInfo[objid][Interior] = interior;
ObjetoInfo[objid][Virtual] = virtualworld;
ObjetoInfo[objid][Draw] = draw;
ObjetoInfo[objid][rZ] = rz;
ObjetoInfo[objid][rY] = ry;
ObjetoInfo[objid][rX] = rx;
ObjetoInfo[objid][Z] = z;
ObjetoInfo[objid][Y] = y;
ObjetoInfo[objid][X] = x;
break;
}
++objid;
}
return objid;
}
/*
function
**** - Moves an object defined
return
**** - Returns to 1
parameters
**** - Objid, Float: x, Float: y, Float: z, Float: speed, Float: rx, Float: ry, Float: rz
comments
**** - no
*/
stock MoveObjectEx(objid, Float:x, Float:y, Float:z, Float:velocidade, Float:rx = -1000.0, Float:ry = -1000.0, Float:rz = -1000.0)
{
if(rx == -1000.0) rx = ObjetoInfo[objid][rX];
else if(ry == -1000.0) ry = ObjetoInfo[objid][rY];
else if(rz == -1000.0) rz = ObjetoInfo[objid][rZ];
ObjetoInfo[objid][Movendo] = true;
ObjetoData[objid][rZ] = rz;
ObjetoData[objid][rY] = ry;
ObjetoData[objid][rX] = rx;
ObjetoData[objid][Z] = z;
ObjetoData[objid][Y] = y;
ObjetoData[objid][X] = x;
ObjetoData[objid][Velocidade] = velocidade;
return 1;
}
/*
function
**** - For an object defined
return
**** - Returns to 1
parameters
**** - objid
comments
**** - To stop the object automatically calls the callback "OnObjectMoved"
*/
stock StopObjectEx(objid)
{
ObjetoInfo[objid][Movendo] = false;
CallRemoteFunction("OnObjectMoved", "i", objid);
Loop(i, MAX_PLAYERS)
{
StopPlayerObject(i, objid);
}
return 1;
}
/*
function
**** - Sets the object to set pos
return
**** - Returns to 1
parameters
**** - Objid, Float: x, Float: y, Float: z
comments
**** - When using the "SetObjectPosEx", the object not to the move (if moving)
*/
stock SetObjectPosEx(objid, Float:x, Float:y, Float:z)
{
ObjetoInfo[objid][Z] = z;
ObjetoInfo[objid][Y] = y;
ObjetoInfo[objid][X] = x;
Loop(i, MAX_PLAYERS)
{
SetPlayerObjectPos(i, objid, x, y, z);
}
return 1;
}
/*
function
**** - Sets the object rotation set
return
**** - Returns to 1
parameters
**** - Objid, Float: rx, Float: ry, Float: rz
comments
**** - no
*/
stock SetObjectRotEx(objid, Float:rx, Float:ry, Float:rz)
{
ObjetoInfo[objid][rZ] = rz;
ObjetoInfo[objid][rY] = ry;
ObjetoInfo[objid][rX] = rx;
Loop(i, MAX_PLAYERS)
{
SetPlayerObjectRot(i, objid, rx, ry, rz);
}
return 1;
}
/*
function
**** - Destroy the object set
return
**** - Returns to 1
parameters
**** - objid
comments
**** - no
*/
stock DestroyObjectEx(objid)
{
if(ObjetoInfo[objid][Movendo] == true) StopObjectEx(objid);
ObjetoInfo[objid][Criado] = false;
return 1;
}
/*
function
**** - Checks whether the object is valid
return
**** - Returns a 1 if it is valid and 0 if not
parameters
**** - objid
comments
**** - no
*/
stock IsValidObjectEx(objid)
{
if(ObjetoInfo[objid][Criado] == true) return 1;
return 0;
}
/*
function
**** - Geta the coordinates of an object defined
return
**** - Returns to 1
parameters
**** - Objid, & Float: x, & Float: y, & Float: z
comments
**** - no
*/
stock GetObjectPosEx(objid, &Float:x, &Float:y, &Float:z)
{
z = ObjetoInfo[objid][Z];
y = ObjetoInfo[objid][Y];
z = ObjetoInfo[objid][X];
return 1;
}
/*
function
**** - Geta rotations of an object defined
return
**** - Returns to 1
parameters
**** - Objid, & Float: rx, & Float: ry, & Float: rz
comments
**** - no
*/
stock GetObjectRotEx(objid, &Float:rx, &Float:ry, &Float:rz)
{
rz = ObjetoInfo[objid][rZ];
ry = ObjetoInfo[objid][rY];
rz = ObjetoInfo[objid][rX];
return 1;
}
/*
function
**** - Sets the interior of an object defined
return
**** - Returns to 1
parameters
**** - Objid, interior
comments
**** - no
*/
stock SetObjectInterior(objid, interior)
{
ObjetoInfo[objid][Interior] = interior;
return 1;
}
/*
function
**** - Sets the virtual world of an object defined
return
**** - Returns to 1
parameters
**** - Objid, interior
comments
**** - virtualworld
*/
stock SetObjectVirtualWorld(objid, virtualworld)
{
ObjetoInfo[objid][Virtual] = virtualworld;
return 1;
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-( Atualizar os Objetos )-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
Function AtualizarObjetos()
{
Loop(i, MAX_PLAYERS)
{
if(!IsPlayerConnected(i)) continue;
Loop(objid, MAX_OBJECTOS)
{
if(GetPlayerInterior(i) == ObjetoInfo[objid][Interior] && GetPlayerVirtualWorld(i) == ObjetoInfo[objid][Virtual] && IsPlayerInRangeOfPoint(i, ObjetoInfo[objid][Draw], ObjetoInfo[objid][X], ObjetoInfo[objid][Y], ObjetoInfo[objid][Z]) && ObjetoInfo[objid][Criado] == true)
{
if(ObjectPlayer[i][objid] == -1)
{
if(ObjetosCriados[i] >= 950) DestroyObjectFromDistance(i), --ObjetosCriados[i];
++ObjetosCriados[i];
ObjectPlayer[i][objid] = CreatePlayerObject(i, ObjetoInfo[objid][Model], ObjetoInfo[objid][X], ObjetoInfo[objid][Y], ObjetoInfo[objid][Z], ObjetoInfo[objid][rX], ObjetoInfo[objid][rY], ObjetoInfo[objid][rZ]);
if(ObjetoInfo[objid][Movendo] == true) MovePlayerObject(i, ObjectPlayer[objid][i], ObjetoData[objid][X], ObjetoData[objid][Y], ObjetoData[objid][Z], ObjetoData[objid][Velocidade], ObjetoData[objid][rX], ObjetoData[objid][rY], ObjetoData[objid][rZ]);
}
}
else
{
DestroyPlayerObject(i, ObjectPlayer[i][objid]);
ObjectPlayer[i][objid] = -1;
}
}
}
return 1;
}
stock DestroyObjectFromDistance(playerid)
{
new Float:objectPos[3], Float:playerDistance = 100000.0, objectId;
Loop(objid, MAX_OBJECTS)
{
GetObjectPos(objid, objectPos[0], objectPos[1], objectPos[2]);
if(GetPlayerDistanceFromPoint(playerid, objectPos[0], objectPos[1], objectPos[2]) < playerDistance)
{
playerDistance = GetPlayerDistanceFromPoint(playerid, objectPos[0], objectPos[1], objectPos[2]);
objectId = objid;
}
}
DestroyPlayerObject(playerid, objectId);
return 1;
}
#if defined FILTERSCRIPT
public OnFilterScriptInit()
#else
public OnGameModeInit()
#endif
{
SetTimer("AtualizarObjetos", MIN_INTERVAL, true);
#if defined FILTERSCRIPT
return (funcidx("ALSS_OnFilterScriptInit") != -1 ? CallLocalFunction("ALSS_OnFilterScriptInit", "") : 1);
}
#if defined _ALS_OnFilterScriptInit
#undef OnFilterScriptInit
#else
#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit ALSS_OnFilterScriptInit
forward ALSS_OnFilterScriptInit();
#else
return (funcidx("ALSS_OnGameModeInit") != -1 ? CallLocalFunction("ALSS_OnGameModeInit", "") : 1);
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit ALSS_OnGameModeInit
forward ALSS_OnGameModeInit();
#endif
//Peguei estб ALS desta Include: http://pastebin.com/d4hfMvQx
public OnPlayerObjectMoved(playerid, objectid)
{
ObjetoInfo[objectid][Movendo] = false;
ObjetoInfo[objectid][X] = ObjetoData[objectid][X];
ObjetoInfo[objectid][Y] = ObjetoData[objectid][Y];
ObjetoInfo[objectid][Z] = ObjetoData[objectid][Z];
ObjetoInfo[objectid][rX] = ObjetoData[objectid][rX];
ObjetoInfo[objectid][rY] = ObjetoData[objectid][rY];
ObjetoInfo[objectid][rZ] = ObjetoData[objectid][rZ];
CallRemoteFunction("OnObjectMoved", "i", objectid);
return 1;
}
#if defined _ALS_OnPlayerObjectMoved
#undef OnPlayerObjectMoved
#else
#define _ALS_OnPlayerObjectMoved
#endif
#define OnPlayerObjectMoved gb_OnPlayerObjectMoved
forward gb_OnPlayerObjectMoved(playerid, objectid);
#define CreateObject CreateObjectEx
#define MoveObject MoveObjectEx
#define StopObject StopObjectEx
#define SetObjectPos SetObjectPosEx
#define SetObjectRot SetObjectRotEx
#define DestroyObject DestroyObjectEx
#define IsValidObject IsValidObjectEx
#define GetObjectPos GetObjectPosEx
#define GetObjectRot GetObjectRotEx
Sorry my bad inglish, i'm used the ****** Translate, original topic: |
CNStramer - First Streamer of objects by Brazil
Primeiro Streamer do BRASIL postado aqui galera, nгo primeiro de todos...
Obrigado pelos comentarios, ******, estou a desenvolver uma nova atualizaзгo, obrigado pelas dicas. Translate for inglish: First of BRAZIL Streamer posted here guys, not first of all ... Thanks for the comments, ******, I am developing a new update, thanks for the tips. |