SA-MP Forums Archive
Speed Player/Veh And HP - 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: Speed Player/Veh And HP (/showthread.php?tid=362082)



Speed Player/Veh And HP - Hervest1998 - 23.07.2012

Код:
#include <a_samp>

public OnPlayerConnect(playerid)
{
	GetPlayerSpeed(playerid);
	GetVehicleSpeed(GetPlayerVehicleID(playerid));
	GetVehicleHP(GetPlayerVehicleID(playerid));
	return 1;
}

stock GetPlayerSpeed(playerid)
{
	new Float:X,Float:Y,Float:Z;
	GetPlayerVelocity(playerid,X,Y,Z);
	return floatsqroot(floatround((X * X + Y * Y + Z * Z) * 200));
}

stock GetVehicleSpeed(vehicleid)
{
	new Float:X,Float:Y,Float:Z;
	GetVehicleVelocity(vehicleid,X,Y,Z);
	return floatsqroot(floatround((X * X + Y * Y + Z * Z) * 200));
}

stock GetVehicleHP(vehicleid)
{
	new Float:Health;
	GetVehicleHealth(vehicleid,Health);
	return floatsqroot(floatround(Health / 10));
}
Код:
C:\Documents and Settings\user\Pulpit\Server\gamemodes\GM.pwn(15) : warning 213: tag mismatch
C:\Documents and Settings\user\Pulpit\Server\gamemodes\GM.pwn(22) : warning 213: tag mismatch
C:\Documents and Settings\user\Pulpit\Server\gamemodes\GM.pwn(29) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Why?


Re: Speed Player/Veh And HP - RedJohn - 23.07.2012

pawn Код:
stock GetPlayerSpeed(playerid)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerVelocity(playerid,X,Y,Z);
    return floatround(floatsqroot(X * X + Y * Y + Z * Z) * 200.00);
}

stock GetVehicleSpeed(vehicleid)
{
    new Float:X,Float:Y,Float:Z;
    GetVehicleVelocity(vehicleid,X,Y,Z);
    return floatround(floatsqroot(X * X + Y * Y + Z * Z) * 200.00);
}

stock GetVehicleHP(vehicleid)
{
    new Float:Health;
    GetVehicleHealth(vehicleid,Health);
    return floatround(floatsqroot(Health / 10.00));
}
Here.


Re: Speed Player/Veh And HP - [IKS]Niko_Hs™ - 23.07.2012

Replace your code with :

Код:
#include <a_samp>

public OnPlayerConnect(playerid)
{
	GetPlayerSpeed(playerid);
	GetVehicleSpeed(GetPlayerVehicleID(playerid));
	GetVehicleHP(GetPlayerVehicleID(playerid));
	return 1;
}

stock GetPlayerSpeed(playerid)
{
        if(playerid != INVALID_PLAYER_ID)
        {
                new Float:Pos[3],Float:PS;
                GetPlayerVelocity(playerid, Pos[0], Pos[1], Pos[2]);
                PS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
                return floatround(PS,floatround_round);
        }
        return INVALID_PLAYER_ID;
}

stock GetVehicleSpeed(vehicleid)
{
        if(vehicleid != INVALID_VEHICLE_ID)
        {
                new Float:Pos[3],Float:VS ;
                GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
                VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
                return floatround(VS,floatround_round);
        }
        return INVALID_VEHICLE_ID;
}



Re: Speed Player/Veh And HP - RedJohn - 23.07.2012

Quote:
Originally Posted by [IKS]Niko_Hs™
Посмотреть сообщение
Replace your code with :

Код:
#include <a_samp>

public OnPlayerConnect(playerid)
{
	GetPlayerSpeed(playerid);
	GetVehicleSpeed(GetPlayerVehicleID(playerid));
	GetVehicleHP(GetPlayerVehicleID(playerid));
	return 1;
}

stock GetPlayerSpeed(playerid)
{
        if(playerid != INVALID_PLAYER_ID)
        {
                new Float:Pos[3],Float:PS;
                GetPlayerVelocity(playerid, Pos[0], Pos[1], Pos[2]);
                PS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
                return floatround(PS,floatround_round);
        }
        return INVALID_PLAYER_ID;
}

stock GetVehicleSpeed(vehicleid)
{
        if(vehicleid != INVALID_VEHICLE_ID)
        {
                new Float:Pos[3],Float:VS ;
                GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
                VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
                return floatround(VS,floatround_round);
        }
        return INVALID_VEHICLE_ID;
}
You missed third. GetVehicleHP.


Re: Speed Player/Veh And HP - Hervest1998 - 23.07.2012

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
pawn Код:
stock GetPlayerSpeed(playerid)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerVelocity(playerid,X,Y,Z);
    return floatround(floatsqroot(X * X + Y * Y + Z * Z) * 200.00);
}

stock GetVehicleSpeed(vehicleid)
{
    new Float:X,Float:Y,Float:Z;
    GetVehicleVelocity(vehicleid,X,Y,Z);
    return floatround(floatsqroot(X * X + Y * Y + Z * Z) * 200.00);
}

stock GetVehicleHP(vehicleid)
{
    new Float:Health;
    GetVehicleHealth(vehicleid,Health);
    return floatround(floatsqroot(Health / 10.00));
}
Here.
Thanks.