Hyunsu_Oh Posted March 13, 2010 Share 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 Link to comment
karlis Posted March 13, 2010 Share Posted March 13, 2010 would be better if you put script in [/code] tags [code=lua] Link to comment
DiSaMe Posted March 13, 2010 Share 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. Link to comment
Hyunsu_Oh Posted March 13, 2010 Author Share 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? Link to comment
Dark Dragon Posted March 13, 2010 Share 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. Link to comment
Hyunsu_Oh Posted March 13, 2010 Author Share 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? Link to comment
Gamesnert Posted March 13, 2010 Share Posted March 13, 2010 If you want to run something at a player who just joined, check when the resource starts. onClientResourceStart Link to comment
MCvarial Posted March 13, 2010 Share Posted March 13, 2010 You could use the onClientResourceStart event. Link to comment
Hyunsu_Oh Posted March 13, 2010 Author Share Posted March 13, 2010 what relation "onClientResourceStart" to my question? i don't know. Link to comment
MCvarial Posted March 13, 2010 Share 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. Link to comment
Hyunsu_Oh Posted March 14, 2010 Author Share Posted March 14, 2010 Thank for everyone. Link to comment
toneysix Posted May 23, 2010 Share 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) ? Link to comment
Dark Dragon Posted May 23, 2010 Share 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) Link to comment
toneysix Posted May 23, 2010 Share 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! 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