Jeromson Posted September 20, 2018 Share Posted September 20, 2018 (edited) 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 September 20, 2018 by Jeromson Link to comment Share on other sites More sharing options...
Robson Posted September 20, 2018 Share Posted September 20, 2018 I think this may solve your problem https://wiki.rage.mp/index.php?title=Player::call player.call(`RegisterWindow`, [player.socialClub]); not sure but I think you can't do this mp.events.add({'RegisterWindow': (player, player.socialClub) => { do it like this mp.events.add({'RegisterWindow': (player, socialClubID) => { Link to comment Share on other sites More sharing options...
Jeromson Posted September 20, 2018 Author Share Posted September 20, 2018 Oh thanks you 🙂 Link to comment Share on other sites More sharing options...
Larvell Posted September 21, 2018 Share Posted September 21, 2018 vor 21 Stunden schrieb Jeromson: BrowserRegisterWindow.execute("updateSocialName("+player+","+player.socialClub+");"); This syntax works the best for us: BrowserRegisterWindow.execute(`updateSocialName(${player},${player.socialClub});`); Link to comment Share on other sites More sharing options...
Jeromson Posted September 22, 2018 Author Share Posted September 22, 2018 (edited) Yes, thanks. My function was useless lol, finaly i use this : BrowserRegisterWindow.execute(`document.getElementById('socialClub').innerHTML = '${socialClubID}';`); Edited September 22, 2018 by Jeromson Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now