Creation of transport radars in SAMP
- mdialog
Only for#define VEHICLE_RADAR_USE_EDITING_TOOLS true
Include in your code and begin using the library:
#include <vehicle-radar>
new radarid = VehicleRadarLoad(130, 50.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // create a radar
SetVehicleRadarExtraValue(radarid, 1005); // add the value
public OnPlayerEnterVehicleRadar(playerid, radarid, vehicleid, activation_count)
{
printf("Enter Vehicle Radar | radarid: %d | vehicleid: %d | activation_count: %d", radarid, vehicleid, activation_count)
return 1;
}
public OnPlayerVehicleRadarCreate(playerid, radarid, speed_limit, Float:zone_size, bool:disabled, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid, interiorid)
{
printf("Create | radarid %d | speed_limit %d | zone_size %f | x %.2f | y %.2f | z %.2f | rx %.2f | ry %.2f | rz %.2f | worldid %d | int %d",
radarid, speed_limit, zone_size, x, y, z, rx, ry, rz, worldid, interiorid
);
//Mysql R39-6 save example
static const mysql_str[] =
"INSERT INTO vehicle_radar (`speed_limit`,`zone_size`,`x`,`y`,`z`,`rx`,`ry`,`rz`,`worldid`,`interiorid`) VALUE ('%d','%f','%f','%f','%f','%f','%f','%f','%d','%d')";
new string[sizeof(mysql_str)];
mysql_format(mysql, string, sizeof(string), mysql_str, speed_limit, zone_size, x, y, z, rx, ry, rz, worldid, interiorid);
new Cache:result = mysql_query(mysql, string);
if(!cache_is_valid(result))
{
SendClientMessage(playerid, -1, "mysql error creating a vehicle radar");
cache_delete(result);
return 1;
}
SetVehicleRadarExtraValue(radarid, cache_insert_id()); // writes the id of the new row
cache_delete(result);
return 1;
}
public OnPlayerVehicleRadarEdit(playerid, radarid, speed_limit, Float:zone_size, bool:disabled, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid, interiorid)
{
printf("Edit | radarid %d | speed_limit %d | zone_size %f | x %.2f | y %.2f | z %.2f | rx %.2f | ry %.2f | rz %.2f | worldid %d | int %d",
radarid, speed_limit, zone_size, x, y, z, rx, ry, rz, worldid, interiorid
);
//Mysql R39-6 save example
static const mysql_str[] =
"UPDATE vehicle_radar SET speed_limit=%d,zone_size='%f',x='%f',y='%f',z='%f',rx='%f',ry='%f',rz='%f',worldid=%d,interiorid=%d WHERE id=%d LIMIT 1";
new string[sizeof(mysql_str)];
mysql_format(mysql, string, sizeof(string), mysql_str, speed_limit, zone_size, x, y, z, rx, ry, rz, worldid, interiorid, GetVehicleRadarExtraValue(radarid));
mysql_tquery(mysql, string);
return 1;
}
public OnPlayerVehicleRadarDelete(playerid, radarid, extra_value)
{
printf("Delete | radarid %d | extra_value %d", radarid, extra_value);
//Mysql R39-6 save example
static const mysql_str[] = "DELETE FROM vehicle_radar WHERE id=%d LIMIT 1";
new string[sizeof(mysql_str) + 11];
mysql_format(mysql, string, sizeof(string), mysql_str, extra_value);
mysql_tquery(mysql, string);
return 1;
}
- Called when the radar is triggered
playerid
- The ID of the playerradarid
- The ID of the radarvehicleid
- The ID of vehicleactivation_count
- Triggering
public OnPlayerVehicleRadarCreate(playerid, radarid, speed_limit, Float:zone_size, bool:disabled, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid, interiorid)
Called when creating a radar
radarid
- The ID of the radarspeed_limit
- Speed limit in km/hFloat:zone_size
- Trigger distancebool:disabled
- Disabled radar (false | true)Float:x
- The x coordinate to create the objectFloat:y
- The y coordinate to create the objectFloat:z
- The z coordinate to create the objectFloat:rx
- The x rotation of the objectFloat:ry
- The y rotation of the objectFloat:rz
- The z rotation of the objectworldid
- The virtual world IDinteriorid
- The interior ID
public OnPlayerVehicleRadarEdit(playerid, radarid, speed_limit, Float:zone_size, bool:disabled, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid, interiorid)
Called when editing
radarid
- The ID of the radarspeed_limit
- Speed limit in km/hFloat:zone_size
- Trigger distancebool:disabled
- Disabled radar (false | true)Float:x
- The x coordinate the objectFloat:y
- The y coordinate the objectFloat:z
- The z coordinate the objectFloat:rx
- The x rotation of the objectFloat:ry
- The y rotation of the objectFloat:rz
- The z rotation of the objectworldid
- The virtual world IDinteriorid
- The interior ID
Called when the radar is removed
radarid
- The ID of the radarextra_value
- Value- Note:
extra_value
set viaSetVehicleRadarExtraValue
Create a radar
playerid
- The ID of the player
List of created radars
playerid
- The ID of the player
VehicleRadarLoad(speed_limit, Float:zone_size, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, bool:disabled = false, const text3D[] = "", text3D_color = -1, Float:text3D_distance = VEHICLE_RADAR_3DTEXT_DISTANCE)
Load Radar
speed_limit
- Speed limit in km/hFloat:zone_size
- Trigger distanceFloat:x
- The x coordinate to create the objectFloat:y
- The y coordinate to create the objectFloat:z
- The z coordinate to create the objectFloat:rx
- The x rotation of the objectFloat:ry
- The y rotation of the objectFloat:rz
- The z rotation of the objectworldid
- The virtual world IDinteriorid
- The interior IDbool:disabled
- Disabled radar (false | true)const text3D[]
- 3DTexttext3D_color
- 3DText colorFloat:text3D_distance
- 3DText draw distance- Returns (0) on failure or id radar
Remove radar
radarid
- The ID of the radarcallback
- CallOnPlayerVehicleRadarDelete
on deletion- Return: Returns (0) on failure or (1) on success
Set the number of triggers
radarid
- The ID of the radarcount
- Count- Return: Returns (0) on failure or (1) on success
Get the number of triggers
radarid
- The ID of the radar- Return: Returns (0) on failure or Count
Set a speed limit
radarid
- The ID of the radarspeed
- Speed in km/h- Return: Returns (0) on failure or (1) on success
Get the speed limit
radarid
- The ID of the radar- Return: Returns (0) on failure or speed
Set the trigger distance
radarid
- The ID of the radarFloat:zone_size
- Trigger distance- Return: Returns (0) on failure or (1) on success
Get trigger distance
radarid
- The ID of the radar&Float:zone_size
- Current distance- Return: Returns (0) on failure or (1) on success
SetVehicleRadarText(radarid, const text[], color, Float:drawdistance = VEHICLE_RADAR_3DTEXT_DISTANCE, Float:x = 0.0, Float:y = 0.0, Float:z = 0.0)
Set 3D Text
radarid
- The ID of the radartext[]
- Textcolor
- ColorFloat:drawdistance
- Draw distanceFloat:x
- The X coordinate to create the textFloat:y
- The Y coordinate to create the textFloat:z
- The Z coordinate to create the text- Return: Returns (0) on failure or (1) on success
Set the value
radarid
- The ID of the radarvalue
- value- Return: Returns (0) on failure or (1) on success
Get the value
radarid
- The ID of the radar- Return: Returns (0) on failure or Extra Value
#define MAX_VEHICLE_RADAR 200
#define VEHICLE_RADAR_OBJECT_MODEL 18880 // object model
#define VEHICLE_RADAR_OBJECT_DISTANCE 200.0
#define VEHICLE_RADAR_3DTEXT_LENGTH 144 // 3d text length
static VEHICLE_RADAR_3DTEXT_TEXT[] = "Speed radar №%d\nSpeed Limit: %d (km/h)";
#define VEHICLE_RADAR_3DTEXT_DISTANCE 15.0 // 3d text draw distance
#define VEHICLE_RADAR_MAX_ROWS_LIST 20 // max dialog list lines
#define VEHICLE_RADAR_USE_EDITING_TOOLS true //use editing tools
#define VEHICLE_RADAR_COLOR_1 "{8fce00}" // 0x8fce00
#define VEHICLE_RADAR_COLOR_2 "{f44747}" // 0xf44747
#define VEHICLE_RADAR_COLOR_3 "{F5D742}" // 0xF5D742
const Float:VEHICLE_RADAR_SPEED_MULTIPLIER = 179.28625; // speed multiplier