Object Models
#1

While I was playing on my server, I found that there was an object that I didn't expect to find it in that place. So I've tried to edit my GM, but didn't find the code that generates that object. So can someone tell me how to get an object's model ID while in game? here's a screen shot for that object:

Reply
#2

bump. you can meet me IG to help me.
Reply
#3

You can use TextDraw and use GetClosestObject stock to update the text of the closest object id. If anyone really needs it, I can create a filterscript.
Reply
#4

uh, I think you should. Thanks by the way.
Reply
#5

Here you go. Try this.

pawn Код:
#include <a_samp>

#define FILTERSCRIPT

#define COLOR_DARKGREEN 0x006400FF
#define COLOR_DARKORANGE 0xFF8C00FF

new Text:Title[MAX_PLAYERS];
new Text:Object[MAX_PLAYERS];
new str[64];

public OnFilterScriptInit()
{
    print("=====================================");
    print(" Nearest Object Initialized! ");
    print("      By: TopAz(FeaR) ");
    print("=====================================");
    return 1;
}

public OnFilterScriptExit()
{
    print("=====================================");
    print(" Nearest Object Unloaded! ");
    print("      By: TopAz(FeaR) ");
    print("=====================================");
    return 1;
}

public OnPlayerConnect(playerid)
{
    //Title
    Title[playerid] = TextDrawCreate(511 ,107 , "~g~~h~~h~Nearest Object:");
    TextDrawColor(Title[playerid], COLOR_DARKGREEN);
    TextDrawLetterSize(Title[playerid], 0.4, 2.8000000000000003);
    TextDrawFont(Title[playerid], 1);
    TextDrawSetProportional(Title[playerid], true);
    TextDrawHideForPlayer(playerid, Title[playerid]);
    //Nearest Object
    Object[playerid] = TextDrawCreate(510 ,127 , "~r~N/A");
    TextDrawColor(Object[playerid], COLOR_DARKORANGE);
    TextDrawLetterSize(Object[playerid], 0.4, 2.8000000000000003);
    TextDrawFont(Object[playerid], 1);
    TextDrawSetProportional(Object[playerid] , true);
    TextDrawHideForPlayer(playerid, Object[playerid]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawDestroy(Title[playerid]);
    TextDrawDestroy(Object[playerid]);
}

public OnPlayerUpdate(playerid)
{
    format(str, sizeof(str), "~y~%f", GetNearestObject(playerid));
    TextDrawSetString(Object[playerid], str);
    return 1;
}

stock GetNearestObject(playerid)
{
    new Float:px, Float:py, Float:pz;
    new currentobject = -1, Float:distance = -1;
    GetPlayerPos(playerid, px, py, pz);
    for(new index = 0; index < MAX_OBJECTS; index++)
    {
        if(!IsValidObject(index))
            continue;
        new Float:ox, Float:oy, Float:oz;
        GetObjectPos(index, ox, oy, oz);
        new Float:odist = floatsqroot
        (
            floatpower(floatabs(floatsub(ox, px )), 2.0) +
            floatpower(floatabs(floatsub(oy, py )), 2.0) +
            floatpower(floatabs(floatsub(oz, pz )), 2.0)
        );
        if(currentobject == -1)
        {
            currentobject = index;
            distance = odist;
        }
        else if(odist < distance)
        {
            currentobject = index;
            distance = odist;
        }
    }
    return currentobject;
}
If you want dynamic, let me know.
Reply
#6

lol man. very nice. +rep for you for that work.
Reply
#7

Here is the dynamic object version. Please don't pm me. Ask in the thread.

pawn Код:
#include <a_samp>
#include <streamer>

#define FILTERSCRIPT

#define COLOR_DARKGREEN 0x006400FF
#define COLOR_DARKORANGE 0xFF8C00FF

new Text:Title[MAX_PLAYERS];
new Text:Object[MAX_PLAYERS];
new str[64];

public OnFilterScriptInit()
{
    print("=====================================");
    print(" Nearest Object Initialized! ");
    print("      By: TopAz(FeaR) ");
    print("=====================================");
    return 1;
}

public OnFilterScriptExit()
{
    print("=====================================");
    print(" Nearest Object Unloaded! ");
    print("      By: TopAz(FeaR) ");
    print("=====================================");
    return 1;
}

public OnPlayerConnect(playerid)
{
    //Title
    Title[playerid] = TextDrawCreate(511 ,107 , "~g~~h~~h~Nearest Object:");
    TextDrawColor(Title[playerid], COLOR_DARKGREEN);
    TextDrawLetterSize(Title[playerid], 0.4, 2.8000000000000003);
    TextDrawFont(Title[playerid], 1);
    TextDrawSetProportional(Title[playerid], true);
    TextDrawShowForPlayer(playerid, Title[playerid]);
    //Nearest Object
    Object[playerid] = TextDrawCreate(510 ,127 , "~r~N/A");
    TextDrawColor(Object[playerid], COLOR_DARKORANGE);
    TextDrawLetterSize(Object[playerid], 0.4, 2.8000000000000003);
    TextDrawFont(Object[playerid], 1);
    TextDrawSetProportional(Object[playerid] , true);
    TextDrawShowForPlayer(playerid, Object[playerid]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawDestroy(Title[playerid]);
    TextDrawDestroy(Object[playerid]);
}

public OnPlayerUpdate(playerid)
{
    format(str, sizeof(str), "~y~%f", GetNearestDynamicObject(playerid));
    TextDrawSetString(Object[playerid], str);
    return 1;
}

stock GetNearestDynamicObject(playerid)
{
    new Float:px, Float:py, Float:pz;
    new currentobject = -1, Float:distance = -1;
    GetPlayerPos(playerid, px, py, pz);
    for(new index = 0; index < CountDynamicObjects(); index++)
    {
        if(!IsValidDynamicObject(index))
            continue;
        new Float:ox, Float:oy, Float:oz;
        GetDynamicObjectPos(index, ox, oy, oz);
        new Float:odist = floatsqroot
        (
            floatpower(floatabs(floatsub(ox, px )), 2.0) +
            floatpower(floatabs(floatsub(oy, py )), 2.0) +
            floatpower(floatabs(floatsub(oz, pz )), 2.0)
        );
        if(currentobject == -1)
        {
            currentobject = index;
            distance = odist;
        }
        else if(odist < distance)
        {
            currentobject = index;
            distance = odist;
        }
    }
    return currentobject;
}
Reply
#8

still, it doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)