Advertisement
GTAProgramming

CPF - Custom Player Functions [Arrumado]

May 18th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.75 KB | None | 0 0
  1. /*
  2.  
  3.  
  4.             CPF Include - Custom Player Functions
  5.            
  6.             Uncomplicated Way To Program!
  7.            
  8.             Author: FuneraL
  9.             Release Date: 13/05/2013 (05/13/2013 MM/DD/AAAA)
  10.            
  11.             Native Functions:
  12.            
  13.             SetPlayerPosEx(playerid, PosX, PosY, PosZ, Int, World);
  14.             GetPlayerDataPos(playerid);
  15.             SetPlayerAllStats(playerid, Score, Money, Health, Armour, Name);
  16.             GetPlayerAllStats(playerid);
  17.             SetPlayerCustomHP(playerid, Health, Armour);
  18.             GiveVehicleForPlayer(playerid, Vehicleid, Angle, VehicleColor, VehicleColor2, Respawn_Delay);
  19.             RemoveVehicleForPlayer(playerid);
  20.             SetPlayerVehiclePosEx(playerid, PosX, PosY, PosZ, Int, World);
  21.             GivePlayerWeaponKit(playerid, Weapon, Weapon_Ammo, Weapon2, Weapon_Ammo2, Weapon3, Weapon_Ammo3);
  22.             SetPlayerWeatherEx(playerid, Hour, Weather);
  23.             GetGunName(gunid);
  24.             GetPlayerGunName(playerid);
  25.  
  26.            
  27. */
  28.  
  29.  
  30. #if defined _CPF_included
  31.     #endif
  32. #define _CPF_included
  33. #pragma library CPF
  34.  
  35. #include <a_samp>
  36.  
  37. #define CPF_Function::%0(%1) stock %0(%1)
  38.  
  39. new CPF_Vehicle[MAX_PLAYERS];
  40.  
  41. CPF_Function::SetPlayerPosEx(playerid, Float:pX, Float:pY, Float:pZ, interior = 0, world = 0) {
  42.     SetPlayerPos(playerid, pX, pY, pZ);
  43.     SetPlayerInterior(playerid, interior);
  44.     SetPlayerVirtualWorld(playerid, world);
  45.     return true;
  46. }
  47.  
  48. CPF_Function::GetPlayerDataPos(playerid) {
  49.     new Float:pX, Float:pY, Float:pZ, CPF_String[120];
  50.     GetPlayerPos(playerid, pX, pY, pZ);
  51.     format(CPF_String, sizeof(CPF_String), "Information Database ->\nPosition: X: %.0f, Y: %.0f, Z: %.0f\nInterior: %d\nWorld: %d", pX, pY, pZ, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
  52.     return CPF_String;
  53. }
  54.  
  55. CPF_Function::SetPlayerAllStats(playerid, score = 0, money = 0, Float:health, Float:armour, name[]) {
  56.     SetPlayerScore(playerid, score);
  57.     ResetPlayerMoney(playerid);
  58.     GivePlayerMoney(playerid, money);
  59.     SetPlayerHealth(playerid, health);
  60.     SetPlayerArmour(playerid, armour);
  61.     SetPlayerName(playerid, name);
  62.     return true;
  63. }
  64.  
  65. CPF_Function::GetPlayerAllStats(playerid) {
  66.     new score, money, Float:health, Float:armour, name[24], CPF_String[200];
  67.     GetPlayerHealth(playerid, health);
  68.     GetPlayerArmour(playerid, armour);
  69.     GetPlayerName(playerid, name, 24);
  70.     format(CPF_String, sizeof(CPF_String), "Information Database ->\nPlayer Score: %d\nPlayer Money: %d\nPlayer Health: %.0f\nPlayer Armour: %.0f\nPlayer Name: %s", score, money, health, armour, name);
  71.     return CPF_String;
  72. }
  73.  
  74. CPF_Function::SetPlayerCustomHP(playerid, Float:health, Float:armour) {
  75.     SetPlayerHealth(playerid, health);
  76.     SetPlayerArmour(playerid, armour);
  77.     return true;
  78. }
  79.  
  80. CPF_Function::GiveVehicleForPlayer(playerid, vehicleid, Float:vehicleangle, vehiclecolor = 0, vehiclecolor2 = 0, respawndelay) {
  81.     new Float:pX, Float:pY, Float:pZ;
  82.     GetPlayerPos(playerid, pX, pY, pZ);
  83.     GetPlayerFacingAngle(playerid, vehicleangle);
  84.     CPF_Vehicle[playerid] = CreateVehicle(vehicleid, pX, pY, pZ, vehicleangle, vehiclecolor, vehiclecolor2, respawndelay);
  85.     PutPlayerInVehicle(playerid, CPF_Vehicle[playerid], 0);
  86.     return true;
  87. }
  88.  
  89. CPF_Function::RemoveVehicleForPlayer(playerid) {
  90.     DestroyVehicle(CPF_Vehicle[playerid]);
  91.     return true;
  92. }
  93.  
  94. CPF_Function::SetPlayerVehiclePosEx(playerid, Float:pX, Float:pY, Float:pZ, interior = 0, world = 0) {
  95.     SetVehiclePos(CPF_Vehicle[playerid], pX, pY, pZ);
  96.     LinkVehicleToInterior(CPF_Vehicle[playerid], interior);
  97.     SetVehicleVirtualWorld(CPF_Vehicle[playerid], world);
  98.     return true;
  99. }
  100.  
  101. CPF_Function::GivePlayerWeaponKit(playerid, weapon1, weapon_ammo1, weapon2, weapon_ammo2, weapon3, weapon_ammo3) {
  102.     GivePlayerWeapon(playerid, weapon1, weapon_ammo1);
  103.     GivePlayerWeapon(playerid, weapon2, weapon_ammo2);
  104.     GivePlayerWeapon(playerid, weapon3, weapon_ammo3);
  105.     return true;
  106. }
  107.  
  108. CPF_Function::SetPlayerWeatherEx(playerid, hour = 0, weather = 0) {
  109.     SetPlayerTime(playerid, hour, hour);
  110.     SetPlayerWeather(playerid, weather);
  111.     return true;
  112. }
  113.  
  114. CPF_Function::GetGunName(gunid) {
  115.     new CPF_GunName[50];
  116.     switch(gunid) {
  117.         case 0: CPF_GunName = "INVALID_WEAPON_ID";
  118.         case 1: CPF_GunName = "Brass Knuckles";
  119.         case 2: CPF_GunName = "Golf Club";
  120.         case 3: CPF_GunName = "Nightstick";
  121.         case 4: CPF_GunName = "Knife";
  122.         case 5: CPF_GunName = "Baseball Bat";
  123.         case 6: CPF_GunName = "Shovel";
  124.         case 7: CPF_GunName = "Pool Cue";
  125.         case 8: CPF_GunName = "Katana";
  126.         case 9: CPF_GunName = "Chainsaw";
  127.         case 10: CPF_GunName = "Double-ended Dildo";
  128.         case 11: CPF_GunName = "Dildo";
  129.         case 12: CPF_GunName = "Vibrator";
  130.         case 13: CPF_GunName = "Silver Vibrator";
  131.         case 14: CPF_GunName = "Flowers";
  132.         case 15: CPF_GunName = "Cane";
  133.         case 16: CPF_GunName = "Grenade";
  134.         case 17: CPF_GunName = "Tear Gas";
  135.         case 18: CPF_GunName = "Molotov Cocktail";
  136.         case 19: CPF_GunName = "INVALID_WEAPON_ID";
  137.         case 20: CPF_GunName = "INVALID_WEAPON_ID";
  138.         case 21: CPF_GunName = "INVALID_WEAPON_ID";
  139.         case 22: CPF_GunName = "9mm";
  140.         case 23: CPF_GunName = "Silenced 9mm";
  141.         case 24: CPF_GunName = "Shotgun";
  142.         case 25: CPF_GunName = "INVALID_WEAPON_ID";
  143.         case 26: CPF_GunName = "Sawnoff-Shotgun";
  144.         case 27: CPF_GunName = "Combat Shotgun";
  145.         case 28: CPF_GunName = "Micro-Uzi";
  146.         case 29: CPF_GunName = "MP5";
  147.         case 30: CPF_GunName = "AK-47";
  148.         case 31: CPF_GunName = "M4";
  149.         case 32: CPF_GunName = "Tec-9";
  150.         case 33: CPF_GunName = "Country Rifle";
  151.         case 34: CPF_GunName = "Sniper Rifle";
  152.         case 35: CPF_GunName = "RPG";
  153.         case 36: CPF_GunName = "HS Rocket";
  154.         case 37: CPF_GunName = "Flamethrower";
  155.         case 38: CPF_GunName = "Minigun";
  156.         case 39: CPF_GunName = "Satchel Charge";
  157.         case 40: CPF_GunName = "Detonator";
  158.         case 41: CPF_GunName = "Spraycan";
  159.         case 42: CPF_GunName = "Fire Extinguisher";
  160.         case 43: CPF_GunName = "Camera";
  161.         case 44: CPF_GunName = "Night Vision Goggles";
  162.         case 45: CPF_GunName = "Thermal Goggles";
  163.         case 46: CPF_GunName = "Parachute";
  164.     }
  165.     return CPF_GunName;
  166. }
  167.  
  168. CPF_Function::GetPlayerGunName(playerid) {
  169.     new CPF_GunName[50];
  170.     new gunid = GetPlayerWeapon(playerid);
  171.     switch(gunid) {
  172.         case 0: CPF_GunName = "INVALID_WEAPON_ID";
  173.         case 1: CPF_GunName = "Brass Knuckles";
  174.         case 2: CPF_GunName = "Golf Club";
  175.         case 3: CPF_GunName = "Nightstick";
  176.         case 4: CPF_GunName = "Knife";
  177.         case 5: CPF_GunName = "Baseball Bat";
  178.         case 6: CPF_GunName = "Shovel";
  179.         case 7: CPF_GunName = "Pool Cue";
  180.         case 8: CPF_GunName = "Katana";
  181.         case 9: CPF_GunName = "Chainsaw";
  182.         case 10: CPF_GunName = "Double-ended Dildo";
  183.         case 11: CPF_GunName = "Dildo";
  184.         case 12: CPF_GunName = "Vibrator";
  185.         case 13: CPF_GunName = "Silver Vibrator";
  186.         case 14: CPF_GunName = "Flowers";
  187.         case 15: CPF_GunName = "Cane";
  188.         case 16: CPF_GunName = "Grenade";
  189.         case 17: CPF_GunName = "Tear Gas";
  190.         case 18: CPF_GunName = "Molotov Cocktail";
  191.         case 19: CPF_GunName = "INVALID_WEAPON_ID";
  192.         case 20: CPF_GunName = "INVALID_WEAPON_ID";
  193.         case 21: CPF_GunName = "INVALID_WEAPON_ID";
  194.         case 22: CPF_GunName = "9mm";
  195.         case 23: CPF_GunName = "Silenced 9mm";
  196.         case 24: CPF_GunName = "Shotgun";
  197.         case 25: CPF_GunName = "INVALID_WEAPON_ID";
  198.         case 26: CPF_GunName = "Sawnoff-Shotgun";
  199.         case 27: CPF_GunName = "Combat Shotgun";
  200.         case 28: CPF_GunName = "Micro-Uzi";
  201.         case 29: CPF_GunName = "MP5";
  202.         case 30: CPF_GunName = "AK-47";
  203.         case 31: CPF_GunName = "M4";
  204.         case 32: CPF_GunName = "Tec-9";
  205.         case 33: CPF_GunName = "Country Rifle";
  206.         case 34: CPF_GunName = "Sniper Rifle";
  207.         case 35: CPF_GunName = "RPG";
  208.         case 36: CPF_GunName = "HS Rocket";
  209.         case 37: CPF_GunName = "Flamethrower";
  210.         case 38: CPF_GunName = "Minigun";
  211.         case 39: CPF_GunName = "Satchel Charge";
  212.         case 40: CPF_GunName = "Detonator";
  213.         case 41: CPF_GunName = "Spraycan";
  214.         case 42: CPF_GunName = "Fire Extinguisher";
  215.         case 43: CPF_GunName = "Camera";
  216.         case 44: CPF_GunName = "Night Vision Goggles";
  217.         case 45: CPF_GunName = "Thermal Goggles";
  218.         case 46: CPF_GunName = "Parachute";
  219.     }
  220.     return CPF_GunName;
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement