Sign in to follow this  
Jigglypuff

HTML + JS

Recommended Posts

HTML:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/hud.css">
</head>
<body>    
<h1 class="titlearea" id="title">
<span class="pagetitle" >
            Hello
</span>
</h1>
</body>
<script src="js/hud.js"></script>
</html>

JS:
document.getElementsByClassName("pagetitle")[0].innerHTML = (`${player.name});


If I enter the text instead of player.name, then it changes the "Hello" to text, but for some reason does not change to the player's nickname. Why? Where is the mistake?

Share this post


Link to post
Share on other sites
Posted (edited)

Please show us where you define player.name. Also I believe you have a syntax error at

(`${player.name});

 

If player is an object, you would do

document.getElementsByClassName("pagetitle")[0].innerHTML = player.name;

 

Edited by introzen

Share this post


Link to post
Share on other sites

I replaced: 
document.getElementsByClassName("pagetitle")[0].innerHTML = (`${player.name});
on:

document.getElementsByClassName("pagetitle")[0].innerHTML = player.name;

I'm stupid exactly how I should define player.name in client?

 

Share this post


Link to post
Share on other sites
Posted (edited)

I'm pretty sure you're trying to reach the player property Player::name however I have never attempted that myself. I'm not at my computer right now but I'm pretty sure you should look up

mp.players.local.name

in terms of accessing the player's properties, name in particular.

Edited by introzen

Share this post


Link to post
Share on other sites
57 minutes ago, Jigglypuff said:
It still does not work, if you can - help when you're at home

I really can't help you anymore since I'm not familiar with clientside-scripting. Do your research as anyone would; first get a general understanding in how javascript works, then utilize tutorials, example scripts and forum threads to better understand how it's applied in RAGE clientside scripting.

You need to somehow access the player properties and define the variable you're trying to insert in innerHTML. The rest is up to you. I'm sure there'll be people here to help you once you get stuck, however no one will make the script for you.

I can really recommend watching @Stuyk's tutorials on YouTube since they're in-depth but also require you to have basic knowledge for what you're trying to learn. My rule of thumb is that if I don't understand what Stuyk is talking about or doing in his tutorials, I need to read more about the basics and then go back and watch again.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.