Hello,
I'm new in lua and I'm a having a little trouble getting started.
I've create a very basic gamemodescript:
the meta.xml file:
<meta>
<info name="Fun Mode" author="StreetFighter442" version="1.0" />
<script src="script.lua" type="server" />
<script src="modelreplace.lua" type="client" />
</meta>
here's the script.lua:
function joinHandler()
local x = 1959.55
local y = -1714.46
local z = 10
spawnPlayer(source, x, y, z)
fadeCamera(source, true)
setCameraTarget(source, source)
outputChatBox("Welcome balb to My Server", source)
end
function loadMapFile ( filename )
node = getResourceConfig ( filename )
-- Check if the file was loaded ok
if ( node ) then
-- Load the loaded xml file into the element tree
loadMapData ( node, getRootNode )
-- Unload the xml file again
xmlUnloadFile ( node )
end
end
function createVehicleForPlayer(thePlayer, commend)
outputChatBox("test: "..getPlayerName(thePlayer),thePlayer)
local x2,y2,z2 = getElementPosition(thePlayer) -- get the position of the player
local orgx,orgy,orgz = getElementPosition(thePlayer) -- get the position of the player
for i=0,20,1 do
x2 = x2 + 1 -- add 5 units to the x position
local createdVehicle = createPed(127,x2,y2,z2)
--local rot = atan2(orgx,orgy,x2,y2);
--setPedRotation(rot)
--setPedControlState(createdVehicle, "fire", true)
--setPedAnimation(createdVehicle, "ped", "WOMAN_walknorm")
-- check if the return value was ''false''
if (createdVehicle == false) then
-- if so, output a message to the chatbox, but only to this player.
outputChatBox("Failed to create ped.",thePlayer)
end
end
end
addCommandHandler("createped", createVehicleForPlayer)
addEventHandler("onPlayerJoin", getRootElement(), joinHandler)
and here's the modelreplace.lua:
function remotePlayerJoin()
outputChatBox("* " .. getPlayerName(source) .. " has joined the server")
end
addEventHandler("onClientPlayerJoin", getRootElement(), remotePlayerJoin)
If i join now my server with the gamemode above running, I get an "error downloading requested files" error, but if join my server when he's running the freeroam gamemode everything works fine.
Hope you can help,
Thanks in advance.