Can you help me with /speed command (+REP) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Can you help me with /speed command (+REP) (
/showthread.php?tid=648222)
Can you help me with /speed command (+REP) -
BluePlayBG - 17.01.2018
The command would tell a vehicle's speed when is executed, for example if I am staying in a vehicle and someone passes, and I type /speed it should tell me the vehicle's speed.
Thanks in advance. +rep
Re: Can you help me with /speed command (+REP) -
Dayrion - 17.01.2018
"Scripting Help"
It's not "Request command section"
Re: Can you help me with /speed command (+REP) -
Daveosss - 17.01.2018
This will show all the nearby players who are driving a vehicle and their speed:
PHP код:
stock GetPlayerSpeed(playerid)
{
new Float:xx,Float:yy,Float:zz,Float:speed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
speed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return floatround((speed * 165.12));
}
CMD:speed(playerid, params[]) // I'm using zcmd include here
{
new found = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(i, 50.0, X, Y, Z) && i != playerid)
{
found = 1;
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player: %s(%d), Speed: %d", name, i, GetPlayerSpeed(i));
SendClientMessage(playerid, -1, string);
}
}
if(found == 0)
{
SendClientMessage(playerid, -1, "No players found.");
}
return 1;
}
Re: Can you help me with /speed command (+REP) -
Abagail - 17.01.2018
Quote:
Originally Posted by Daveosss
This will show all the nearby players who are driving a vehicle and their speed:
PHP код:
stock GetPlayerSpeed(playerid)
{
new Float:xx,Float:yy,Float:zz,Float:speed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
speed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return floatround((speed * 165.12));
}
CMD:speed(playerid, params[]) // I'm using zcmd include here
{
new found = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(i, 50.0, X, Y, Z) && i != playerid)
{
found = 1;
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player: %s(%d), Speed: %d", name, i, GetPlayerSpeed(i));
SendClientMessage(playerid, -1, string);
}
}
if(found == 0)
{
SendClientMessage(playerid, -1, "No players found.");
}
return 1;
}
|
You should've read the above post. This isn't helping him
at all, it's simply giving him code. It doesn't even have comments in the code. How does this help him learn anything?