[Include] Mil-Functions 0.1
#1

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



Reply
#2

Intersting...
anyway,nice include.

EDIT: What the 'GetClostestPlayerToPoint' callbacks are used for ?
Reply
#3

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

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,
Reply
#5

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

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?
Reply
#7

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

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
Reply
#9

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 .....
Reply
#10

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
Reply
#11

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

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

Just finished SetVehicleSpeed(vehicleid, speed)

EDIT: sorry double post
Reply
#14

Nice functions - Keep them updated.
Reply
#15

Updated to 0.2, new functions added
Reply
#16

FINILY!!Great Job.Now I can easy make Speedometer
Reply
#17

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

Thanks Milanoise! Still going great!!
Reply
#19

Awesome job!
+Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)