Cypress

The Power Statue v0.3

Jun 6th, 2011
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.86 KB | None | 0 0
  1. /*
  2.                      The Power Statue v0.2
  3.                
  4.       Change-log:
  5.          v0.2
  6.             - Easy change of the statue position.
  7.          v0.3
  8.             - Improved scripting.
  9.             - Using foreach for looping though all players.
  10.       Credits:
  11.             - Zeex (zcmd)
  12.             - Y_Less (foreach)
  13.             - Me (for whole filterscript)
  14. */
  15.  
  16. #include <a_samp>
  17. #include <zcmd>
  18. #include <foreach>
  19.  
  20. #define MONEY_VALUE 1000  // Amount of money you want to give
  21. #define xpos  2845.6782  // The X cordinates
  22. #define ypos -2410.4414 // The y cordinates
  23. #define zpos  19.1922  // The z cordinates
  24.  
  25. new
  26.   bool:StatueOwner[MAX_PLAYERS],
  27.   Statue,
  28.   bool:StatueOwned,
  29.   DeleteStatueTime = 15
  30. ;
  31.  
  32. forward DropStatue(playerid);
  33. forward DeleteStatue( );
  34.  
  35. public OnPlayerConnect(playerid)
  36. {
  37.    StatueOwner[playerid] = false;
  38.    return 1;
  39. }
  40.  
  41. public OnFilterScriptInit()
  42. {
  43.     Statue = CreatePickup(1276, 3, xpos,ypos,zpos);
  44.     return 1;
  45. }
  46.  
  47. public DropStatue(playerid)
  48. {
  49.     if(StatueOwner[playerid] == true)
  50.     {
  51.         StatueOwner[playerid] = false;
  52.         StatueOwned = false;
  53.         new Float:x,Float:y,Float:z;
  54.         GetPlayerPos(playerid, x, y, z);
  55.         Statue = CreatePickup(1276, 3, x, y, z);
  56.         SetTimerEx("DeleteStatue", DeleteStatueTime*1000, false, "d", Statue);
  57.     }
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerPickUpPickup(playerid, pickupid)
  62. {
  63.     if(pickupid == Statue)
  64.     {
  65.        new string[128];
  66.        format(string,sizeof(string),"* %s has picked up the Statue.", pName(playerid));
  67.        SendClientMessageToAll(0x52AB5ADD, string);
  68.        StatueOwner[playerid] = true;
  69.        StatueOwned = true;
  70.        DestroyPickup(Statue);
  71.     }
  72.     return 1;
  73. }
  74.  
  75. public DeleteStatue( )
  76. {
  77.     DestroyPickup(Statue);
  78.     StatueOwned = false;
  79.     Statue = CreatePickup(1276, 3, xpos,ypos,zpos);
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerDisconnect(playerid, reason)
  84. {
  85.     if(StatueOwner[playerid] == true)
  86.     {
  87.       StatueOwner[playerid] = false;
  88.       StatueOwned = false;
  89.       DeleteStatue( );
  90.     }
  91.     return 1;
  92. }
  93.  
  94. public OnPlayerDeath(playerid, killerid, reason)
  95. {
  96.     if(StatueOwner[playerid] == true) DropStatue(playerid);
  97.     if(StatueOwner[killerid] == true)
  98.     {
  99.        GivePlayerMoney(killerid, MONEY_VALUE);
  100.        new string[50];
  101.        format(string, sizeof(string), "$%i", MONEY_VALUE);
  102.        GameTextForPlayer(killerid, string, 3000, 3);
  103.     }
  104.     return 1;
  105. }
  106.  
  107. COMMAND:statue(playerid, params[])
  108. {
  109.     if(StatueOwned == true)
  110.     {
  111.        foreach(Player, i)
  112.        {
  113.           if(StatueOwner[i] == true)
  114.           {
  115.              new string[128];
  116.              format(string,sizeof(string),"* The Statue is owned by %s.", pName(playerid));
  117.              SendClientMessage(playerid, 0x52AB5ADD, string);
  118.           }
  119.        }
  120.     }
  121.     else SendClientMessage(playerid,0x52AB5ADD,"The Statue has not owner.");
  122.     return 1;
  123. }
  124.  
  125. stock pName(playerid)
  126. {
  127.     new
  128.        Name[MAX_PLAYER_NAME];
  129.     GetPlayerName(playerid, Name, sizeof(Name));
  130.     return Name;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment