Advertisement
Shiny_

Untitled

Oct 2nd, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.90 KB | None | 0 0
  1. namespace Core {
  2.     #include <conio.h>
  3.     #include <cstdlib>
  4.     #include <ctime>
  5.     #include <iostream>
  6.     #include <string>
  7.  
  8.     /* SA-MP GDK: */
  9.     #include <sampgdk/a_objects.hpp>
  10.     #include <sampgdk/a_players.hpp>
  11.     #include <sampgdk/a_samp.hpp>
  12.     #include <sampgdk/a_vehicles.hpp>
  13.     #include <sampgdk/core.hpp>
  14.     #include <sampgdk/plugin.h>
  15.  
  16.     #pragma comment(lib, "sampgdk3.lib")
  17.    
  18.     class CPSD {
  19.         public:
  20.             int pSpeed[MAX_PLAYERS];
  21.             int VelocityTimer[MAX_PLAYERS];
  22.             int BindKey_(char * key);
  23.             int IsVehiclePlaneOrHelicopter(int vehicleid);
  24.            
  25.             char str[MAX_PLAYERS][170];
  26.             char Speed3DText[MAX_PLAYERS];
  27.             char CarFireObject[MAX_PLAYERS];
  28.             char Name[MAX_PLAYERS][MAX_PLAYER_NAME];
  29.  
  30.             float Pos[MAX_PLAYERS][3];
  31.             float Health[MAX_PLAYERS];
  32.             float xyz[MAX_PLAYERS][3];
  33.             float GetSpeed(int playerid);
  34.             float SetSpeed(int playerid);
  35.            
  36.             ~CPSD();
  37.            
  38.             inline bool PlayAudioStreamForPlayer(int playerid, const char * url);
  39.             inline bool ApplyAnimation(int playerid, const char * animlib, const char * animname, float fDelta, bool loop, bool lockx, bool locky, bool freeze, int time);
  40.     };
  41.     CPSD Plugin_PSD;
  42.     CPSD::~CPSD() {
  43.         strcpy(* str, "");
  44.         strcpy(Speed3DText, "");
  45.         strcpy(CarFireObject, "");
  46.         strcpy(* Name, "");
  47.         * Health = 0.0;
  48.         strcpy((char *)xyz, "");
  49.     }
  50.  
  51.     int CPSD::BindKey_(char * key) {
  52.         if(!strcmp("action", key)) return KEY_ACTION;
  53.         else if(!strcmp("crouch", key)) return KEY_CROUCH;
  54.         else if(!strcmp("fire", key)) return KEY_FIRE;
  55.         else if(!strcmp("sprint", key)) return KEY_SPRINT;
  56.         else if(!strcmp("attack", key)) return KEY_SECONDARY_ATTACK;
  57.         else if(!strcmp("jump", key)) return KEY_JUMP;
  58.         else if(!strcmp("lookr", key)) return KEY_LOOK_RIGHT;
  59.         else if(!strcmp("lookl", key)) return KEY_LOOK_LEFT;
  60.         else if(!strcmp("lookb", key)) return KEY_LOOK_BEHIND;
  61.         else if(!strcmp("handbrake", key)) return KEY_HANDBRAKE;
  62.         else if(!strcmp("submission", key)) return KEY_SUBMISSION;
  63.         else if(!strcmp("walk", key)) return KEY_WALK;
  64.         else if(!strcmp("aup", key)) return KEY_ANALOG_UP;
  65.         else if(!strcmp("adown", key)) return KEY_ANALOG_DOWN;
  66.         else if(!strcmp("aleft", key)) return KEY_ANALOG_LEFT;
  67.         else if(!strcmp("aright", key)) return KEY_ANALOG_RIGHT;
  68.         else if(!strcmp("yes", key)) return KEY_YES;
  69.         else if(!strcmp("no", key)) return KEY_NO;
  70.         else if(!strcmp("ctrlback", key)) return KEY_NO;
  71.         else if(!strcmp("up", key)) return KEY_UP;
  72.         else if(!strcmp("down", key)) return KEY_DOWN;
  73.         else if(!strcmp("left", key)) return KEY_LEFT;
  74.         else if(!strcmp("right", key)) return KEY_RIGHT;
  75.         else return false;
  76.     }
  77.  
  78.     int CPSD::IsVehiclePlaneOrHelicopter(int vehicleid) {
  79.         switch(vehicleid) {
  80.             case 417: case 425: case 447: case 460: case 464: case 465: case 469: case 476: case 487: case 488: case 497: case 501: case 511: case 512: case 513: case 519: case 520: case 539: case 553: case 548: case 563: case 577: case 592: case 593: return true; break;
  81.         }
  82.         return false;
  83.     }
  84.  
  85.     float CPSD::GetSpeed(int playerid) {
  86.         IsPlayerInAnyVehicle(playerid)? GetVehicleVelocity(GetPlayerVehicleID(playerid), &xyz[0][playerid], &xyz[1][playerid], &xyz[2][playerid]): GetPlayerVelocity(playerid, &xyz[0][playerid], &xyz[1][playerid], &xyz[2][playerid]);
  87.         return 160 * sqrtf(powf(xyz[2][playerid], 2) + powf(xyz[1][playerid], 2) + powf(xyz[0][playerid], 2));
  88.     }
  89.  
  90.     inline bool CPSD::PlayAudioStreamForPlayer(int playerid, const char * url) {
  91.         float posX = 0.0;
  92.         float posY = 0.0;
  93.         float posZ = 0.0;
  94.         float distance = 0.0;
  95.         bool usepos = false;
  96.         return ::sampgdk_PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  97.     }
  98.  
  99.     inline bool CPSD::ApplyAnimation(int playerid, const char * animlib, const char * animname, float fDelta, bool loop, bool lockx, bool locky, bool freeze, int time) {
  100.         bool forcesync = false;
  101.         return ::sampgdk_ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync);
  102.     }
  103. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement