Hyunsu_Oh Posted March 13, 2010 Posted March 13, 2010 (edited) sorry, my bad english. GRoot = getRootElement() GRRoot = getResourceRootElement() function ClientModeStart(startedmode) end addEventHandler("onClientResourceStart", GRRoot, ClientModeStart) function ClientPlayerJoin() outputChatBox("* " .. getPlayerName(source) .. " has joined the server") end addEventHandler("onClientPlayerJoin", GRoot, ClientPlayerJoin) function ClientPlayerSpawn() outputChatBox("* " .. getPlayerName(source) .. " spawned") end addEventHandler ("onClientPlayerSpawn", GRoot, ClientPlayerSpawn) onClientPlayerSpawn worked. onClientResourceStart worked. but onClientPlayerJoin didn't work. please. help me. Edited March 13, 2010 by Guest
karlis Posted March 13, 2010 Posted March 13, 2010 would be better if you put script in [/code] tags [code=lua]
DiSaMe Posted March 13, 2010 Posted March 13, 2010 Did you test onClientPlayerJoin with remote player? It doesn't work with local player as the script is downloaded when the player has already joined.
Hyunsu_Oh Posted March 13, 2010 Author Posted March 13, 2010 Did you test onClientPlayerJoin with remote player? It doesn't work with local player as the script is downloaded when the player has already joined. if i enter my server, i don't see onClientPlayerJoin event?
Dark Dragon Posted March 13, 2010 Posted March 13, 2010 exactly, this event is triggered for every player except you. you can see others join, they can see you join but you can't see yourself join.
Hyunsu_Oh Posted March 13, 2010 Author Posted March 13, 2010 exactly, this event is triggered for every player except you. you can see others join, they can see you join but you can't see yourself join. thank you Then, Don't i trigger "onClientPlayerJoin" event? if so, how can i trigger the event?
Gamesnert Posted March 13, 2010 Posted March 13, 2010 If you want to run something at a player who just joined, check when the resource starts. onClientResourceStart
Hyunsu_Oh Posted March 13, 2010 Author Posted March 13, 2010 what relation "onClientResourceStart" to my question? i don't know.
MCvarial Posted March 13, 2010 Posted March 13, 2010 The onClientResourceStart event is triggered when a resource is started clientside, if you use getResourceRootElement() as the source it will trigger if for the resource containing your script, in other words right after the localplayer has finished downloading his resources.
toneysix Posted May 23, 2010 Posted May 23, 2010 The onClientResourceStart event is triggered when a resource is started clientside, if you use getResourceRootElement() as the source it will trigger if for the resource containing your script, in other words right after the localplayer has finished downloading his resources. I have same problem. I'm new scripter of MTA, and this event just wont works for me, so i have to do something like it: addEventHandler( "onClientResourceStart", getRootElement(), function(startedRes) OnPlayerJoinToServer() end ); function OnPlayerJoinToServer() outputChatBox("* " .. getPlayerName(source) .. " зашёл на сервер.") fadeCamera(true) setCameraTarget(getLocalPlayer()) setCameraMatrix(1478.797119, -1756.001953, 115.093994, 1528.569336, -1670.147827, 102.773277) end addEventHandler("onClientPlayerJoin", getRootElement(), OnPlayerJoinToServer) ?
Dark Dragon Posted May 23, 2010 Posted May 23, 2010 you call OnPlayerJoin when the local client started the resource, but the source of onClientResourceStart is not the local player because onClientPlayerJoin has no parameters you can use this (hacky) way, but don't tend to try it with other events! addEventHandler( "onClientResourceStart", getRootElement(), function(startedRes) OnPlayerJoinToServer(getLocalPlayer()) -- use the local player as first parameter end ); function OnPlayerJoinToServer(theplayer) local player = theplayer or source -- set our target player to be theplayer if existent, else to source outputChatBox("* " .. getPlayerName(player) .. " зашёл на сервер.") -- are those next three lines really what you want to happen whenever someone joins? -- you might want to put those lines in the function above. fadeCamera(true) setCameraTarget(getLocalPlayer()) setCameraMatrix(1478.797119, -1756.001953, 115.093994, 1528.569336, -1670.147827, 102.773277) -- end addEventHandler("onClientPlayerJoin", getRootElement(), OnPlayerJoinToServer)
toneysix Posted May 23, 2010 Posted May 23, 2010 you call OnPlayerJoin when the local client started the resource, but the source of onClientResourceStart is not the local playerbecause onClientPlayerJoin has no parameters you can use this (hacky) way, but don't tend to try it with other events! Big thanks, its works!
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