SA-MP Forums Archive
[Include] Mil-Functions 0.1 - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Mil-Functions 0.1 (/showthread.php?tid=364706)



Mil-Functions 0.2 [SetVehicleSpeed, GetVehicleSpeed + More] - milanosie - 31.07.2012

Mil-Functions


Version: 0.2
Last update: 08-08-2012
Author: Milanosie
Pastebin: http://pastebin.com/hKDJfKn3



Hello, welcome to Mil-Functions. It's nothing big yet but I'm planning on expanding Mil-Functions on a weekly scale until it contains a good amount of features.
For now, I'm happy with what I got so far.


Functions

All Functions

pawn Код:
public GetVehicleSpeed(vehicleid, unit);
public GetClosestVehicleFromPoint(Float:x, Float:y, Float:z);
public GetClosestVehicleFromPlayer(playerid);
public GetClosestPlayerFromPlayer(playerid);
public GetClosestPlayerFromPoint(Float:x, Float:y, Float:z);
public LocalChat(playerid, Float:range, text[]);
public GetVehicleType(vehicleid);
public ToggleVehicleEngine(vehicleid);
public StopVehicleEngine(vehicleid);
public StartVehicleEngine(vehicleid);
public Freeze(playerid);
public Unfreeze(playerid);
public TogFreeze(playerid);
public SetVehicleSpeed(vehicleid, Float:speed);

Added in 0.2

pawn Код:
public ToggleVehicleEngine(vehicleid);
public StopVehicleEngine(vehicleid);
public StartVehicleEngine(vehicleid);
public Freeze(playerid);
public Unfreeze(playerid);
public TogFreeze(playerid);
public SetVehicleSpeed(vehicleid, Float:speed);

Usage

GetVehicleSpeed


Usage: GetVehicleSpeed(vehicleid, unit)
Parameters: kmh/mph
Example
pawn Код:
new v = GetPlayerVehicleID(playerid);
new string[128];
format(string, sizeof(string), "You are driving %d KM/h", GetVehicleSpeed(v, kmh));
SendClientMessage(playerid, 0xFFFF00, string);
GetClosestVehicleFromPoint


Usage: GetClosestVehicleFromPoint(Float: x, Float:y, Float:z)
Parameters: x coordinate, y coordinate, z coordinate.
Example
pawn Код:
printf("Closest Vehicle near 323, 100, 5 = %d", GetClosestVehicleFromPoint(323, 100, 5));


GetClosestVehicleFromPlayer


Usage: GetClosestVehicleFromPlayer(playerid)
Parameters: playerid
Example
pawn Код:
printf("Closest Vehicle near [%d] = %d", playerid, GetClosestVehicleFromPlayer(playerid));
GetClosestPlayerFromPoint


Usage: GetClosestPlayerFromPoint(Float: x, Float:y, Float:z)
Parameters: x coordinate, y coordinate, z coordinate.
Example
pawn Код:
printf("Closest PlayerID near 323, 100, 5 = %d", GetClosestPlayerFromPoint(323, 100, 5));
GetClosestPlayerFromPlayer


Usage: GetClosestPlayerFromPlayer(playerid)
Parameters: playerid
Example
pawn Код:
printf("Closest PlayerID near [%d] = %d", playerid, GetClosestPlayerFromPlayer(playerid));
LocalChat


Usage: LocalChat(playerid, Float:range, text[])
Parameters: playerid, range, text
Info: The color of the text depands on the distance of the other players around. The chat will only show for the same virtual world and interior.
Example
pawn Код:
public OnPlayerText(playerid, text[])
{
    new name[24];
    GetPlayerName(playerid, name, 24);
    new string[128];
    format(string, sizeof(string), "%s says: %s", name, text);
    LocalChat(playerid, 25, string);
    return 0;
}
GetVehicleType


Usage: GetVehicleType(vehicleid)
Parameters: VehicleID
Info: Returns Model_Car, Model_Bike, Model_Heli, Model_Plane, Model_Unique, Model_Bicycle or Model_Boat
Example
pawn Код:
CMD:seatbelt(playerid, params[])
{
    if(GetVehicleType(vehicleid) != Model_Car) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can only perform this command in a car.");
    //rest of the code
}
SetVehicleSpeed

Usage: SetVehicleSpeed(vehicleid, km/h)
Parameters: vehicleid, km/h speed
Info: Set the vehicle speed [ONLY sets the speed, not maintains it.]
Example:

This is a very simple example of a cruise control system, just showing an example of the usage of SetVehicleSpeed

