Advertisement
Guest User

[MAP] Mount Chilliad - BY: _Infanticida_

a guest
Jul 14th, 2010
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.07 KB | None | 0 0
  1. /*
  2. Criado por _Infanticida_, favor não retirar os créditos !!!
  3. */
  4. #include <a_samp>
  5.  
  6. forward Timer();
  7. forward SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z);
  8. /*
  9.     SetPlayerPosWithObjects usage in your gamemode:
  10.  
  11.         CallRemoteFunction("SetPlayerPosWithObjects","ifff",playerid,newx,newy,newz);
  12. */
  13.  
  14. //------------------------------------------------------------------------------
  15. //------------------------------------------------------------------------------
  16.  
  17. bool:IsInReach(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:dist)
  18. {
  19.     x = (x > x2) ? x - x2 : x2 - x;
  20.     if(x > dist) return false;
  21.     y = (y > y2) ? y - y2 : y2 - y;
  22.     if(y > dist) return false;
  23.     z = (z > z2) ? z - z2 : z2 - z;
  24.     if(z > dist) return false;
  25.     return true;
  26. }
  27.  
  28. //------------------------------------------------------------------------------
  29.  
  30. new timer;
  31.  
  32. public OnFilterScriptInit()
  33. {
  34.     print("---\nLoaded xObjects by Boylett\n---");
  35.     timer = SetTimer("Timer",500,1);
  36.     return 1;
  37. }
  38.  
  39. public OnFilterScriptExit()
  40. {
  41.     for(new i = 0; i < MAX_PLAYERS; i++)
  42.     {
  43.         for(new o = 0; o < sizeof(Objects); o++)
  44.         {
  45.             if(Player[i][view][o])
  46.             {
  47.                 Player[i][view][o] = false;
  48.                 DestroyPlayerObject(i,Player[i][objid][o]);
  49.             }
  50.         }
  51.     }
  52.    
  53.     KillTimer(timer);
  54. }
  55.  
  56. //------------------------------------------------------------------------------
  57.  
  58. public OnPlayerConnect(playerid)
  59. {
  60.     for(new i = 0; i < sizeof(Objects); i++) Player[playerid][view][i] = false;
  61. }
  62.  
  63. public OnPlayerDisconnect(playerid)
  64. {
  65.     for(new i = 0; i < sizeof(Objects); i++)
  66.     {
  67.         if(Player[playerid][view][i])
  68.         {
  69.             Player[playerid][view][i] = false;
  70.             DestroyPlayerObject(playerid,Player[playerid][objid][i]);
  71.         }
  72.     }
  73. }
  74.  
  75. //------------------------------------------------------------------------------
  76.  
  77. public Timer()
  78. {
  79.     for(new i = 0; i < MAX_PLAYERS; i++)
  80.         if(IsPlayerConnected(i))
  81.             PlayerObjectUpdate(i);
  82. }
  83.  
  84. PlayerObjectUpdate(playerid)
  85. {
  86.     new Float:pos[3];
  87.     GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  88.     for(new i = 0; i < sizeof(Objects); i++)
  89.     {
  90.         if(!Player[playerid][view][i])
  91.         {
  92.             if(IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  93.             {
  94.                 Player[playerid][view][i] = true;
  95.                 Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
  96.             }
  97.         } else if(!IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  98.         {
  99.             Player[playerid][view][i] = false;
  100.             DestroyPlayerObject(playerid,Player[playerid][objid][i]);
  101.         }
  102.     }
  103. }
  104.  
  105. public SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z)
  106. {
  107.     for(new i = 0; i < sizeof(Objects); i++)
  108.     {
  109.         if(!Player[playerid][view][i])
  110.         {
  111.             if(IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  112.             {
  113.                 Player[playerid][view][i] = true;
  114.                 Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
  115.             }
  116.         } else if(!IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  117.         {
  118.             Player[playerid][view][i] = false;
  119.             DestroyPlayerObject(playerid,Player[playerid][objid][i]);
  120.         }
  121.     }
  122.     SetPlayerPos(playerid,Float:x,Float:y,Float:z);
  123. }
  124.  
  125. public OnPlayerSpawn(playerid)
  126.     PlayerObjectUpdate(playerid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement