Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SA-MP Include Objects in VirtualWorlds
- *
- * (c) by Kaliber, 2013
- *
- * Version 1.0
- */
- #if !defined _samp_included
- #include <a_samp>
- #endif
- #if defined _objects_worlds
- #endinput
- #endif
- #define _objects_worlds 1
- #define INVALID_REQU 0
- #define INVALID_PARAM -1
- forward Stream_OnPlayerConnect(playerid);
- native Stream__CreateObject(modelid,Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ,Float:DrawDistance)=CreateObject;
- native Stream__IsValidObject(objectid)=IsValidObject;
- native Stream__IsObjectMoving(objectid)=IsObjectMoving;
- native Stream__SetObjectPos(objectid,Float:X,Float:Y,Float:Z)=SetObjectPos;
- native Stream__SetObjectRot(objectid,Float:rX,Float:rY,Float:rZ)=SetObjectRot;
- native Stream__GetObjectRot(objectid,&Float:rX,&Float:rY,&Float:rZ)=GetObjectRot;
- native Stream__GetObjectPos(objectid,&Float:X,&Float:Y,&Float:Z)=GetObjectPos;
- native Stream__StopObject(objectid)=StopObject;
- native Stream__AttachObjectToPlayer(objectid,playerid,Float:OffsetX,Float:OffsetY,Float:OffsetZ,Float:rX,Float:rY,Float:rZ)=AttachObjectToPlayer;
- native Stream__AttachObjectToVehicle(objectid,vehicleid,Float:OffsetX,Float:OffsetY,Float:OffsetZ,Float:RotX,Float:RotY,Float:RotZ)=AttachObjectToVehicle;
- native Stream__SetObjectMaterialText(objectid, text[], materialindex = 0, materialsize = OBJECT_MATERIAL_SIZE_256x128, fontface[] = "Arial", fontsize = 24, bold = 1, fontcolor = 0xFFFFFFFF, backcolor = 0, textalignment = 0)=SetObjectMaterialText;
- native Stream__SetObjectMaterial(objectid, materialindex, modelid, txdname[], texturename[], materialcolor)=SetObjectMaterial;
- native Stream__SetPlayerVirtualWorld(playerid, worldid)=SetPlayerVirtualWorld;
- native Stream__SetPlayerInterior(playerid, intid)=SetPlayerInterior;
- native Stream__MoveObject(objectid,Float:X,Float:Y,Float:Z,Float:Speed,Float:RotX,Float:RotY,Float:RotZ)=MoveObject;
- native Stream__DestroyObject(objectid)=DestroyObject;
- #define A:: e_F_
- enum A::ENUM{ A::model,A::int,Float:A::x,Float:A::y,Float:A::z,Float:A::rx,Float:A::ry,Float:A::rz,Float:A::dis,A::world };
- static obj[MAX_OBJECTS][A::ENUM],id,bool:buffer[MAX_PLAYERS][MAX_OBJECTS];
- stock Stream_SetObjectMaterial(objectid, materialindex, modelid, txdname[], texturename[], materialcolor) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- SetPlayerObjectMaterial(i, objectid+1, materialindex, modelid, txdname, texturename, materialcolor);
- }
- return 1;
- }
- #if defined _ALS_SetObjectMaterial
- #undef SetObjectMaterial
- #else
- #define _ALS_SetObjectMaterial
- #endif
- #define SetObjectMaterial Stream_SetObjectMaterial
- stock Stream_SetObjectMaterialText(objectid, text[], materialindex = 0, materialsize = OBJECT_MATERIAL_SIZE_256x128, fontface[] = "Arial", fontsize = 24, bold = 1, fontcolor = 0xFFFFFFFF, backcolor = 0, textalignment = 0) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- SetPlayerObjectMaterialText(i,objectid+1,text,materialindex,materialsize,fontface,fontsize,bold,fontcolor,backcolor,textalignment);
- }
- return 1;
- }
- #if defined _ALS_SetObjectMaterialText
- #undef SetObjectMaterialText
- #else
- #define _ALS_SetObjectMaterialText
- #endif
- #define SetObjectMaterialText Stream_SetObjectMaterialText
- stock Stream_AttachObjectToVehicle(objectid,vehicleid,Float:OffsetX,Float:OffsetY,Float:OffsetZ,Float:rX,Float:rY,Float:rZ) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- AttachPlayerObjectToVehicle(i,vehicleid,objectid+1,OffsetX,OffsetY,OffsetZ,rX,rY,rZ);
- }
- return 1;
- }
- #if defined _ALS_AttachObjectToVehicle
- #undef AttachObjectToVehicle
- #else
- #define _ALS_AttachObjectToVehicle
- #endif
- #define AttachObjectToVehicle Stream_AttachObjectToVehicle
- stock Stream_AttachObjectToPlayer(objectid,playerid,Float:OffsetX,Float:OffsetY,Float:OffsetZ,Float:rX,Float:rY,Float:rZ) {
- return AttachPlayerObjectToPlayer(playerid,objectid+1,playerid,OffsetX,OffsetY,OffsetZ,rX,rY,rZ);
- }
- #if defined _ALS_AttachObjectToPlayer
- #undef AttachObjectToPlayer
- #else
- #define _ALS_AttachObjectToPlayer
- #endif
- #define AttachObjectToPlayer Stream_AttachObjectToPlayer
- stock Stream_IsValidObject(objectid) {
- if(!obj[objectid][A::model] || objectid > id) return INVALID_REQU;
- return 1;
- }
- #if defined _ALS_IsValidObject
- #undef IsValidObject
- #else
- #define _ALS_IsValidObject
- #endif
- #define IsValidObject Stream_IsValidObject
- stock Stream_IsObjectMoving(objectid) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(IsPlayerObjectMoving(i,objectid+1)) return 1;
- }
- return INVALID_REQU;
- }
- #if defined _ALS_IsObjectMoving
- #undef IsObjectMoving
- #else
- #define _ALS_IsObjectMoving
- #endif
- #define IsObjectMoving Stream_IsObjectMoving
- stock Stream_StopObject(objectid) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- StopPlayerObject(i,objectid+1);
- }
- return INVALID_REQU;
- }
- #if defined _ALS_StopObject
- #undef StopObject
- #else
- #define _ALS_StopObject
- #endif
- #define StopObject Stream_StopObject
- stock Stream_SetObjectPos(objectid,Float:X,Float:Y,Float:Z) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- SetPlayerObjectPos(i,objectid+1,X,Y,Z);
- }
- obj[objectid][A::x]=X,obj[objectid][A::y]=Y,obj[objectid][A::z]=Z;
- return INVALID_REQU;
- }
- #if defined _ALS_SetObjectPos
- #undef SetObjectPos
- #else
- #define _ALS_SetObjectPos
- #endif
- #define SetObjectPos Stream_SetObjectPos
- stock Stream_SetObjectRot(objectid,Float:X,Float:Y,Float:Z) {
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- SetPlayerObjectRot(i,objectid+1,X,Y,Z);
- }
- obj[objectid][A::rx]=X,obj[objectid][A::ry]=Y,obj[objectid][A::rz]=Z;
- return INVALID_REQU;
- }
- #if defined _ALS_SetObjectRot
- #undef SetObjectRot
- #else
- #define _ALS_SetObjectRot
- #endif
- #define SetObjectRot Stream_SetObjectRot
- stock Stream_GetObjectRot(o,&Float:X,&Float:Y,&Float:Z) {
- return X=obj[o][A::rx],Y=obj[o][A::ry],Z=obj[o][A::rz];
- }
- #if defined _ALS_GetObjectRot
- #undef GetObjectRot
- #else
- #define _ALS_GetObjectRot
- #endif
- #define GetObjectRot Stream_GetObjectRot
- stock Stream_GetObjectPos(o,&Float:X,&Float:Y,&Float:Z) {
- return X=obj[o][A::x],Y=obj[o][A::y],Z=obj[o][A::z];
- }
- #if defined _ALS_GetObjectPos
- #undef GetObjectPos
- #else
- #define _ALS_GetObjectPos
- #endif
- #define GetObjectPos Stream_GetObjectPos
- stock Stream_CreateObject(modelid,Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ,Float:DrawDistance=300.0) {
- if(id==MAX_OBJECTS) return INVALID_PARAM;
- obj[id][A::model]=modelid,obj[id][A::x]=X,obj[id][A::y]=Y,obj[id][A::z]=Z,obj[id][A::rx]=rX,obj[id][A::ry]=rY,obj[id][A::rz]=rZ,obj[id][A::dis]=DrawDistance;
- obj[id][A::world]=999,obj[id][A::int]=999,id++;
- return id-1;
- }
- #if defined _ALS_CreateObject
- #undef CreateObject
- #else
- #define _ALS_CreateObject
- #endif
- #define CreateObject Stream_CreateObject
- stock Stream_MoveObject(objectid,Float:X,Float:Y,Float:Z,Float:Speed,Float:RotX=0.0,Float:RotY=0.0,Float:RotZ=0.0) {
- if(objectid > id) return INVALID_PARAM;
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- MovePlayerObject(i,objectid+1,Float:X,Float:Y,Float:Z,Float:Speed,Float:RotX,Float:RotY,Float:RotZ);
- }
- new q=objectid;
- obj[q][A::x]=X,obj[q][A::y]=Y,obj[q][A::z]=Z;
- if(RotX) obj[q][A::rx]=RotX;
- if(RotY) obj[q][A::ry]=RotY;
- if(RotZ) obj[q][A::rz]=RotZ;
- return 1;
- }
- #if defined _ALS_MoveObject
- #undef MoveObject
- #else
- #define _ALS_MoveObject
- #endif
- #define MoveObject Stream_MoveObject
- stock Stream_DestroyObject(objectid) {
- if(objectid > id) return INVALID_PARAM;
- for(new i; i<MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!Stream_Check(i,objectid)) continue;
- DestroyPlayerObject(i,objectid+1),buffer[i][objectid]=false;
- }
- return obj[objectid][A::model]=0,1;
- }
- #if defined _ALS_DestroyObject
- #undef DestroyObject
- #else
- #define _ALS_DestroyObject
- #endif
- #define DestroyObject Stream_DestroyObject
- stock Stream_SetPlayerVirtualWorld(playerid, worldid) {
- new intid = GetPlayerInterior(playerid),i;
- for(; i<id; i++) {
- if(World_Check(i,worldid,intid)) {
- if(buffer[playerid][i]) continue;
- buffer[playerid][i]=true;
- CreatePlayerObject(playerid,obj[i][A::model],obj[i][A::x],obj[i][A::y],obj[i][A::z],obj[i][A::rx],obj[i][A::ry],obj[i][A::rz],obj[i][A::dis]);
- } else DestroyPlayerObject(playerid,i+1),buffer[playerid][i]=false;
- }
- return Stream__SetPlayerVirtualWorld(playerid, worldid);
- }
- #if defined _ALS_SetPlayerVirtualWorld
- #undef SetPlayerVirtualWorld
- #else
- #define _ALS_SetPlayerVirtualWorld
- #endif
- #define SetPlayerVirtualWorld Stream_SetPlayerVirtualWorld
- stock Stream_SetPlayerInterior(playerid, intid) {
- new worldid = GetPlayerVirtualWorld(playerid),i;
- for(; i<id; i++) {
- if(World_Check(i,worldid,intid)) {
- if(buffer[playerid][i]) continue;
- buffer[playerid][i]=true;
- CreatePlayerObject(playerid,obj[i][A::model],obj[i][A::x],obj[i][A::y],obj[i][A::z],obj[i][A::rx],obj[i][A::ry],obj[i][A::rz],obj[i][A::dis]);
- } else DestroyPlayerObject(playerid,i+1),buffer[playerid][i]=false;
- }
- return Stream__SetPlayerInterior(playerid, intid);
- }
- #if defined _ALS_SetPlayerInterior
- #undef SetPlayerInterior
- #else
- #define _ALS_SetPlayerInterior
- #endif
- #define SetPlayerInterior Stream_SetPlayerInterior
- public OnPlayerConnect(playerid) {
- for(new i; i<id; i++) {
- if(!Stream_Check(playerid,i)) continue;
- buffer[playerid][i]=true;
- CreatePlayerObject(playerid,obj[i][A::model],obj[i][A::x],obj[i][A::y],obj[i][A::z],obj[i][A::rx],obj[i][A::ry],obj[i][A::rz],obj[i][A::dis]);
- }
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect Stream_OnPlayerConnect
- stock SetObjectVirtualWorld(object, worldid) {
- if(object > id) return INVALID_PARAM;
- return obj[object][A::world]=worldid;
- }
- stock GetObjectVirtualWorld(object) {
- if(object > id) return INVALID_PARAM;
- return obj[object][A::world];
- }
- stock SetObjectInterior(object, intid) {
- if(object > id) return INVALID_PARAM;
- return obj[object][A::int]=intid;
- }
- stock GetObjectInterior(object) {
- if(object > id) return INVALID_PARAM;
- return obj[object][A::int];
- }
- stock Stream_Check(i,q) {
- if(!obj[q][A::model]) return 0;
- if(obj[q][A::int] == 999 && obj[q][A::world] == 999) return 1;
- if(obj[q][A::world] == GetPlayerVirtualWorld(i) && obj[q][A::int] == GetPlayerInterior(i) || obj[q][A::world] == GetPlayerVirtualWorld(i) && obj[q][A::int] == 999 || obj[q][A::world] == 999 && obj[q][A::int] == GetPlayerInterior(i)) return 1;
- return 0;
- }
- stock World_Check(q,worldid,intid) {
- if(!obj[q][A::model]) return 0;
- if(obj[q][A::int] == 999 && obj[q][A::world] == 999) return 1;
- if(obj[q][A::world] == worldid && obj[q][A::int] == intid || obj[q][A::world] == worldid && obj[q][A::int] == 999 || obj[q][A::world] == 999 && obj[q][A::int] == intid) return 1;
- return 0;
- }
- #undef INVALID_PARAM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement