PDA

View Full Version : how to make cmd:findcar


langit
19/11/2017, 03:14 PM
hi .. can someone help me, how do i make cmd / findcar with checkpoint

CMD:carpos(playerid, params[])
{
new string[128], CARID;
if(sscanf(params, "i", CARID)) // Check if there's a param
{ // There's no param:
SendClientMessage(playerid, COLOR_RED, "USAGE: /carpos (CARID)");
}
else
{ // There is a param and it's a number (integer):
if (IsValidVehicle(CARID)) // Check if your param is a valid vehicle
{ // There is a vehicle with this ID:
new Float: carx, Float: cary, Float: carz;
GetVehiclePos(CARID, carx, cary, carz);
format(string, sizeof(string), "%d's Position: %.3f, %.3f, %.3f.", CARID, carx, cary, carz); // The floats will be shown with 3 point numbers. (Hence the .3, you can change or remove this if you want)
SendClientMessage(playerid, COLOR_WHITE, string);
new Float: carangle;
GetVehicleZAngle(CARID, carangle);
format(string, sizeof(string), "%d's angle: %.3f.", CARID, carangle);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{ // There is no vehicle with this ID:
SendClientMessage(playerid, COLOR_RED, "This vehicle does not exist!");
}
}
return 1;
}

Baseball
19/11/2017, 03:37 PM
Hi,
you will make a classic checkpoint, but replace the coordinates of the definition carx cary carz.

Lucases
19/11/2017, 07:47 PM
CMD:carpos(playerid, params[])
{
new string[128], CARID;
if(sscanf(params, "i", CARID)) // Check if there's a param
{ // There's no param:
SendClientMessage(playerid, COLOR_RED, "USAGE: /carpos (CARID)");
}
else
{ // There is a param and it's a number (integer):
if (IsValidVehicle(CARID)) // Check if your param is a valid vehicle
{ // There is a vehicle with this ID:
new Float: carx, Float: cary, Float: carz;
GetVehiclePos(CARID, carx, cary, carz);
format(string, sizeof(string), "%d's Position: %.3f, %.3f, %.3f.", CARID, carx, cary, carz); // The floats will be shown with 3 point numbers. (Hence the .3, you can change or remove this if you want)
SetPlayerCheckpoint(playerid, carx, cary, carz);
SendClientMessage(playerid, COLOR_WHITE, string);
new Float: carangle;
GetVehicleZAngle(CARID, carangle);
format(string, sizeof(string), "%d's angle: %.3f.", CARID, carangle);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{ // There is no vehicle with this ID:
SendClientMessage(playerid, COLOR_RED, "This vehicle does not exist!");
}
}
return 1;
}

langit
20/11/2017, 12:03 AM
CMD:carpos(playerid, params[])
{
new string[128], CARID;
if(sscanf(params, "i", CARID)) // Check if there's a param
{ // There's no param:
SendClientMessage(playerid, COLOR_RED, "USAGE: /carpos (CARID)");
}
else
{ // There is a param and it's a number (integer):
if (IsValidVehicle(CARID)) // Check if your param is a valid vehicle
{ // There is a vehicle with this ID:
new Float: carx, Float: cary, Float: carz;
GetVehiclePos(CARID, carx, cary, carz);
format(string, sizeof(string), "%d's Position: %.3f, %.3f, %.3f.", CARID, carx, cary, carz); // The floats will be shown with 3 point numbers. (Hence the .3, you can change or remove this if you want)
SetPlayerCheckpoint(playerid, carx, cary, carz);
SendClientMessage(playerid, COLOR_WHITE, string);
new Float: carangle;
GetVehicleZAngle(CARID, carangle);
format(string, sizeof(string), "%d's angle: %.3f.", CARID, carangle);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{ // There is no vehicle with this ID:
SendClientMessage(playerid, COLOR_RED, "This vehicle does not exist!");
}
}
return 1;
}


i get WARNING (44878) : warning 202: number of arguments does not match definition

Beryllium
20/11/2017, 12:28 AM
I still can't understand what do you want, Do you want the car teleport to someone's position? or Do you want a player to teleport a vehicle using its id?

L97
20/11/2017, 02:56 AM
i get WARNING (44878) : warning 202: number of arguments does not match definition
Here:
CMD:carpos(playerid, params[])
{
new CARID;
if(sscanf(params, "i", CARID)) // Check if there's a param
{ // There's no param:
SendClientMessage(playerid, COLOR_RED, "USAGE: /carpos (CARID)");
}
else
{ // There is a param and it's a number (integer):
if (IsValidVehicle(CARID)) // Check if your param is a valid vehicle
{ // There is a vehicle with this ID:
new Float: carx, Float: cary, Float: carz;
GetVehiclePos(CARID, carx, cary, carz);
SetPlayerCheckpoint(playerid, carx, cary, carz, 3.0);
SendClientMessage(playerid, COLOR_WHITE, "Your vehicle is now marked on the map.");
}
else
{ // There is no vehicle with this ID:
SendClientMessage(playerid, COLOR_RED, "This vehicle does not exist!");
}
}
return 1;
}
I removed these because you probably don't need them anymore now that you're using a checkpoint:
format(string, sizeof(string), "%d's Position: %.3f, %.3f, %.3f.", CARID, carx, cary, carz); // The floats will be shown with 3 point numbers. (Hence the .3, you can change or remove this if you want)
SendClientMessage(playerid, COLOR_WHITE, string);
new Float: carangle;
GetVehicleZAngle(CARID, carangle);
format(string, sizeof(string), "%d's angle: %.3f.", CARID, carangle);
SendClientMessage(playerid, COLOR_WHITE, string);

langit
20/11/2017, 06:02 AM
I still can't understand what do you want, Do you want the car teleport to someone's position? or Do you want a player to teleport a vehicle using its id?

so that players easily find the vehicle,

langit
20/11/2017, 06:04 AM
Here:
CMD:carpos(playerid, params[])
{
new CARID;
if(sscanf(params, "i", CARID)) // Check if there's a param
{ // There's no param:
SendClientMessage(playerid, COLOR_RED, "USAGE: /carpos (CARID)");
}
else
{ // There is a param and it's a number (integer):
if (IsValidVehicle(CARID)) // Check if your param is a valid vehicle
{ // There is a vehicle with this ID:
new Float: carx, Float: cary, Float: carz;
GetVehiclePos(CARID, carx, cary, carz);
SetPlayerCheckpoint(playerid, carx, cary, carz, 3.0);
SendClientMessage(playerid, COLOR_WHITE, "Your vehicle is now marked on the map.");
}
else
{ // There is no vehicle with this ID:
SendClientMessage(playerid, COLOR_RED, "This vehicle does not exist!");
}
}
return 1;
}
I removed these because you probably don't need them anymore now that you're using a checkpoint:
format(string, sizeof(string), "%d's Position: %.3f, %.3f, %.3f.", CARID, carx, cary, carz); // The floats will be shown with 3 point numbers. (Hence the .3, you can change or remove this if you want)
SendClientMessage(playerid, COLOR_WHITE, string);
new Float: carangle;
GetVehicleZAngle(CARID, carangle);
format(string, sizeof(string), "%d's angle: %.3f.", CARID, carangle);
SendClientMessage(playerid, COLOR_WHITE, string);

this works, thanks L97