04.09.2014, 22:28
(
Last edited by connork; 05/09/2014 at 12:29 PM.
Reason: Update, new function
)
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);
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)