The online racing simulator
[Solved] Drift score reset
Hello,

I have a problem with resetting drift score after passing the 1st check point. Here is my code :


<?php 
CatchEvent OnSplit1
$userName # Player event
    
$DriftScore GetCurrentPlayerVar"DriftScore" );
    
$LastDriftScore GetCurrentPlayerVar"LastDriftScore" );

    IF ( 
$DriftScore )
    
THEN
        SetCurrentPlayerVar
"DriftScore");
    ENDIF

    IF ( 
$LastDriftScore )
    
THEN
        SetCurrentPlayerVar
"LastDriftScore");
    ENDIF
EndCatchEvent  
?>


End here is the error what gives in log file !


<?php 
5
/4/2012 1:18:12 PM -> Warning var "DriftScore" is readonlynot set
5
/4/2012 1:18:12 PM -> Warning var "LastDriftScore" is readonlynot set
?>


So how the code looks like to be workable ?

Thx for any comment !
Nothing to do with your code, but if you're resetting the drift score(s) back to zero, shouldn't you tell the drivers?

Anyway, try this;


<?php 
CatchEvent OnSplit1
$userName # Player event
    
IF ( GetCurrentPlayerVar"DriftScore" ) > "0" )
    
THEN
        setUserStoredValue
"DriftScore""0" );
        
privRCM ("^1Your drift score has been reset to ZERO");
        
closePrivButton"drftscoretextrev&driftcombotextrev&driftanglerev&driftangle");        
    
openPrivButton"drftscoretextrev",16,160,9,5,3,-1,0,"^1-" );
        
openPrivButton"driftcombotextrev",17,150,9,7,3,-1,0,"^1-" );
        
openPrivButton"driftanglerev",6,153,10,12,3,-1,64,"^1-" );        
    ENDIF

    IF ( 
GetCurrentPlayerVar"LastDriftScore" ) > "0" )
    
THEN
        setUserStoredValue
"LastDriftScore""0" );
        
privRCM ("^1Your drift score has been reset to ZERO");        
        
closePrivButton"drftscoretextrev&driftcombotextrev&driftanglerev&driftangle");         
    
openPrivButton"drftscoretextrev",16,160,9,5,3,-1,0,"^1-" );
        
openPrivButton"driftcombotextrev",17,150,9,7,3,-1,0,"^1-" );
        
openPrivButton"driftanglerev",6,153,10,12,3,-1,64,"^1-" );            
    ENDIF
EndCatchEvent
?>


Quote from sinanju :Nothing to do with your code, but if you're resetting the drift score(s) back to zero, shouldn't you tell the drivers?

Anyway, try this;


<?php 
CatchEvent OnSplit1
$userName # Player event
    
IF ( GetCurrentPlayerVar"DriftScore" ) > "0" )
    
THEN
        setUserStoredValue
"DriftScore""0" );
        
privRCM ("^1Your drift score has been reset to ZERO");
        
closePrivButton"drftscoretextrev&driftcombotextrev&driftanglerev&driftangle");        
    
openPrivButton"drftscoretextrev",16,160,9,5,3,-1,0,"^1-" );
        
openPrivButton"driftcombotextrev",17,150,9,7,3,-1,0,"^1-" );
        
openPrivButton"driftanglerev",6,153,10,12,3,-1,64,"^1-" );        
    ENDIF

    IF ( 
GetCurrentPlayerVar"LastDriftScore" ) > "0" )
    
THEN
        setUserStoredValue
"LastDriftScore""0" );
        
privRCM ("^1Your drift score has been reset to ZERO");        
        
closePrivButton"drftscoretextrev&driftcombotextrev&driftanglerev&driftangle");         
    
openPrivButton"drftscoretextrev",16,160,9,5,3,-1,0,"^1-" );
        
openPrivButton"driftcombotextrev",17,150,9,7,3,-1,0,"^1-" );
        
openPrivButton"driftanglerev",6,153,10,12,3,-1,64,"^1-" );            
    ENDIF
EndCatchEvent
?>



The drift score box is closing the drift points to showing but after contiunue scoring the drift without resetting the score before the split1 . So its looks like that resseting the score but truly not . . .

Any other advice will be nice ... I want this code to be workable for long time but no solution yet.

An idea : subonsplit1 = driftresetscore like someting like that ....
I'm not sure if it would work or not, but an alternative might be to set one of the global drift variables like $MinimumDriftScore to very high value in sector 1, then in sector 2, and the other sectors, drop the value back down?

Probably the $MinimumDriftScore would be best as you could put it to 9999 globally, then back to small number thereafter.

