Sziasztok! Kezdem érteni ezt a setElementData meg getElementData dolgok de mégis kellene egy kis segítség: :unsure:
Client oldali script. iMaxScore-t elmentem driftscore néven setElementData-val amikor véget ér a drift. Ezt le is ellenőrzöm, elmenti. Ezt amikor kilép a player server oldalon lekérem. De aztán mikor belép a játékos hogy töltsem ezt neki be az iMaxScore-ba hogy lássa mennyivel lépett ki előzőleg?!
Client:
local iDriftScore = 0;
local iMaxScore = 0;
local iScore = 0;
local iMyCombo = 1;
local fCustomFontScale = 2;
local bJustFinished = false;
local player = getLocalPlayer( )
addEventHandler( \"onClientMapStarting\", root,
function( tMapInfo )
iMaxScore = 0;
iDriftScore = 0;
iMyCombo = 0;
txtBestScore: text( \"Best score:\" );
for i, v in pairs( tMapInfo ) do
outputDebugString( tostring( i ) .. \" : \" .. tostring( v ) );
end
end
);
addEventHandler( \"onClientResourceStart\", resourceRoot,
function( )
dxSetTestMode( \"none\" );
txtCombo = dxText: create( \"x2\", screenSize[ 1 ] - 100, screenSize[ 2 ] / 2 , false, \"default-bold\", 5 );
txtCombo: type( \"shadow\", 4 );
txtCombo: visible( false );
txtComboTitle = dxText: create( \"COMBO\", screenSize[ 1 ] * 0.9, screenSize[ 2 ] / 2 - 60, false, \"default-bold\", 3 );
txtComboTitle: type( \"shadow\", 3 );
txtComboTitle: visible( false );
txtScoreTitle = dxText: create( \"DRIFT\", screenSize[ 1 ] / 2, screenSize[ 2 ] / 5.6, false, \"default-bold\", 3 );
txtScoreTitle: type( \"shadow\", 3 );
txtScoreTitle: visible( false );
txtScore = dxText: create( \"\", screenSize[ 1 ] / 2, screenSize[ 2 ] / 4, false, \"default-bold\", 3 );
txtScore: visible( false );
txtScore: type( \"shadow\", 3 );
txtBestScore = dxText: create( \"Best score: 0\", screenSize[ 1 ] * 0.8, 20, false, \"arial\", 2 );
txtBestScore: type( \"shadow\", 2 );
ftDigitalism = dxCreateFont( \"digitalism.ttf\", 20, true );
if ftDigitalism then
txtCombo: font( ftDigitalism );
txtCombo: scale( fCustomFontScale );
txtComboTitle: font( ftDigitalism );
txtComboTitle: scale( fCustomFontScale*.7 );
txtScore: font( ftDigitalism );
txtScore: scale( fCustomFontScale );
txtScoreTitle: font( ftDigitalism );
txtScoreTitle: scale( fCustomFontScale );
txtBestScore: font( ftDigitalism );
txtBestScore: scale( fCustomFontScale/2 );
end
end
)
addEventHandler( \"onClientVehicleStartDrift\", root,
function( )
addEventHandler( \"onClientVehicleDrift\", root, drift );
if not bJustFinished then
txtScore: text( \"0\" );
txtScore: visible( true );
txtScoreTitle: visible( true );
local r,g,b,a = txtScore: color( );
txtScore: color( r, g, b, 255 );
end
end
)
addEventHandler( \"onClientVehicleEndDrift\", root,
function( )
removeEventHandler( \"onClientVehicleDrift\", root, drift );
iLastScore = iDriftScore * iMyCombo;
txtCombo: visible( false );
txtComboTitle: visible( false );
txtScore: text( tostring( iLastScore ) );
Animation.createAndPlay( txtScore,
Animation.presets.dxTextMove(
screenSize[ 1 ] / 2,
screenSize[ 2 ] / 4,
100, false,
screenSize[ 1 ] * .3,
screenSize[ 2 ] / 4
)
);
--Animation.createAndPlay( txtScore, Animation.presets.dxTextFadeIn( 100 ) );
Animation.createAndPlay( txtScoreTitle,
Animation.presets.dxTextMove(
screenSize[ 1 ] / 2,
screenSize[ 2 ] / 5.6,
100, false,
screenSize[ 1 ] * .7,
screenSize[ 2 ] / 5.6
)
);
--Animation.createAndPlay( txtScoreTitle, Animation.presets.dxTextFadeIn( 300 ) );
if iLastScore > iMaxScore then
txtBestScore: text( \"Best Score: \" .. tostring( iLastScore ) );
iMaxScore = iLastScore;
end
bJustFinished = true;
setTimer( changeFinishedState, 2000, 1 );
setTimer( centreScore, 100, 1 );
iDriftScore = 0;
iMyCombo = 1;
setElementData(player, \"driftscore\", iMaxScore)
lol = getElementData(player, \"driftscore\")
outputChatBox(lol)
end
)
addEventHandler( \"onClientVehicleDriftCombo\", root,
function( iCombo )
txtCombo: text( \"x\"..tostring( iCombo ) );
txtCombo: visible( true );
txtComboTitle: visible( true );
playSoundFrontEnd( 43 );
Animation.createAndPlay( txtCombo, Animation.presets.dxTextMoveResize(
screenSize[ 1 ] * 0.9,
screenSize[ 2 ] / 2 - 10,
ftDigitalism and fCustomFontScale*.75 or 5,
300, false, -- time, loop,
screenSize[ 1 ] * 0.9,
screenSize[ 2 ] / 2 - 10,
ftDigitalism and fCustomFontScale*3 or 15 ) );
Animation.createAndPlay( txtCombo, Animation.presets.dxTextFadeIn( 300 ) );
iMyCombo = iCombo;
end
);
function drift( fAngle, fSpeed, sSide, iDriftTime )
local iNewScore = math.ceil( iDriftScore + (fAngle/25) * (fSpeed/15) );
if not bJustFinished then
txtScore: text( tostring( iNewScore ) );
txtScore: visible( true );
txtScoreTitle: visible( true );
local r,g,b = txtScore: color( );
txtScore: color( r, g, b, 255 );
end
iDriftScore = iNewScore;
end
function centreScore( )
txtScore: position( screenSize[ 1 ] / 2, screenSize[ 2 ] / 4, false )
txtScoreTitle: position( screenSize[ 1 ] / 2, screenSize[ 2 ] / 5.6, false );
end
function changeFinishedState( )
bJustFinished = false;
if iDriftScore == 0 then
txtScore: visible( false );
txtScoreTitle: visible( false );
else
txtScore: text( tostring( iDriftScore ) );
end
end
function iMaxScore()
iMaxScore = getElementData(player, \"driftscore\")
end
addEventHandler(\"onClientResourceStart\",root,iMaxScore)
Server:
local iMaxScore = getElementData(source, \"driftscore\")
end
addEventHandler(\"onPlayerQuit\",myscore)]