Dzemous Posted July 8, 2017 Share Posted July 8, 2017 Hello guys, I'm beginners in LUA. Why this code doesn't work? 0 DB When player joined, server giving he skin about ID 0 C-side function SskinC () triggerServerEvent ("SetSkinPlayerJoin", resourceRoot) end addEventHandler ("onClientPlayerJoin", getRootElement(), SskinC) S-side function UstawSkina() setElementModel(client, 0) end addEvent("SetSkinPlayerJoin", true) addEventHandler("SetSkinPlayerJoin", resourceRoot, UstawSkina) I don't know when I must write resourceRoot, root, getRootElement, etc. and this is my problem (Sorry for my english, but i can't pefrect his :/) Link to comment
Dimos7 Posted July 8, 2017 Share Posted July 8, 2017 (edited) C-side function SskinC () triggerServerEvent ("SetSkinPlayerJoin", root) end addEventHandler ("onClientPlayerJoin", root, SskinC) S-side function UstawSkina() setElementModel(client, 0) end addEvent("SetSkinPlayerJoin", true) addEventHandler("SetSkinPlayerJoin", root, UstawSkina) even there is a event for player join you can use but for not change your scipt here it is i hope works not tested Edited July 8, 2017 by Dimos7 Link to comment
Infinity# Posted July 8, 2017 Share Posted July 8, 2017 -- client side function changeSkinUponSpawn(team) -- The source of this event is the player that spawned -- if isElement(source) and getElementType(source) == "player" then triggerServerEvent("setSkinUponSpawning", source) end end addEventHandler ("onClientPlayerSpawn", getRootElement(), changeSkinUponSpawn) -- server side function setSkinUponSpawningCall() if source then setElementModel(source, 0) end end addEvent("setSkinUponSpawning", true) addEventHandler("setSkinUponSpawning", resourceRoot, setSkinUponSpawningCall) Keep in mind, you can only change a player's skin is when he's successfully spawned with the spawnPlayer event. "onClientPlayerJoin" is called as soon as the player join the server, you can't change his model as he hasn't been spawned yet. So we make it when the player spawns, to change his skin to 0. Can be changed from server side. Here is an example of what onClientPlayerJoin can be used for. (From MTA wiki) function remotePlayerJoin() outputChatBox("* " .. getPlayerName(source) .. " has joined the server") end addEventHandler("onClientPlayerJoin", getRootElement(), remotePlayerJoin) Link to comment
itHyperoX Posted July 8, 2017 Share Posted July 8, 2017 (edited) triggerServerEvent("triggetSomething",getLocalPlayer(),triggetSomething) -- Client --Server addEvent("triggetSomething",true) addEventHandler("triggetSomething",root,function() -- Your code here end) Edited July 8, 2017 by TheMOG Link to comment
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