pawn Код:
new p_speed[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    new v = GetPlayerVehicleID(playerid);
    if(v != 0)
    {
        if(cruisecontrol[playerid] == 1)
        {
            if(p_speed[playerid] == 0)
            {
                SetVehicleSpeed(vehicleid, 50.0);
                p_speed[playerid] = 1;
            }
            else if(p_speed[playerid] == 1)
            {
                p_speed[playerid] = 2;
            }
            else
            {
                p_speed[playerid] = 0;
            }
        }
    }
    return 1;
}

ToggleVehicleEngine


Usage: ToggleVehicleEngine(vehicleid)
Parameters: vehicleid
Info: Changes the state of the engine of a vehicle
Example
pawn Код:
ToggleVehicleEngine(GetPlayerVehicleID(playerid));
StopVehicleEngine

Usage: StopVehicleEngine(vehicleid)
Parameters: vehicleid
Info: Stops the vehicle engine


StartVehicleEngine

Usage: StartVehicleEngine(vehicleid)
Parameters: vehicleid
Info: Starts the vehicle engine

Freeze

Usage: Freeze(playerid)
Parameters: playerid
Info: Freezes the player

Unfreeze

Usage: Unfreeze(playerid)
Parameters: playerid
Info: Un Freezes the player

TogFreeze

Usage: TogFreeze(playerid)
Parameters: playerid
Info: Changes the frozen state of the player






Re: Mil-Functions 0.1 - Kaperstone - 31.07.2012

Intersting...
anyway,nice include.

EDIT: What the 'GetClostestPlayerToPoint' callbacks are used for ?


Re: Mil-Functions 0.1 - Glint - 31.07.2012

Nice job, it will be terrific if you really do keep updating it on weekly basis.


Re: Mil-Functions 0.1 - milanosie - 31.07.2012

Quote:
Originally Posted by xkirill
Посмотреть сообщение
Intersting...
anyway,nice include.

EDIT: What the 'GetClostestPlayerToPoint' callbacks are used for ?
Let me give you an example:

For example a race system for if nobody finished within the time limit.
Check who is the closest to the finish or w/e.

Something like that

Im using it for an event where the player closest to a checkpoint at a random location gets 5k when the timer ends,


Re: Mil-Functions 0.1 - MP2 - 31.07.2012

They're functions, NOT callbacks. Also, why are they public..?


Re: Mil-Functions 0.1 - milanosie - 01.08.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
They're functions, NOT callbacks. Also, why are they public..?
They're functions indeed, and why shouldn't they be public?


Re : Mil-Functions 0.1 - ricardo178 - 01.08.2012

Wow, that's useful. Keep updating and maybe made an include with them. This will be useful for me.


Re: Re : Mil-Functions 0.1 - milanosie - 01.08.2012

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
Wow, that's useful. Keep updating and maybe made an include with them. This will be useful for me.
Will do, thanks


Re: Mil-Functions 0.1 - TheArcher - 01.08.2012

CMDeatbelt(playerid, params[])
{
if(GetVehicleType(vehicleid) != Model_Car) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can only perform this command in a car.");
//rest of the code
}

can be easly

if(IsPlayerInAnyVehicle(playerid) ) return .....


Re: Mil-Functions 0.1 - milanosie - 01.08.2012

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
CMDeatbelt(playerid, params[])
{
if(GetVehicleType(vehicleid) != Model_Car) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can only perform this command in a car.");
//rest of the code
}

can be easly

if(IsPlayerInAnyVehicle(playerid) ) return .....
No,its not the same.
IsPlayerInAnyVehicle checks if ANY vehicle.

GetVehicleType returns if it is a car, plane, helicopter, bike, bycicle, etc....

Only cars have seatbelt though, a Car isn't the same as a Vehicle


Re: Mil-Functions 0.1 - TheArcher - 01.08.2012

True, also just check if the model is different from the plane, bike one.


Re: Mil-Functions 0.1 - milanosie - 01.08.2012

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
True, also just check if the model is different from the plane, bike one.
What do you mean?


Re: Mil-Functions 0.1 - milanosie - 02.08.2012

Just finished SetVehicleSpeed(vehicleid, speed)

EDIT: sorry double post


Re: Mil-Functions 0.1 - Jewelz - 04.08.2012

Nice functions - Keep them updated.


Re: Mil-Functions 0.1 - milanosie - 08.08.2012

Updated to 0.2, new functions added


Re: Mil-Functions 0.1 - Sanady - 08.08.2012

FINILY!!Great Job.Now I can easy make Speedometer


Re: Mil-Functions 0.1 - milanosie - 08.08.2012

Quote:
Originally Posted by Sanady
Посмотреть сообщение
FINILY!!Great Job.Now I can easy make Speedometer
Glad you find it useful


Re: Mil-Functions 0.1 - Jewelz - 15.08.2012

Thanks Milanoise! Still going great!!


Re: Mil-Functions 0.1 - RedWingz - 15.08.2012

Awesome job!
+Rep