Share Pastebin
Guest
Public paste!

Hakam

By: a guest | Dec 17th, 2008 | Syntax: None | Size: 8.57 KB | Hits: 1,910 | Expires: Never
Copy text to clipboard
  1. #include <a_samp>
  2.  
  3. #define filterscript
  4. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  5. //*****EDIT BELOW THIS LINE:*****
  6. //------------------------------------------------------------------------------------------------------------------------------------------------------------
  7. #define DISTANCE_BETWEEN_PLAYERS 5 //The minimum distance between players to be able to rob                     |
  8. #define COLOR_ROB 0x00FFFFFF //The color of the text send to the players when made a successfull rob             |
  9. #define COLOR_FAIL 0x00FFFFFF //Color of the text displayed to the players when a rob has failed                        |
  10. #define COLOR_ERROR 0xFF0000FF //Color of the text when there is an error                                                                 |
  11. #define ROB_TIME 7000 //Time between rob commands to prevent spam (in milliseconds)                                      |
  12. //*****NO NEED TO EDIT BELOW THIS LINE:*****                                                                                                                       |
  13. //------------------------------------------------------------------------------------------------------------------------------------------------------------
  14.  
  15. new robtime[MAX_PLAYERS];
  16. new ID;
  17.  
  18.  
  19. stock Float:GetDistanceBetweenPlayers(p1,p2){
  20.         new Float:x1,Float:y1,Float:z1,Float:x3,Float:y3,Float:z3;
  21.         if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
  22.                 return -1.00;
  23.         }
  24.         GetPlayerPos(p1,x1,y1,z1);
  25.         GetPlayerPos(p2,x3,y3,z3);
  26.         return floatsqroot(floatpower(floatabs(floatsub(x3,x1)),2)+floatpower(floatabs(floatsub(y3,y1)),2)+floatpower(floatabs(floatsub(z3,z1)),2));
  27. }
  28.  
  29. forward robtimer(id);
  30.  
  31. dcmd_rob(playerid, params[])
  32.         {
  33.                 new pname[MAX_PLAYER_NAME];
  34.                 GetPlayerName(playerid, pname, sizeof(pname));
  35.                 if(!strlen(params))
  36.                 {
  37.                         SendClientMessage(playerid, COLOR_ERROR, "Correct usage: /rob [ID]");
  38.                 }
  39.                 else
  40.                 {
  41.                         ID = strval(params);
  42.                         if(robtime[playerid] == 0)
  43.                         {
  44.                                 if(ID != playerid)
  45.                                 {
  46.                                         if(IsPlayerConnected(ID))
  47.                                         {
  48.                                                 new oname[MAX_PLAYER_NAME];
  49.                                                 GetPlayerName(ID, oname, sizeof(oname));
  50.                                                 if(GetDistanceBetweenPlayers(playerid, ID) <= DISTANCE_BETWEEN_PLAYERS)
  51.                                                 {
  52.                                                         if(!GetPlayerVehicleID(ID) || GetPlayerVehicleID(ID) == GetPlayerVehicleID(ID))
  53.                                                         {
  54.                                                                 if(GetPlayerMoney(ID) > 0)
  55.                                                                 {
  56.                                                                         new rob = random(11);
  57.                                                                         if(rob == 1 || rob == 2 || rob == 10 || rob == 11)
  58.                                                                         {
  59.                                                                                 new string[256];
  60.                                                                                 format(string, sizeof(string), "%s (%i) noticed you trying to rob him. Attempt failed!",oname, ID);
  61.                                                                                 SendClientMessage(playerid, COLOR_ROB, string);
  62.                                                                                 format(string, sizeof(string), "~w~%s Noticed you trying to rob him.~n~Attempt failed!.",oname, ID);
  63.                                                                                 GameTextForPlayer(playerid, string, 5000, 4);
  64.                                                                                 GetPlayerName(playerid,pname,sizeof(pname));
  65.                                                                                 format(string, sizeof(string), "You noticed %s (%i) trying to rob you. His attempt has failed!", pname, playerid);
  66.                                                                                 SendClientMessage(ID, COLOR_ROB, string);
  67.                                                                                 format(string, sizeof(string), "~w~You noticed %s trying to rob you.~n~His attempt has failed!", pname, playerid);
  68.                                                                                 GameTextForPlayer(ID, string, 5000, 4);
  69.                                                                         }
  70.                                                                         else if(rob == 3)
  71.                                                                         {
  72.                                                                                 new pcash = GetPlayerMoney(ID);
  73.                                                                                 new robcash = random(pcash);
  74.                                                                         GivePlayerMoney(ID, -robcash);
  75.                                                                                 GivePlayerMoney(playerid, robcash);
  76.                                                                                 GetPlayerName(playerid, pname, sizeof(pname));
  77.                                                                                 new string[256];
  78.                                                                                 format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash, oname, ID);
  79.                                                                                 SendClientMessage(playerid, COLOR_ROB, string);
  80.                                                                                 format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash, oname);
  81.                                                                                 GameTextForPlayer(playerid, string, 5000, 4);
  82.                                                                                 format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash);
  83.                                                                                 SendClientMessage(ID, COLOR_ROB, string);
  84.                                                                                 format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash);
  85.                                                                                 GameTextForPlayer(ID, string, 5000, 4);
  86.                                                                         }
  87.                                                                         else if(rob == 4 || rob == 5 || rob == 8)
  88.                                                                         {
  89.                                                                                 new pcash = GetPlayerMoney(ID);
  90.                                                                                 new robcash = random(pcash);
  91.                                                                                 new robcash2 = robcash-random(robcash);
  92.                                                                         GivePlayerMoney(ID, -robcash2);
  93.                                                                                 GivePlayerMoney(playerid, robcash2);
  94.                                                                                 new string[256];
  95.                                                                                 GetPlayerName(playerid, pname, sizeof(pname));
  96.                                                                                 format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash2, oname, ID);
  97.                                                                                 SendClientMessage(playerid, COLOR_ROB, string);
  98.                                                                                 format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash2, oname);
  99.                                                                                 GameTextForPlayer(playerid, string, 5000, 4);
  100.                                                                                 format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash2);
  101.                                                                                 SendClientMessage(ID, COLOR_ROB, string);
  102.                                                                                 format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash2);
  103.                                                                                 GameTextForPlayer(ID, string, 5000, 4);
  104.                                                                         }
  105.                                                                         else if(rob == 6 || rob == 7)
  106.                                                                         {
  107.                                                                                 new pcash = GetPlayerMoney(ID);
  108.                                                                                 new robcash = random(pcash);
  109.                                                                                 new robcash2 = robcash-random(robcash);
  110.                                                                                 new robcash3 = robcash2-random(robcash2);
  111.                                                                         GivePlayerMoney(ID, -robcash3);
  112.                                                                                 GivePlayerMoney(playerid, robcash3);
  113.                                                                                 new string[256];
  114.                                                                                 GetPlayerName(playerid, pname, sizeof(pname));
  115.                                                                                 format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash3, oname, ID);
  116.                                                                                 SendClientMessage(playerid, COLOR_ROB, string);
  117.                                                                                 format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash3);
  118.                                                                                 SendClientMessage(ID, COLOR_ROB, string);
  119.                                                                                 format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash3, oname);
  120.                                                                                 GameTextForPlayer(playerid, string, 5000, 4);
  121.                                                                                 format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash3);
  122.                                                                                 GameTextForPlayer(ID, string, 5000, 4);
  123.                                                                         }
  124.                                                                         else
  125.                                                                         {
  126.                                                                                 SetPlayerHealth(playerid, -69);
  127.                                                                                 new string[256];
  128.                                                                                 GetPlayerName(playerid, pname, sizeof(pname));
  129.                                                                                 format(string, sizeof(string), "Your hand has stuck to %s (%i)'s pocket. ", oname, ID);
  130.                                                                                 SendClientMessage(playerid, COLOR_FAIL, string);
  131.                                                                                 SendClientMessage(playerid, COLOR_FAIL, "He noticed it and ripped your arms off.");
  132.                                                                                 format(string, sizeof(string), "%s (%i)'s hand has stuck to your pocket while trying to rob you.", pname, playerid);
  133.                                                                                 SendClientMessage(ID, COLOR_FAIL, string);
  134.                                                                                 SendClientMessage(ID, COLOR_FAIL, "You noticed it and ripped his arms off.");
  135.                                                                                 format(string, sizeof(string), "*** %s (%i) has bled to death.", pname, playerid);
  136.                                                                                 SendClientMessageToAll(0x880000FF, string);
  137.                                                                                 format(string, sizeof(string), "~w~%s has ripped your arms off.", oname, ID);
  138.                                                                                 GameTextForPlayer(playerid, string, 5000, 4);
  139.                                                                                 format(string, sizeof(string), "~w~Ripped %s's arms off.", oname, ID);
  140.                                                                                 GameTextForPlayer(ID, string, 5000, 4);
  141.                                                                         }
  142.                                                                         robtime[playerid] = 1;
  143.                                                                         SetTimerEx("robtimer", ROB_TIME, false, "i", playerid);
  144.                                                                 }
  145.                                                                 else
  146.                                                                 {
  147.                                                                         new string[256];
  148.                                                                         format(string, sizeof(string), "%s (%i) has no money to rob!", oname, ID);
  149.                                                                         SendClientMessage(playerid, COLOR_ERROR, string);
  150.                                                                 }
  151.                                                         }
  152.                                                         else
  153.                                                         {
  154.                                                                 new string[256];
  155.                                                                 format(string, sizeof(string), "%s (%i) has to be in the same vehicle as you to be able to rob!", oname, ID);
  156.                                                                 SendClientMessage(playerid, COLOR_ERROR, string);
  157.                                                         }
  158.                                                 }
  159.                                                 else
  160.                                                 {
  161.                                                         new string[256];
  162.                                                         format(string, sizeof(string), "%s (%i) is not close enough to rob.", oname, ID);
  163.                                                         SendClientMessage(playerid, COLOR_ERROR, string);
  164.                                                 }
  165.                                         }
  166.                                         else
  167.                                         {
  168.                                                 SendClientMessage(playerid, COLOR_ERROR, "That player is not connected!");
  169.                                         }
  170.                                 }
  171.                                 else
  172.                                 {
  173.                                         SendClientMessage(playerid, COLOR_ERROR, "You cannot rob yourself!");
  174.                                 }
  175.                         }
  176.                         else
  177.                         {
  178.                                 SendClientMessage(playerid, COLOR_ERROR, "Please wait before robbing someone again.");
  179.                         }
  180.                 }
  181.         return 1;
  182. }
  183.  
  184. public OnPlayerCommandText(playerid, cmdtext[])
  185. {
  186.         dcmd(rob, 3, cmdtext);
  187.         return 0;
  188. }
  189. public robtimer(id)
  190. {
  191.         robtime[id] = 0;
  192. }