[Include] TSSA Objects
#1

TSSA Objects


Hi, I developed this script today. It's simple, but useful.

Thue funcions are:

Code:
native GetObjectModel(objectid);
native IsPlayerInRangeOfObject(playerid, Float:range, objectid);
native GetRangePlayerObjectID(playerid, Float:range);
native IsPlayerInRangeOfAnyObject(playerid, Float:range);
native GetPlayerDistanceToObject(playerid, objectid);
native CreateExplosionOnObject(objectid, type, Float:radius);
native IsPlayerInRangeOfModelID(playerid, Float:range, modelid);
GetObjectModel
Get the model id of the object after being created.
return modelid; -> The model of the object.

IsPlayerInRangeOfObject
Checks if the player is in range of a specified object.
return 1 -> if its is true
return 0 -> if its false

GetRangePlayerObjectID
Get the ID of the object which the player is close.
return objectid -> The ID of the object

IsPlayerInRangeOfAnyObject
Check if the player is in range of any object.
return 1 -> if its is true
return 0 -> if its false

GetPlayerDistanceToObject
Get the distance of player to object.
return distance -> The integer value of the distance

CreateExplosionOnObject
Create a explosion on the position of the object. (Good for bombs, etc.)

IsPlayerInRangeOfModelID
Check if the player is in the range of a object with modelid == modelid
return objectid -> The ID of object

Exemple:
pawn Code:
#include <a_samp>
#include <tssa_objects>

new TestObject;

public OnFilterScriptInit()
{
    TestObject = CreateObject(672, 95.26448, -67.43716, 0.85775,   0.00000, 0.00000, 0.00000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/explode", cmdtext, true) == 0)
    {
        ExplodeObject(TestObject, 10, 1);
        SendClientMessage(playerid, -1, "| INFO | Object exploded");
        return 1;
    }
    if (strcmp("/range", cmdtext, true) == 0)
    {
        new S[128];
        if(IsPlayerInRangeOfAnyObject(playerid, 10.0))
        {
            new ObjectID = GetRangePlayerObjectID(playerid, 10.0);
            new Float:X, Float:Y, Float:Z;
            GetObjectPos(ObjectID, X, Y, Z);
            format(S, sizeof(S), "| INFO | You are within range of the object (ID: %d | Model: %d | Distance: %d | Pos: %f,%f,%f)", ObjectID, GetObjectModel(ObjectID), GetPlayerDistanceToObject(playerid, ObjectID), X, Y, Z);
        }
        else format(S, sizeof(S), "| INFO | You're not in range of the object");
        SendClientMessage(playerid, -1, S);
        return 1;
    }
    return 0;
}
Code:
| INFO | You are within range of the object (ID: 2 | Model: 672 | Distance: 1 | Pos: 95.264480,-67.437156,0.857749)

Reply
#2

Wow this is nice.
Might use it.
Reply
#3

pawn Code:
IsPlayerInRangeOfObject
Can you use the modelid for this (IsPlayerInRangeOfObject(playerid, 715)) instead of new object = CreateObject(...) and then IsPlayerInRangeOfObject(playerid, object)?
Reply
#4

Wow .
Reply
#5

Quote:
Originally Posted by connork
View Post
native IsPlayerInRangeOfAnyObject(playerid, Float:range);
It will always return true, unless the player is in the sky.
Reply
#6

Why you've posted this at plugin section? It must be posted at Includes board.
Reply
#7

Quote:
Originally Posted by codectile
View Post
It will always return true, unless the player is in the sky.
Well, I've looked at the source code and it only detects objects created with CreateTSSAObject.
Reply
#8

@Twizted: Well, that's fine then.
Reply
#9

I added the function: native IsPlayerInRangeOfModelID(playerid, Float:range, modelid);

It's will return the ID of object with modelid in range of player.

It's all right with IsPlayerInRangeOfAnyObject, just create a new object with CreateObject and work,

thanks for the comments.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)