Yes, let's say you have 2 script files named Server.Lua and Client.Lua. You know what file is which, but we must also tell the server which file is which and that is done in the meta file.
<script src="Server.Lua" type="server" />
<script src="Client.Lua" type="client" />
Alright, so now then, we want to call something to run from the Client File, so we will make some function in the Client File (AKA Client Side):
function ClientTest() -- The custom function name
outputChatBox("Test: I'm the Client Script!") -- Just a very basic test message
addEvent("Client-ClientTest",true) -- We must add this event to be able to call it from the Server Script
addEventHandler("Client-ClientTest",getRootElement(),ClientTest) -- We must also add this Event Handler to point it correctly at our Function
Now we'll be able to call the new function from the Server File (AKA Server Side):
outputChatbox("This is the Server Script!",source) -- Another very basic message
triggerClientEvent(source,"Client-ClientTest",source) -- Calls the Client Side Event/Function
In this example, you would get 2 messages in the chat, one from the Server and the other from the Client
If you use setCameraTarget(90, 90, 90) then it will show where ever X(90) is, Y(90) is and Z(90) is and thats not what you want... What you need to do is figure out where you want the camera to be looking at and use the coordinates of that exact location (No angles, rotations, etc)
I remember that in 2012 it worked perfectly with update 1.2
I think that was it. And now that I want to go back to make race maps I realized that this resource does not work well...
when I define the game mode everything goes very well if it works, but when it is time to put the road controlpoint it is bad,
instead of leaving the cs_roadbridge04 file only a trash can comes out as a control point.
This is how it should look and how it should work, I don't know why in older versions this works well and in recent versions it doesn't. I hope someone can solve this
Sorry, forgot to add the "end" for the function itself...
number = 0 -- Declare the variable outside the function
number = number + 1 -- Add +1 so it changes each time the function is called
local msg = messages[number] -- Display the Message
if number = 3 then -- If it just Displayed the last Message...
number = 0 -- Reset it to start all over again
end -- Forgotten End :(
I'm new to this. I'm having trouble understanding the functional part of it. I do understand the idea, though.
This is what I understood from your comment: since this is a client event, I need to create a script that's running in a "client.Lua" file. I created it and edited the meta.xml to look for the source file (type="client"). Up to this point, is this the correct way to proceed?
The script looks like this:
-- player spawns at coordinates 2023, 1008, 10.83, with a rotation of -90, and a randomized skin id between 1 and 288.
spawnPlayer(source, 2023, 1008, 10.83, -90, math.random (1,288))
-- screen fades from black to color.
-- if target not defined, syntax maintains player targeted
setCameraTarget(90, 90, 90) -- (targetX, targetY, targetZ) adding different values ranging 0-359 changes nothing
addEventHandler("onPlayerJoin", getRootElement(), joinHandler)
I added X, Y, Z = 90 to have round values and to see a noticable change to the camera, if any. And just to be sure, I added the same line to server.Lua. Console threw an error coming from server.Lua, so I deleted the line and the error went away. However, the script doesn't seem to be working. Nothing is happening. The camera is still pointing to the north. There are no errors coming from client.Lua.
(off context: how come the error only comes from server.Lua, even though both server.Lua and client.Lua have the same line?)