Advertisement
Guest User

V-Weapon 1.0

a guest
Apr 19th, 2012
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.99 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3.  
  4. #define DIALOG_WEAPONS 50000
  5.  
  6. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  7.  
  8. #define PRESSED(%0) \
  9.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  10.  
  11. #define COLOR_RED 0xFF0000AA
  12. #define COLOR_PURPLE 0x9E18E7FF
  13.  
  14. new PlayerWeapon1[MAX_PLAYERS] = 0, PlayerWeapon2[MAX_PLAYERS] = 0, PlayerWeapon3[MAX_PLAYERS] = 0;
  15. new TaktikObject[MAX_PLAYERS], TaktikToggle[MAX_PLAYERS] = 0;
  16. new Float:FPos[MAX_PLAYERS][3];
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.     print("\n--------------------------------------");
  21.     print("V-Weapons 1.0 Loaded...");
  22.     print("V-Weapons 1.0 by -Viper-");
  23.     print("--------------------------------------\n");
  24.     return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     return 1;
  30. }
  31.  
  32. public OnPlayerConnect(playerid)
  33. {
  34.     SetTimerEx("V_Weapons", 500, 1, "d", playerid);
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerDisconnect(playerid)
  39. {
  40.     DestroyObject(TaktikObject[playerid]);
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerSpawn(playerid)
  45. {
  46.     if(TaktikToggle[playerid] == 1)
  47.     {
  48.         DestroyObject(TaktikObject[playerid]);
  49.         SetPlayerPos(playerid, FPos[playerid][0], FPos[playerid][1], FPos[playerid][2]);
  50.         TaktikToggle[playerid] = 0;
  51.     }
  52.     return 1;
  53. }
  54.  
  55. public OnPlayerDeath(playerid, killerid, reason)
  56. {
  57.     RemovePlayerAttachedObject(playerid, 0);
  58.     RemovePlayerAttachedObject(playerid, 1);
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerCommandText(playerid, cmdtext[])
  63. {
  64.     dcmd(vhelp, 5, cmdtext);
  65.     dcmd(vweapon, 7, cmdtext);
  66.     dcmd(vweaponlist, 11, cmdtext);
  67.     return 0;
  68. }
  69.  
  70. dcmd_vhelp(playerid, params[])
  71. {
  72.     #pragma unused params
  73.     SendClientMessage(playerid, COLOR_PURPLE, "V-Weapons {FFFFFF}1.0{9E18E7} made by {FFFFFF}-Viper-");
  74.     SendClientMessage(playerid, COLOR_PURPLE, "V-Weapons Commands:");
  75.     SendClientMessage(playerid, COLOR_PURPLE, "{FFFFFF}/vhelp{9E18E7} - to see the Help");
  76.     SendClientMessage(playerid, COLOR_PURPLE, "{FFFFFF}/vweapon{9E18E7} - give a Player a Weapon");
  77.     SendClientMessage(playerid, COLOR_PURPLE, "{FFFFFF}/vweaponlist{9E18E7} - to see the new Weapon ID´s");
  78.     return 1;
  79. }
  80. dcmd_vweapon(playerid, params[])
  81. {
  82.     new pid, weaponid, weaponammo;
  83.     new string[128], YourName[20], GiveName[20];
  84.     if(sscanf(params,"ddd",pid,weaponid,weaponammo))
  85.     {
  86.         return SendClientMessage(playerid, COLOR_RED, "Usage: /vweapon [playerid] [weaponid] [weaponammo]");
  87.     }
  88.     if(!IsPlayerConnected(pid))
  89.     {
  90.         return SendClientMessage(playerid, COLOR_RED, "[ERROR]No one is online with this id!");
  91.     }
  92.     GetPlayerName(pid, GiveName, sizeof(GiveName));
  93.     GetPlayerName(playerid, YourName, sizeof(YourName));
  94.     V_GivePlayerWeapon(pid, weaponid, weaponammo);
  95.     format(string, sizeof(string), "V_GivePlayerWeapon: %s give %s a Weapon (%d) with %d Ammo", YourName, GiveName, weaponid, weaponammo);
  96.     SendClientMessageToAll(COLOR_PURPLE, string);
  97.     return 1;
  98. }
  99.  
  100. dcmd_vweaponlist(playerid, params[])
  101. {
  102.     #pragma unused params
  103.     SendClientMessage(playerid, 0xFFFFFFFF, "PSG - 47 | Nails Baseball Bat - 48 | Skull Bat - 49\nGuitar 1 - 50 | Guitar 2 - 51 | Guitar 3 - 52 | MP5 Elite - 53 | Tactical Insertion - 54");
  104.     return 1;
  105. }
  106.  
  107. forward V_Weapons(playerid);
  108. public V_Weapons(playerid)
  109. {
  110.     switch(GetPlayerWeapon(playerid))
  111.     {
  112.         case 0:
  113.         {
  114.             if(PlayerWeapon3[playerid] == 0)
  115.             {
  116.                 RemovePlayerAttachedObject(playerid, 0);
  117.                 RemovePlayerAttachedObject(playerid, 1);
  118.             }
  119.             else if(PlayerWeapon3[playerid] == 1)
  120.             {
  121.                 if(TaktikToggle[playerid] == 0)
  122.                 {
  123.                     SetPlayerAttachedObject(playerid, 0, 354, 5, 0.09, 0.00, -0.01, 0.0, 93.0, 0.0, 0.39, 0.43, 0.44);
  124.                     RemovePlayerAttachedObject(playerid, 1);
  125.                 }
  126.                 else if(TaktikToggle[playerid] == 1)
  127.                 {
  128.                     RemovePlayerAttachedObject(playerid, 0);
  129.                     RemovePlayerAttachedObject(playerid, 1);
  130.                 }
  131.             }
  132.         }
  133.         case 1..4:
  134.         {
  135.             RemovePlayerAttachedObject(playerid, 0);
  136.             RemovePlayerAttachedObject(playerid, 1);
  137.         }
  138.         case 5:
  139.         {
  140.             if(PlayerWeapon2[playerid] == 0)
  141.             {
  142.                 RemovePlayerAttachedObject(playerid, 0);
  143.                 RemovePlayerAttachedObject(playerid, 1);
  144.             }
  145.             else if(PlayerWeapon2[playerid] == 1)
  146.             {
  147.                 SetPlayerAttachedObject(playerid, 0, 2045, 6, 0.049999, 0.019999, 0.240000, 94.000000, 0.000000, 0.000000, 1.400000, 1.300000, 1.300000);
  148.                 RemovePlayerAttachedObject(playerid, 1);
  149.             }
  150.             else if(PlayerWeapon2[playerid] == 2)
  151.             {
  152.                 SetPlayerAttachedObject(playerid, 0, 3524, 6, 0.069999, 0.009999, 0.300000, 4.000000, 0.000000, 90.000000, 0.300000, 0.300000, 0.200000);
  153.                 RemovePlayerAttachedObject(playerid, 1);
  154.             }
  155.         }
  156.         case 6..14:
  157.         {
  158.             RemovePlayerAttachedObject(playerid, 0);
  159.             RemovePlayerAttachedObject(playerid, 1);
  160.         }
  161.         case 15:
  162.         {
  163.             if(PlayerWeapon2[playerid] == 0)
  164.             {
  165.                 RemovePlayerAttachedObject(playerid, 0);
  166.                 RemovePlayerAttachedObject(playerid, 1);
  167.             }
  168.             else if(PlayerWeapon2[playerid] == 3)
  169.             {
  170.                 SetPlayerAttachedObject(playerid, 0, 19317, 6, 0.07, 0.00, 0.41, 2.0, 181.0, 0.0, 1.00, 1.10, 1.00);
  171.                 RemovePlayerAttachedObject(playerid, 1);
  172.             }
  173.             else if(PlayerWeapon2[playerid] == 4)
  174.             {
  175.                 SetPlayerAttachedObject(playerid, 0, 19318, 6, 0.05, 0.00, 0.49, 3.0, 177.0, 1.0, 1.02, 1.21, 1.12);
  176.                 RemovePlayerAttachedObject(playerid, 1);
  177.             }
  178.             else if(PlayerWeapon2[playerid] == 5)
  179.             {
  180.                 SetPlayerAttachedObject(playerid, 0, 19319, 6, 0.09, 0.00, 0.42, 3.0, 179.0, -1.0, 1.04, 1.40, 1.00);
  181.                 RemovePlayerAttachedObject(playerid, 1);
  182.             }
  183.         }
  184.         case 16..24:
  185.         {
  186.             RemovePlayerAttachedObject(playerid, 0);
  187.             RemovePlayerAttachedObject(playerid, 1);
  188.         }
  189.         case 25:
  190.         {
  191.             RemovePlayerAttachedObject(playerid, 0);
  192.             RemovePlayerAttachedObject(playerid, 1);
  193.         }
  194.         case 26..28:
  195.         {
  196.             RemovePlayerAttachedObject(playerid, 0);
  197.             RemovePlayerAttachedObject(playerid, 1);
  198.         }
  199.         case 29:
  200.         {
  201.             if(PlayerWeapon1[playerid] == 0)
  202.             {
  203.                 RemovePlayerAttachedObject(playerid, 0);
  204.                 RemovePlayerAttachedObject(playerid, 1);
  205.             }
  206.             else if(PlayerWeapon1[playerid] == 2)
  207.             {
  208.                 SetPlayerAttachedObject(playerid, 1, 2036, 6, 0.180000, 0.009999, 0.170000, 90.000000, -7.000000, 7.000000, 0.299999, 0.500000, 0.380000);
  209.                 if (IsPlayerAiming(playerid))
  210.                 {
  211.                     if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  212.                     {
  213.                         SetPlayerAttachedObject(playerid, 0, 18643, 6, 0.298249, -0.02776, 0.158052, -11.631746, 359.302673, 357.584259);
  214.                     }
  215.                     else
  216.                     {
  217.                         SetPlayerAttachedObject(playerid, 0, 18643, 6, 0.298249, -0.02776, 0.158052, 8.368253, 358.302673, 352.584259);
  218.                     }
  219.                     }
  220.                     else
  221.                     {
  222.                     if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  223.                     {
  224.                         SetPlayerAttachedObject(playerid, 0, 18643, 6, 0.293249, -0.027759, 0.195051, -12.131746, 354.302734, 352.484222);
  225.                     }
  226.                     else
  227.                     {
  228.                         SetPlayerAttachedObject(playerid, 0, 18643, 6, 0.293249, -0.027759, 0.195051, -12.131746, 354.302734, 352.484222);
  229.                     }
  230.                 }
  231.             }
  232.         }
  233.         case 30..33:
  234.         {
  235.             RemovePlayerAttachedObject(playerid, 0);
  236.             RemovePlayerAttachedObject(playerid, 1);
  237.         }
  238.         case 34:
  239.         {
  240.             if(PlayerWeapon1[playerid] == 0)
  241.             {
  242.                 RemovePlayerAttachedObject(playerid, 0);
  243.                 RemovePlayerAttachedObject(playerid, 1);
  244.             }
  245.             else if(PlayerWeapon1[playerid] == 1)
  246.             {
  247.                 SetPlayerAttachedObject(playerid, 0, 2036, 6, 0.449999, 0.000000, 0.099999, 90.000000, -4.000000, 7.000000, 1.279999, 1.029999, 1.090000);
  248.                 RemovePlayerAttachedObject(playerid, 1);
  249.             }
  250.         }
  251.         case 35..46:
  252.         {
  253.             RemovePlayerAttachedObject(playerid, 0);
  254.             RemovePlayerAttachedObject(playerid, 1);
  255.         }
  256.     }
  257.     return 1;
  258. }
  259.  
  260. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  261. {
  262.     if(PRESSED(KEY_FIRE))
  263.     {
  264.         if(PlayerWeapon3[playerid] == 1)
  265.         {
  266.             if(GetPlayerWeapon(playerid) == 0)
  267.             {
  268.                 if(TaktikToggle[playerid] == 0)
  269.                 {
  270.                     GetPlayerPos(playerid, FPos[playerid][0], FPos[playerid][1], FPos[playerid][2]);
  271.                     TaktikToggle[playerid] = 1;
  272.                     TaktikObject[playerid] = CreateObject(354, FPos[playerid][0], FPos[playerid][1], FPos[playerid][2]-1, 0, 0, 0);
  273.                 }
  274.             }
  275.         }
  276.     }
  277.     return 1;
  278. }
  279.  
  280. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  281. {
  282.     return 1;
  283. }
  284.  
  285. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  286. {
  287.     new Float:health;
  288.     if(issuerid != INVALID_PLAYER_ID)
  289.     {
  290.         switch(GetPlayerWeapon(issuerid))
  291.         {
  292.             case 0..4: {}
  293.             case 5:
  294.             {
  295.                 if(PlayerWeapon2[issuerid] == 1)//Nate
  296.                 {
  297.                     GetPlayerHealth(playerid, health);
  298.                     SetPlayerHealth(playerid, health-8);
  299.                 }
  300.                 else if(PlayerWeapon2[issuerid] == 2)//Skull
  301.                 {
  302.                     GetPlayerHealth(playerid, health);
  303.                     SetPlayerHealth(playerid, health-7);
  304.                 }
  305.             }
  306.             case 6..14: {}
  307.             case 15:
  308.             {
  309.                 if(PlayerWeapon2[issuerid] == 3)//Guitar 1
  310.                 {
  311.                     GetPlayerHealth(playerid, health);
  312.                     SetPlayerHealth(playerid, health-5);
  313.                 }
  314.                 else if(PlayerWeapon2[issuerid] == 4)//Guitar 2
  315.                 {
  316.                     GetPlayerHealth(playerid, health);
  317.                     SetPlayerHealth(playerid, health-5);
  318.                 }
  319.                 else if(PlayerWeapon2[issuerid] == 5)//Guitar 3
  320.                 {
  321.                     GetPlayerHealth(playerid, health);
  322.                     SetPlayerHealth(playerid, health-5);
  323.                 }
  324.             }
  325.             case 16..28: {}
  326.             case 29:
  327.             {
  328.                 if(PlayerWeapon1[issuerid] == 2)//MP5 Elite
  329.                 {
  330.                     GetPlayerHealth(playerid, health);
  331.                     SetPlayerHealth(playerid, health-12);
  332.                 }
  333.             }
  334.             case 30..33: {}
  335.             case 34:
  336.             {
  337.                 if(PlayerWeapon1[issuerid] == 1)//PSG
  338.                 {
  339.                     GetPlayerHealth(playerid, health);
  340.                     SetPlayerHealth(playerid, health-53);
  341.                 }
  342.             }
  343.             case 35..46: {}
  344.         }
  345.     }
  346.     return 1;
  347. }
  348.  
  349. stock V_GivePlayerWeapon(playerid, weaponid, ammo)
  350. {
  351.     switch(weaponid)
  352.     {
  353.         case 1:{ GivePlayerWeapon(playerid, 1, ammo);PlayerWeapon2[playerid] = 0;}
  354.         case 2:{ GivePlayerWeapon(playerid, 2, ammo);PlayerWeapon2[playerid] = 0;}
  355.         case 3:{ GivePlayerWeapon(playerid, 3, ammo);PlayerWeapon2[playerid] = 0;}
  356.         case 4:{ GivePlayerWeapon(playerid, 4, ammo);PlayerWeapon2[playerid] = 0;}
  357.         case 5:{ GivePlayerWeapon(playerid, 5, ammo);PlayerWeapon2[playerid] = 0;}
  358.         case 6:{ GivePlayerWeapon(playerid, 6, ammo);PlayerWeapon2[playerid] = 0;}
  359.         case 7:{ GivePlayerWeapon(playerid, 7, ammo);PlayerWeapon2[playerid] = 0;}
  360.         case 8:{ GivePlayerWeapon(playerid, 8, ammo);PlayerWeapon2[playerid] = 0;}
  361.         case 9:{ GivePlayerWeapon(playerid, 9, ammo);PlayerWeapon2[playerid] = 0;}
  362.         case 10:{ GivePlayerWeapon(playerid, 10, ammo);PlayerWeapon2[playerid] = 0;}
  363.         case 11:{ GivePlayerWeapon(playerid, 11, ammo);PlayerWeapon2[playerid] = 0;}
  364.         case 12:{ GivePlayerWeapon(playerid, 12, ammo);PlayerWeapon2[playerid] = 0;}
  365.         case 13:{ GivePlayerWeapon(playerid, 13, ammo);PlayerWeapon2[playerid] = 0;}
  366.         case 14:{ GivePlayerWeapon(playerid, 14, ammo);PlayerWeapon2[playerid] = 0;}
  367.         case 15:{ GivePlayerWeapon(playerid, 15, ammo);PlayerWeapon2[playerid] = 0;}
  368.         case 16:{ GivePlayerWeapon(playerid, 16, ammo);}
  369.         case 17:{ GivePlayerWeapon(playerid, 17, ammo);}
  370.         case 18:{ GivePlayerWeapon(playerid, 18, ammo);}
  371.         case 22:{ GivePlayerWeapon(playerid, 22, ammo);}
  372.         case 23:{ GivePlayerWeapon(playerid, 23, ammo);}
  373.         case 24:{ GivePlayerWeapon(playerid, 24, ammo);}
  374.         case 25:{ GivePlayerWeapon(playerid, 25, ammo);PlayerWeapon1[playerid] = 0;}
  375.         case 26:{ GivePlayerWeapon(playerid, 26, ammo);PlayerWeapon1[playerid] = 0;}
  376.         case 27:{ GivePlayerWeapon(playerid, 27, ammo);PlayerWeapon1[playerid] = 0;}
  377.         case 28:{ GivePlayerWeapon(playerid, 28, ammo);PlayerWeapon1[playerid] = 0;}
  378.         case 29:{ GivePlayerWeapon(playerid, 29, ammo);PlayerWeapon1[playerid] = 0;}
  379.         case 30:{ GivePlayerWeapon(playerid, 30, ammo);PlayerWeapon1[playerid] = 0;}
  380.         case 31:{ GivePlayerWeapon(playerid, 31, ammo);PlayerWeapon1[playerid] = 0;}
  381.         case 32:{ GivePlayerWeapon(playerid, 32, ammo);PlayerWeapon1[playerid] = 0;}
  382.         case 33:{ GivePlayerWeapon(playerid, 33, ammo);PlayerWeapon1[playerid] = 0;}
  383.         case 34:{ GivePlayerWeapon(playerid, 34, ammo);PlayerWeapon1[playerid] = 0;}
  384.         case 35:{ GivePlayerWeapon(playerid, 35, ammo);PlayerWeapon1[playerid] = 0;}
  385.         case 36:{ GivePlayerWeapon(playerid, 36, ammo);PlayerWeapon1[playerid] = 0;}
  386.         case 37:{ GivePlayerWeapon(playerid, 37, ammo);}
  387.         case 38:{ GivePlayerWeapon(playerid, 38, ammo);}
  388.         case 39:{ GivePlayerWeapon(playerid, 39, ammo);}
  389.         case 40:{ GivePlayerWeapon(playerid, 40, ammo);}
  390.         case 41:{ GivePlayerWeapon(playerid, 41, ammo);}
  391.         case 42:{ GivePlayerWeapon(playerid, 42, ammo);}
  392.         case 43:{ GivePlayerWeapon(playerid, 43, ammo);}
  393.         case 44:{ GivePlayerWeapon(playerid, 44, ammo);}
  394.         case 45:{ GivePlayerWeapon(playerid, 45, ammo);}
  395.         case 46:{ GivePlayerWeapon(playerid, 46, ammo);}
  396.  
  397.         case 47: { GivePlayerWeapon(playerid, 34, ammo); PlayerWeapon1[playerid] = 1; }//PSG
  398.         case 48: { GivePlayerWeapon(playerid, 5, ammo); PlayerWeapon2[playerid] = 1; }//Nail
  399.         case 49: { GivePlayerWeapon(playerid, 5, ammo); PlayerWeapon2[playerid] = 2; }//Skull
  400.         case 50: { GivePlayerWeapon(playerid, 15, ammo); PlayerWeapon2[playerid] = 3; }//Guitar 1
  401.         case 51: { GivePlayerWeapon(playerid, 15, ammo); PlayerWeapon2[playerid] = 4; }//Guitar 2
  402.         case 52: { GivePlayerWeapon(playerid, 15, ammo); PlayerWeapon2[playerid] = 5; }//Guitar 3
  403.         case 53: { GivePlayerWeapon(playerid, 29, ammo); PlayerWeapon1[playerid] = 2; }//MP5 Elite
  404.         case 54: { PlayerWeapon3[playerid] = 1; }//Tactical
  405.     }
  406.     return 1;
  407. }
  408.  
  409. stock IsPlayerAiming(playerid)
  410. {
  411.     new anim = GetPlayerAnimationIndex(playerid);
  412.     if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) ||
  413.     (anim == 1643) || (anim == 1453) || (anim == 220))return 1;
  414.     return 0;
  415. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement