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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.