Hello everyone. I started to write mode using the Wiki, but I have a black screen when you connect. Show where the error, please?
test.lua:
-- sets colors when player join
function onJoin ()
g_Red, g_Green, g_Blue = math.random (50, 255), math.random (50, 255), math.random (50, 255)
end
-- checks if player has sent a message
function onChat ( message, messageType )
if messageType == 0 then
local root = getRootElement()
outputChatBox ( getPlayerName ( source ) .. ": #E0D0B0" .. message, getRootElement(), g_Red, g_Green, g_Blue, true )
cancelEvent()
end
end
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin)
addEventHandler ( "onPlayerChat", getRootElement(), onChat )
-- Get a table of all the players
players = getElementsByType ( "player" )
-- Go through every player
-- when a player spawns,
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension )
-- Spawn them at the desired coordinates
spawnPlayer ( playerValue, 0.0, 0.0, 5.0, 90.0, 0 )
giveWeapon ( source, 31, 200 ) --M4
giveWeapon ( source, 36, 200 ) --Heat Seeker
end
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn )
-- we register quitPlayer as a handler for the event
function quitPlayer ( quitType )
-- we store the player's name
local quittingPlayerName = getPlayerName ( source )
-- and send the message to the server
outputChatBox ( quittingPlayerName .. " has left the server (" .. quitType .. ")" )
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )
function playerDied(totalAmmo, killer, killerWeapon, bodypart)
outputChatBox(getPlayerName(source).." died!")
end
addEventHandler("onPlayerWasted",getRootElement(),playerDied)
function respawnVehicle( vehicle )
spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) )
end
test_client.lua:
function remotePlayerJoin()
outputChatBox("* " .. getPlayerName(source) .. " has joined the server")
end
addEventHandler("onClientPlayerJoin", getRootElement(), remotePlayerJoin)
function onQuitGame( reason )
outputChatBox ( getPlayerName( source ).." has left the server ("..reason..")" )
end
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )
function explosionOnSpawn ( )
-- get the spawned player's position
local pX, pY, pZ = getElementPosition ( source )
-- and create an explosion there
createExplosion ( pX, pY, pZ, 6 )
fadeCamera( true )
end
-- add this function as a handler for any player that spawns
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), explosionOnSpawn )
function addRednessOnDamage ( )
fadeCamera ( source, false, 1.0, 255, 0, 0 ) -- fade the player's camera to red over a period of 1 second
setTimer ( fadeCamera, 500, 1, source, true, 0.5 ) -- don't let it go to opaque red, interrupt it after half a second and fade back to normal
end
addEventHandler ( "onPlayerDamage", getRootElement(), addRednessOnDamage )
function showClientImage()
guiCreateStaticImage( 20, 200, 100, 100, "image\logo.png", false )
end
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage )
P.S. Sorry for my bad english..