delaypawn

bfx_objects

Aug 11th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.01 KB | None | 0 0
  1. /*
  2. (c) 2008 - 2009 By BlackFoX_UD_
  3. -=-=-=- BFX STREAM -=-=-=-
  4. [ BETA 5 RELEASE ]
  5. */
  6. /*
  7. native b_CreateObject(modelid,Float:xx,Float:yy,Float:zz,Float:rxx,Float:ryy,Float:rzz,virtual_ww = -1);
  8. native b_SetObjectRot(objectid,Float:nxr,Float:nyr,Float:nzr);
  9. native b_MoveObject(objectid,Float:tox,Float:toy,Float:toz,Speedx);
  10. native b_SetObjectPos(objectid,Float:val_x,Float:val_y,Float:val_z);
  11. native b_DestroyObject(objectid);
  12. native b_PlayerDisconnect(playerid);
  13. native ObjektStream();
  14. native b_LinkToVirtualWorld(objectid,vw_id);
  15. */
  16. /*
  17. Es duerfen Maximal 149 Objekte an einem Punkt verwendet werden
  18. ansonsten kann es zum Crash fuehren
  19.  
  20. Have Fun
  21.  
  22. Mfg. BlackFoX_UD_
  23. */
  24. #define MAX_OBJEKTE 5000
  25. #define DISTANZ 142
  26. #define VERSIONA "v3.3 BETA"
  27. #define MAX_AREA_OBJEKTE 250
  28. #define IsPosInDistance(%0,%1,%2,%3,%4,%5,%6) \
  29.         (((%0 - %3) * (%0 - %3)) + ((%1 - %4) * (%1 - %4)) + ((%2 - %5) * (%2 - %5)) <= %6 * %6)
  30. new PLAYER_OBJEKTE[MAX_PLAYERS];
  31. //------------------------------------------------------------------------------
  32. enum objects
  33. {
  34.     modelu,
  35.     Float:x_val,
  36.     Float:y_val,
  37.     Float:z_val,
  38.     Float:rx_val,
  39.     Float:ry_val,
  40.     Float:rz_val,
  41.     exist,
  42.     obj_id,
  43.     virtual_world_object,
  44. }
  45. new Objekte[MAX_OBJEKTE][objects];
  46. new bool:CreatedObjekte[MAX_PLAYERS][MAX_OBJEKTE];
  47. new CreatedID[MAX_PLAYERS][MAX_OBJEKTE];
  48. //new Streamer;
  49. new now_idx;
  50. new Float:pttx[MAX_PLAYERS],Float:ptty[MAX_PLAYERS],Float:pttz[MAX_PLAYERS];
  51. //------------------------------------------------------------------------------
  52. stock b_CreateObject(modelid,Float:xx,Float:yy,Float:zz,Float:rxx,Float:ryy,Float:rzz,virtual_ww = -1)
  53. {
  54. now_idx++;
  55. Objekte[now_idx][modelu] = modelid;
  56. Objekte[now_idx][x_val] = Float:xx;
  57. Objekte[now_idx][y_val] = Float:yy;
  58. Objekte[now_idx][z_val] = Float:zz;
  59. Objekte[now_idx][rx_val] = Float:rxx;
  60. Objekte[now_idx][ry_val] = Float:ryy;
  61. Objekte[now_idx][rz_val] = Float:rzz;
  62. Objekte[now_idx][exist] = 1;
  63. Objekte[now_idx][obj_id] = now_idx;
  64. Objekte[now_idx][virtual_world_object] = virtual_ww;
  65. return now_idx;
  66. }
  67. //------------------------------------------------------------------------------
  68. stock b_LinkToVirtualWorld(objectid,vw_id)
  69. {
  70.     for(new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  71.     {
  72.         if(Objekte[objectid][exist] == 1)
  73.         {
  74.             if(CreatedObjekte[playerid][objectid] == true)
  75.             {
  76.                 DestroyPlayerObject(playerid,CreatedID[playerid][objectid]);
  77.                 CreatedObjekte[playerid][objectid] = false;
  78.                 Objekte[objectid][virtual_world_object] = vw_id;
  79.             }
  80.             else
  81.             {
  82.                 Objekte[objectid][virtual_world_object] = vw_id;
  83.             }
  84.         }
  85.     }
  86. }
  87. //------------------------------------------------------------------------------
  88. stock b_MoveObject(objectid,Float:tox,Float:toy,Float:toz,Float:Speedx)
  89. {
  90.     for(new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  91.     {
  92.         if(Objekte[objectid][exist] == 1)
  93.         {
  94.             if(CreatedObjekte[playerid][objectid] == true)
  95.             {
  96.                 Objekte[objectid][x_val] = Float:tox;
  97.                 Objekte[objectid][y_val] = Float:toy;
  98.                 Objekte[objectid][z_val] = Float:toz;
  99.                 MovePlayerObject(playerid,CreatedID[playerid][objectid],tox,toy,toz,Speedx);
  100.             }
  101.             else
  102.             {
  103.                 Objekte[objectid][x_val] = Float:tox;
  104.                 Objekte[objectid][y_val] = Float:toy;
  105.                 Objekte[objectid][z_val] = Float:toz;
  106.             }
  107.         }
  108.     }
  109. }
  110. //------------------------------------------------------------------------------
  111. stock b_SetObjectRot(objectid,Float:nxr,Float:nyr,Float:nzr)
  112. {
  113.     for(new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  114.     {
  115.         if(Objekte[objectid][exist] == 1)
  116.         {
  117.             if(CreatedObjekte[playerid][objectid] == true)
  118.             {
  119.                 SetPlayerObjectRot(playerid,CreatedID[playerid][objectid],nxr,nyr,nzr);
  120.                 Objekte[objectid][rx_val] = Float:nxr;
  121.                 Objekte[objectid][ry_val] = Float:nyr;
  122.                 Objekte[objectid][rz_val] = Float:nzr;
  123.             }
  124.             else
  125.             {
  126.                 Objekte[objectid][rx_val] = Float:nxr;
  127.                 Objekte[objectid][ry_val] = Float:nyr;
  128.                 Objekte[objectid][rz_val] = Float:nzr;
  129.             }
  130.         }
  131.     }
  132. }
  133. //------------------------------------------------------------------------------
  134. /*stock b_GameModeInit(){
  135. printf("[ Objects Streamed with BFX Object Streamer %s ]",VERSIONA);
  136. printf("[ Streamer Arbeitet Grade mit %d Prozent von %d Maxmimalen Objekten ]",ProzentWert(now_idx,MAX_OBJEKTE),MAX_OBJEKTE);
  137. Streamer = SetTimer("ObjektStream",1000,1);}*/
  138. //------------------------------------------------------------------------------
  139. //stock b_GameModeExit(){KillTimer(Streamer);}
  140. //------------------------------------------------------------------------------
  141. stock b_PlayerDisconnect(playerid)
  142. {
  143.     for(new oxt = 0;oxt<now_idx;oxt++)
  144.     {
  145.         if(CreatedObjekte[playerid][oxt] == true)
  146.         {
  147.             CreatedID[playerid][oxt] = -1;
  148.             CreatedObjekte[playerid][oxt] = false;
  149.         }
  150.         else
  151.         {
  152.             DestroyPlayerObject(playerid,CreatedID[playerid][oxt]);
  153.             CreatedID[playerid][oxt] = -1;
  154.             CreatedObjekte[playerid][oxt] = false;
  155.         }
  156.     }
  157.     PLAYER_OBJEKTE[playerid] = 0;
  158.     ptty[playerid] = (0.0);
  159.     pttx[playerid] = (0.0);
  160.     pttz[playerid] = (0.0);
  161. }
  162. //------------------------------------------------------------------------------
  163. stock b_SetObjectPos(objectid,Float:val_x,Float:val_y,Float:val_z)
  164. {
  165.     for(new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  166.     {
  167.         if(Objekte[objectid][exist] == 1)
  168.         {
  169.             if(CreatedObjekte[playerid][objectid] == true)
  170.             {
  171.                 SetPlayerObjectPos(playerid,CreatedID[playerid][objectid],val_x,val_y,val_z);
  172.                 Objekte[objectid][x_val] = Float:val_x;
  173.                 Objekte[objectid][y_val] = Float:val_y;
  174.                 Objekte[objectid][z_val] = Float:val_z;
  175.             }
  176.             else
  177.             {
  178.                 Objekte[objectid][x_val] = Float:val_x;
  179.                 Objekte[objectid][y_val] = Float:val_y;
  180.                 Objekte[objectid][z_val] = Float:val_z;
  181.             }
  182.         }
  183.     }
  184. }
  185. //------------------------------------------------------------------------------
  186. stock b_DestroyObject(objectid)
  187. {
  188.     for(new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  189.     {
  190.         if(Objekte[objectid][exist] == 1)
  191.         {
  192.             if(CreatedObjekte[playerid][objectid] == true)
  193.             {
  194.                 DestroyPlayerObject(playerid,CreatedID[playerid][objectid]);
  195.                 Objekte[objectid][exist] = 0;
  196.                 CreatedObjekte[playerid][objectid] = false;
  197.             }
  198.             else
  199.             {
  200.                 Objekte[objectid][exist] = 0;
  201.             }
  202.         }
  203.     }
  204. }
  205. //------------------------------------------------------------------------------
  206. forward ObjektStream(playerid);
  207. public ObjektStream(playerid)
  208. {
  209.     /*for(new playerid = 0;playerid<GetMaxPlayers();playerid++)
  210.     {*/
  211.         for(new o = 0;o<now_idx;o++)
  212.         {
  213.             if(IsPlayerConnected(playerid))
  214.             {
  215.                 if(GetPlayerPos(playerid,pttx[playerid],ptty[playerid],pttz[playerid]))
  216.                 {
  217.                     if(IsPosInDistance(pttx[playerid],ptty[playerid],pttz[playerid],Objekte[o][x_val],Objekte[o][y_val],Objekte[o][z_val],DISTANZ))
  218.                     {
  219.                         if(PLAYER_OBJEKTE[playerid] < MAX_AREA_OBJEKTE)
  220.                         {
  221.                             if(Objekte[o][exist] == 1)
  222.                             {
  223.                                 if(Objekte[o][virtual_world_object]!=-1)
  224.                                 {
  225.                                     if(GetPlayerVirtualWorld(playerid) == Objekte[o][virtual_world_object])
  226.                                     {
  227.                                         if(CreatedObjekte[playerid][o] == false)
  228.                                         {
  229.                                             CreatedID[playerid][o] = CreatePlayerObject(playerid,Objekte[o][modelu],Objekte[o][x_val],Objekte[o][y_val],Objekte[o][z_val],Objekte[o][rx_val],Objekte[o][ry_val],Objekte[o][rz_val]);
  230.                                             CreatedObjekte[playerid][o] = true;
  231.                                             PLAYER_OBJEKTE[playerid]++;
  232.                                         }
  233.                                     }
  234.                                 }
  235.                                 else if(Objekte[o][virtual_world_object] == -1)
  236.                                 {
  237.                                     if(CreatedObjekte[playerid][o] == false)
  238.                                     {
  239.                                         CreatedID[playerid][o] = CreatePlayerObject(playerid,Objekte[o][modelu],Objekte[o][x_val],Objekte[o][y_val],Objekte[o][z_val],Objekte[o][rx_val],Objekte[o][ry_val],Objekte[o][rz_val]);
  240.                                         CreatedObjekte[playerid][o] = true;
  241.                                         PLAYER_OBJEKTE[playerid]++;
  242.                                     }
  243.                                 }
  244.                             }
  245.                         }
  246.                     }
  247.                     else
  248.                     {
  249.                         if(Objekte[o][exist] == 1)
  250.                         {
  251.                             if(CreatedObjekte[playerid][o] == true)
  252.                             {
  253.                                 DestroyPlayerObject(playerid,CreatedID[playerid][o]);
  254.                                 CreatedID[playerid][o] = -1;
  255.                                 CreatedObjekte[playerid][o] = false;
  256.                                 PLAYER_OBJEKTE[playerid]--;
  257.                             }
  258.                         }
  259.                     }
  260.                 }
  261.             }
  262.         }
  263.  
  264.     //}
  265. }
  266. //------------------------------------------------------------------------------
  267. /*forward FreierSlot();
  268. public FreierSlot()
  269. {
  270. new freeS = 0;
  271. for(new i = 0;i<MAX_OBJEKTE;i++)
  272. {
  273.     if(freeS == 0)
  274.     {
  275.         if(Objekte[i][exist] == 0)
  276.         {
  277.         freeS = i;
  278.         }
  279.     }
  280. }
  281. return freeS;
  282. }*/
  283. //------------------------------------------------------------------------------
  284. stock ProzentWert(const Anteil,const Grundwert)return Anteil*100/Grundwert;
  285. //------------------------------------------------------------------------------
  286. stock b_OnPlayerUpdate(playerid)ObjektStream(playerid);
Add Comment
Please, Sign In to add comment