Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ___________________________________________________________________
- / | |
- / |
- / THIS include has been created by [D]ry[D]esert |
- / copyright(c) to [D]ry[D]esert. |
- / v0.1 beta |
- /___________________________________________________________________|
- */
- /*
- #define MAX_RADARS (30) //Maxium ammount of radars can be created.
- #define ALLOWED_SPEED (120) //The allowed of vehicle's speed(KM).
- #define CREATE_3DTEXT_LABEL (true) //Create the Text 'Radar' on the rader. true for yes, false for no
- #define LABEL_DRAW_DISTANCE (20) //Draw distance for the label.(Wont work if CREATE_3DTEXT_LABEL == false.
- #define CAMERA_RANGE (12) //The range which camera can reach to detect if player has passed the limited speed
- #define PLAY_CAMERA_SOUND (true) //when player pass the limite speed, it will play camera sound. true for enable and false for disable.
- #define LABEL_COLOR_TEXT (0x0000BBAA) //Set label color.(wont work if CREATE_3DTEXT_LABEL == false.)
- #define LABEL_TEXT "Radar" //Set label Text.(wont work if CREATE_3DTEXT_LABEL == false.)
- */
- #include <a_samp>
- #if defined _dRadar_included
- #endinput
- #endif
- #define _dRadar_included
- #if !defined _samp_included
- #error "You need to include the a_samp.inc include file before the dRadar.inc file!!"
- #endif
- #if !defined MAX_RADARS
- #define MAX_RADARS (30)
- #endif
- #if !defined ALLOWED_SPEED
- #define ALLOWED_SPEED (120) //KM
- #endif
- #if !defined CAMERA_RANGE
- #define CAMERA_RANGE (12) //The range which camera can reach to detect if player has passed the limited speed
- #endif
- #if !defined PLAY_CAMERA_SOUND
- #define PLAY_CAMERA_SOUND (true) //when player pass the limite speed, it will play camera sound. true for enable and false for disable.
- #endif
- #if !defined CREATE_3DTEXT_LABEL
- #define CREATE_3DTEXT_LABEL (true) //Create the Text 'Radar' on the rader. true for yes, false for no
- #endif
- #if !defined LABEL_DRAW_DISTANCE
- #define LABEL_DRAW_DISTANCE (20)
- #endif
- #if !defined LABEL_COLOR_TEXT
- #define LABEL_COLOR_TEXT (0x0000BBAA) //blue color.
- #endif
- #if !defined LABEL_TEXT
- #define LABEL_TEXT "Radar"
- #endif
- enum d_Radar
- {
- RadarObject,
- Text3D:RaderLable,
- Float:R_X,
- Float:R_Y,
- Float:R_Z,
- bool:Exist
- };
- new dRadar[MAX_RADARS][d_Radar];
- new RadarCounter;
- new lastcheck[MAX_PLAYERS];
- forward pCheck();
- forward dRadar_OnGameModeInit();
- forward OnVehiclePassTheLimitedSpeed(playerid, vehicleid);
- public OnGameModeInit()
- {
- print("====================================");
- print("| dRadar v0.1 beta |");
- print("| ©[D]ry[D]esert |");
- print("====================================");
- SetTimer("pCheck",10,true);
- CallLocalFunction("dRadar_OnGameModeInit","");
- return 1;
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit dRadar_OnGameModeInit
- forward dRadar_OnGameModeInit();
- stock Float:Radar_GetPlayerSpeed(playerid)
- {
- new Float:SpeedX, Float:SpeedY, Float:SpeedZ;
- new Float:Speed;
- GetVehicleVelocity(GetPlayerVehicleID(playerid), SpeedX, SpeedY, SpeedZ);
- Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatpower(SpeedY, 2.0)));
- Speed = floatround(Speed * 100 * 1.60);
- return Speed;
- }
- public pCheck()
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- new newmessage = gettime();
- for(new r=0;r<MAX_RADARS;r++)
- {
- if(dRadar[r][Exist] == true)
- {
- if(IsPlayerInRangeOfPoint(i,CAMERA_RANGE,dRadar[r][R_X],dRadar[r][R_Y],dRadar[r][R_Z]))
- {
- if(IsPlayerInAnyVehicle(i))
- {
- if(Radar_GetPlayerSpeed(i) >= ALLOWED_SPEED)
- {
- switch(newmessage - lastcheck[i])
- {
- case 0..2:
- {
- return 0;
- }
- default:
- {
- new vehicleid = GetPlayerVehicleID(i);
- #if PLAY_CAMERA_SOUND == true
- PlayerPlaySound(i,1132,0,0,0);
- #endif
- CallLocalFunction("OnVehiclePassTheLimitedSpeed","ii",i,vehicleid);
- lastcheck[i] = gettime();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return 1;
- }
- stock CreateRadar(type,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:DrawDistance)
- {
- if(RadarCounter == MAX_RADARS)
- {
- print("dRADAR ERROR: cant create radar, radars has reached the maximum ammount");
- }
- else
- {
- if(type == 0)
- {
- dRadar[RadarCounter][RadarObject] = CreateObject(18653,x,y,z-0.5,rx,ry,rz,DrawDistance);
- }
- else if(type == 1)
- {
- dRadar[RadarCounter][RadarObject] = CreateObject(18880,x,y,z-0.5,rx,ry,rz,DrawDistance);
- }
- else
- {
- print("dRADAR ERROR: Unknow type.");
- }
- dRadar[RadarCounter][R_X] = x;
- dRadar[RadarCounter][R_Y] = y;
- dRadar[RadarCounter][R_Z] = z;
- dRadar[RadarCounter][Exist] = true;
- #if CREATE_3DTEXT_LABEL == true
- dRadar[RadarCounter][RaderLable] = Create3DTextLabel(LABEL_TEXT,LABEL_COLOR_TEXT,x,y,z,LABEL_DRAW_DISTANCE,0);
- #endif
- RadarCounter++;
- }
- }
- // © All rights Reserve to [D]ry[D]esert. 2013.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement