OKStyle

Advanced Weapons

Apr 2nd, 2012
497
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. // Advanced Weapons by O.K.Style™
  3. new AWName[] = {"гаечного ключа", "монтировки", "молотка", "фонарика", "электрошокера", "отвёртки", "граблей", "бензочлена", "басс-гитары", "флай-гитары", "варлок-гитары", "трости"};
  4. new AWDamage[12] = {25, 30, 35, 10, 30, 35, 25, 5, 15, 15, 15, 10};
  5. public OnPlayerCommandText(playerid, cmdtext[])
  6. {
  7.     new cmd[256], idx;
  8.     cmd = strtok(cmdtext, idx);
  9.    
  10.     if(strcmp(cmd, "/aw", true) == 0)
  11.     {
  12.         new tmp[30];
  13.         tmp = strtok(cmdtext, idx);
  14.         if(strlen(tmp) < 1) return SendClientMessage(playerid, -1, "{BCBCBC}Синтаксис: /aw [awid]");
  15.         new aw = strval(tmp);
  16.         if(aw < 1 || aw > 10) return SendClientMessage(playerid, -1, "{FDE39D}Данный ID дополнительного оружия не существует.");
  17.         new slot = GetPVarInt(playerid, "AWSlot");
  18.         if(slot > 0) RemovePlayerAttachedObject(playerid, slot);
  19.         slot = -1;
  20.         for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  21.         {
  22.             if(IsPlayerAttachedObjectSlotUsed(playerid, i)) continue;
  23.             slot = i;
  24.             SetPVarInt(playerid, "AWSlot", slot);
  25.             break;
  26.         }
  27.         if(slot == -1) return SendClientMessage(playerid, -1, "{FDE39D}У Вашего персонажа нет свободных слотов для аттача.");
  28.         SetPVarInt(playerid, "AdvWeap", aw);
  29.         switch(aw)
  30.         {
  31.             case 1: SetPlayerAttachedObject(playerid, slot, 18633, 6, 0.074999, 0.023999, 0.053999, 104.199981, -91.499992, 1.500003, 1.000000, 1.000000, 1.000000);
  32.             case 2: SetPlayerAttachedObject(playerid, slot, 18634, 6, 0.054000, 0.013999, -0.087999, -94.399963, -25.899974, 175.799911, 1.000000, 1.000000, 1.000000);
  33.             case 3: SetPlayerAttachedObject(playerid, slot, 18635, 6, -0.004000, -0.008000, -0.073000, 3.299994, 0.000000, -6.100000, 1.000000, 1.000000, 1.000000);
  34.             case 4: SetPlayerAttachedObject(playerid, slot, 18641, 6, 0.057999, 0.023000, 0.050000, 0.000000, 167.599990, 0.000000, 1.000000, 1.000000, 1.000000);
  35.             case 5: SetPlayerAttachedObject(playerid, slot, 18642, 6, 0.051000, 0.009000, 0.041999, -172.099929, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000);
  36.             case 6: SetPlayerAttachedObject(playerid, slot, 18644, 6, 0.072999, 0.007999, -0.006999, 178.700027, 0.000000, -3.599997, 1.000000, 1.000000, 1.000000);
  37.             case 7: SetPlayerAttachedObject(playerid, slot, 18890, 6, -0.021999, 0.030000, -0.243999, -174.999984, -0.199999, -92.600028, 1.000000, 1.000000, 1.000000);
  38.             case 8: SetPlayerAttachedObject(playerid, slot, 19086, 6, 0.000000, 0.007999, 0.023000, 1.499997, -93.900032, 0.000000, 1.000000, 1.000000, 1.000000);
  39.             case 9: SetPlayerAttachedObject(playerid, slot, 19317, 6, 0.073999, 0.030000, 0.150000, -177.400024, -4.500000, -4.199998, 1.000000, 1.000000, 1.000000);
  40.             case 10: SetPlayerAttachedObject(playerid, slot, 19318, 6, 0.054000, 0.011999, 0.197000, 0.000000, 177.300048, -171.399917, 1.000000, 1.000000, 1.000000);
  41.             case 11: SetPlayerAttachedObject(playerid, slot, 19319, 6, 0.049999, 0.008000, 0.240000, -176.999954, 0.000000, -12.299943, 1.000000, 1.000000, 1.000000);
  42.             case 12: SetPlayerAttachedObject(playerid, slot, 19348, 6, 0.050999, 0.043000, 0.353999, 175.300033, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000);
  43.             default: return 1;
  44.         }
  45.         new string[128];
  46.         format(string, sizeof(string), "{FDE39D}Вы стали обладателем %s.", AWName[aw]);
  47.         SendClientMessage(playerid, -1, string);
  48.         return 1;
  49.     }
  50.     return 1;
  51. }
  52. public OnPlayerDeath(playerid, killerid, reason)
  53. {
  54.     #pragma unused reason
  55.     if(killerid == INVALID_PLAYER_ID) return 1;
  56.     new aw = GetPVarInt(killerid, "AdvWeap");
  57.     if(aw != 0)
  58.     {
  59.         new string[128], PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME];
  60.         GetPlayerName(playerid, TargetName, sizeof(TargetName));
  61.         GetPlayerName(killerid, PlayerName, sizeof(PlayerName));
  62.         format(string, sizeof(string), "{FFFFFF}Игрок {FDE39D}%s {FFFFFF}был убит игроком {FDE39D}%s {FFFFFF}с помощью {FDE39D}%s{FFFFFF}.", TargetName, PlayerName, AWName[aw]);
  63.         SendClientMessageToAll(-1, string);
  64.         return 1;
  65.     }
  66.     return 1;
  67. }
  68. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  69. {
  70.     if(issuerid != INVALID_PLAYER_ID)
  71.     {
  72.         if(weaponid == 0)
  73.         {
  74.             new aw = GetPVarInt(issuerid, "AdvWeap");
  75.             new Float:hp;
  76.             GetPlayerHealth(playerid, hp);
  77.             SetPlayerHealth(playerid, hp + amount - AWDamage[aw]);
  78.         }
  79.     }
  80.     return 1;
  81. }
  82. stock strtok(const string[], &index)
  83. {
  84.     new length = strlen(string);
  85.     while ((index < length) && (string[index] <= ' ')) index++;
  86.     new offset = index, result[20];
  87.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  88.     {
  89.         result[index - offset] = string[index];
  90.         index++;
  91.     }
  92.     result[index - offset] = EOS;
  93.     return result;
  94. }
RAW Paste Data