Skip to content

Commit

Permalink
Update rml nametags resource (#35)
Browse files Browse the repository at this point in the history
* Update rml nametags resource

* Use BaseObject type+id instead of old entity id

* Use getByRemoteID
  • Loading branch information
xxshady authored Dec 23, 2023
1 parent 2e9d42f commit aadf09a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rml-nametags/Client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,24 @@ let tickHandle = undefined;

alt.on("gameEntityCreate", (entity) => {
const rmlElement = document.createElement("button");
rmlElement.id = entity.id.toString();
rmlElement.entityType = entity.type;
rmlElement.entityID = entity.remoteID;
rmlElement.addClass("nametag");
rmlElement.addClass("hide");

if (entity instanceof alt.Player) {
if (showPlayerIds && !showPlayerNames)
rmlElement.innerRML = `ID: ${entity.id}`;
rmlElement.innerRML = `ID: ${entity.remoteID}`;
else if (showPlayerIds && showPlayerNames)
rmlElement.innerRML = `ID: ${entity.id} | Name: ${entity.name}`;
rmlElement.innerRML = `ID: ${entity.remoteID} | Name: ${entity.name}`;
else if (!showPlayerIds && showPlayerNames)
rmlElement.innerRML = `Name: ${entity.name}`;
else {
rmlElement.destroy();
return;
}
} else if (entity instanceof alt.Vehicle && showVehicleIds)
rmlElement.innerRML = `ID: ${entity.id}`;
rmlElement.innerRML = `ID: ${entity.remoteID}`;
else {
rmlElement.destroy();
return;
Expand Down Expand Up @@ -82,7 +83,7 @@ alt.on("keyup", (key) => {
});

function printCoordinates(rmlElement, eventArgs) {
const entity = alt.Entity.getByID(parseInt(rmlElement.id));
const entity = alt.BaseObject.getByRemoteID(rmlElement.entityType, rmlElement.entityID);
alt.log("Entity Position", "X", entity.pos.x, "Y", entity.pos.y, "Z", entity.pos.z);
}

Expand Down

0 comments on commit aadf09a

Please sign in to comment.