Sign in to follow this  
Jeromson

variable from server-side to client-side with events call ?

Recommended Posts

Hello,

i have a problem to pass a variable from server side to client side with the funtion events call :

 

Server side

mp.events.add('playerJoin', player => {
    console.log(`[GTARAGE]: Joueur ${player.socialClub} - IP :[${player.ip}] a rejoint le serveur.`);
                    if(player.socialClub) == true){
                        console.log(`[GTARAGE]: Joueur ${player.socialClub} trouvé dans la collection.`);
                        player.call(`LoginWindow`, player.socialClub);
                    } else {
                        console.log(`[GTARAGE]: Joueur ${player.socialClub} inconnu.`);
                        player.call(`RegisterWindow`, player.socialClub);
                    };

    player.model = mp.joaat('player_zero');
    player.spawn(new mp.Vector3(-425.517, 1123.620, 325.8544));
});

 

Client side :

var BrowserRegisterWindow = mp.browsers.new('package://gtarage/ui/accountRegister.html');

mp.events.add({'RegisterWindow': (player, player.socialClub) => {
	// Create register window
	BrowserRegisterWindow.execute("updateSocialName("+player+","+player.socialClub+");");
	}
});

In HTML :

 

 

<script>
function updateSocialName(player) {
let socialname = "player.socialClub";
document.getElementById("socialName").innerText = "player.socialClub";
};
 
</script>

 

I want get player social Club in browser, Can you help me pls ?

Edited by Jeromson

Share this post


Link to post
Share on other sites
vor 21 Stunden schrieb Jeromson:

BrowserRegisterWindow.execute("updateSocialName("+player+","+player.socialClub+");");

 

This syntax works the best for us:

BrowserRegisterWindow.execute(`updateSocialName(${player},${player.socialClub});`);

 

Share this post


Link to post
Share on other sites

Yes, thanks. My function was useless lol, finaly i use this :

BrowserRegisterWindow.execute(`document.getElementById('socialClub').innerHTML = '${socialClubID}';`);
 
Edited by Jeromson

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.