It may well be that lapper will always use the global variable and ignore the redefined variable in the sectors, so you may have to remove it globally and define it in each sector (very high in 1st sector and back to normal in other sectors).
Quote from sinanju :I'm not sure if it would work or not, but an alternative might be to set one of the global drift variables like $MinimumDriftScore to very high value in sector 1, then in sector 2, and the other sectors, drop the value back down?

Probably the $MinimumDriftScore would be best as you could put it to 9999 globally, then back to small number thereafter.

It may well be that lapper will always use the global variable and ignore the redefined variable in the sectors, so you may have to remove it globally and define it in each sector (very high in 1st sector and back to normal in other sectors).

Uh I'm a bit confused about the sectors ... I dont know what u mean under sector. Could you givem me an exampla about your meaning ? Because I cant uderstand how to realize ...
Sorry - by sectors, I actually mean splits - as in


<?php 
Event OnSplit1
$userName # Player event
$MinimumDriftScore 9999
EndEvent
?>



<?php 
Event OnSplit2
$userName # Player event
$MinimumDriftScore 100
EndEvent
?>


with Event OnSplit3 and Event OnLap both having same $MinimumDriftScore number as in OnSplit2.
Seems its doesnt work ...
I think I found where I went wrong!

Instead of setUserStoredValue, it should be SetUserStoredValue.

If you check, and it now works, you may want to use the following code as it also changes text at top of screen - not just the driftmeter.


<?php 
CatchEvent OnSplit1
$userName # Player event
    
IF ( GetCurrentPlayerVar"DriftScore" ) > "0" )
    
THEN
        SetUserStoredValue
"DriftScore""0" );
        
privRCM ("^7Your drift score has been reset to ^1ZERO");
        
closePrivButton"drftscoretextrev&driftcombotextrev&driftanglerev&driftangle&driftcomboboxtexttop");
        
closePrivButton"driftscore_399_1&driftscore_400_1&driftscore_500_1&driftscore_1000_1&driftscore_2000_1&driftscore_5000_1&driftscore_10000_1&driftscore_15000_1&driftscore_20000_1&driftscore_30000_1");        
        
openPrivButton"drftscoretextrev",16,160,9,5,3,-1,0,"^1-" );
        
openPrivButton"driftcombotextrev",17,150,9,7,3,-1,0,"^1-" );
        
openPrivButton"driftanglerev",6,153,10,12,3,-1,64,"^1-" );
        
openPrivButton"driftcomboboxtexttop",85,1,30,7,4,-1,96,"^2Total Drift Score ^3this lap: ^1ZERO");
        
openPrivButton"driftscore_temp",85,9,30,5,3,3,32,"^7Driftscore reset to ^1ZERO");                                      
    ENDIF

    IF ( 
GetCurrentPlayerVar"LastDriftScore" ) > "0" )
    
THEN
        SetUserStoredValue
"LastDriftScore""0" );
        
privRCM ("^7Your drift score has been reset to ^1ZERO");        
        
closePrivButton"drftscoretextrev&driftcombotextrev&driftanglerev&driftangle&driftcomboboxtexttop");
        
closePrivButton"driftscore_399_1&driftscore_400_1&driftscore_500_1&driftscore_1000_1&driftscore_2000_1&driftscore_5000_1&driftscore_10000_1&driftscore_15000_1&driftscore_20000_1&driftscore_30000_1");                    
        
openPrivButton"drftscoretextrev",16,160,9,5,3,-1,0,"^1-" );
        
openPrivButton"driftcombotextrev",17,150,9,7,3,-1,0,"^1-" );
        
openPrivButton"driftanglerev",6,153,10,12,3,-1,64,"^1-" );
        
openPrivButton"driftcomboboxtexttop",85,1,30,7,4,-1,96,"^2Total Drift Score ^3this lap: ^1ZERO");       
        
openPrivButton"driftscore_temp",85,9,30,5,3,3,32,"^7Driftscore reset to ^1ZERO");                    
    ENDIF
EndCatchEvent
?>


Hopefully it will all work properly now.
Done some testing, and it works ok in V6.012, but not in V6.013.

Which version are you using?

Does the layout you were using for your video have a start point and end line? This may make a difference.

Maybe you could run the test again, but this time, type !drf to get driftscore when lapper says it has reset to zero, to see if it has actually reset?
Quote from sinanju :Done some testing, and it works ok in V6.012, but not in V6.013.

Which version are you using?

Does the layout you were using for your video have a start point and end line? This may make a difference.

Maybe you could run the test again, but this time, type !drf to get driftscore when lapper says it has reset to zero, to see if it has actually reset?

I run 6.013 . The layout ha the one chackpont and a finish line so the lap are lapped. The lapper doesnt reset the score just close the score "windows" but continue scoring !
This thread is closed

FGED GREDG RDFGDR GSFDG