ziomal432 Posted July 1, 2010 Share Posted July 1, 2010 (edited) It's maybe 'cause I am n00bish, but I'm learning. function OnResourceStart() createVehicle(562, 2035.3472, 1347.7974, 10.8203) end addEventHandler("onResourceStart", getRootElement(), OnResourceStart() function OnPlayerJoin() local x = 2035.3472 local y = 1346.7974 local z = 10.8203 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Test!", source) end addEventHandler("onPlayerJoin", getRootElement(), OnPlayerJoin() When I connect to server, the screen is black. EDIT: Sorry for bad category Please move to Scripting. EDIT2: function OnResourceStart(res) createVehicle(562, 2035.3472, 1347.7974, 10.8203) end addEventHandler("onResourceStart", getRootElement(), OnResourceStart) function OnPlayerJoin() local x = 2035.3472 local y = 1346.7974 local z = 10.8203 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Siema!", source) end addEventHandler("onPlayerJoin", getRootElement(), OnPlayerJoin) Maybe it's too hard for me? Please close or remove this topic. Edited July 1, 2010 by Guest Link to comment
MaddDogg Posted July 1, 2010 Share Posted July 1, 2010 Why is your problem located at onResourceStart? I think you mean onPlayerJoin.. Does the function get called? Test this first. Is the script serverside? Do you get errors in the log file? Apart from that, you should attach the onResourceStart event to the resource's root element, it is in, otherwise the car will be created with every script file, you load onto the server. Link to comment
ziomal432 Posted July 3, 2010 Author Share Posted July 3, 2010 Maybe I badly written it. Problem is solved: function OnResourceStart(res) createVehicle(562, 2035.3472, 1347.7974, 10.8203) end addEventHandler("onResourceStart", getRootElement(), OnResourceStart) function OnPlayerJoin() local x = 2035.3472 local y = 1346.7974 local z = 10.8203 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Siema!", source) end addEventHandler("onPlayerJoin", getRootElement(), OnPlayerJoin) Link to comment
MaddDogg Posted July 3, 2010 Share Posted July 3, 2010 Although it is solved, I want to emphasize the following again: Apart from that, you should attach the onResourceStart event to the resource's root element, it is in, otherwise the car will be created with every script file, you load onto the server. If you don't fix that, you'll soon have 10 cars standing at one point. Link to comment
ziomal432 Posted July 3, 2010 Author Share Posted July 3, 2010 (edited) Sorry, I'm just somehow pensive. function OnResourceStart(res) if(res == getThisResource()) then createVehicle(562, 2035.3472, 1347.7974, 10.8203) end end addEventHandler("onResourceStart", getRootElement(), OnResourceStart) and close. EDIT: @DOWN: thanks. Edited July 3, 2010 by Guest Link to comment
50p Posted July 3, 2010 Share Posted July 3, 2010 You don't need the if statement... Just: ... addEventHandler( "onResourceStart", getResourceRootElement(), OnResourceStart ); 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