The online racing simulator
Searching in All forums
(446 results)
Krayy
S2 licensed
Quote from iOL(Qc) :EDIT: I'm learning a lot doiing this!

<?php 
Event OnSplit1
$userName # Player event
IF(ToNum(GetCurrentPlayerVar("sp1")) == 0)
THEN
setCurrentPlayerVar
"sp1",ToNum(GetCurrentPlayerVar("Split1")));
$tData SplitToArrayToNum(GetCurrentPlayerVar("sp1")),"?");
dumpVar($tData);
ENDIF
IF (
ToNum(GetCurrentPlayerVar("sp1")) != && ToNum(GetCurrentPlayerVar("Split1")) > ToNum(GetCurrentPlayerVar("sp1")))
THEN
$difference 
ToNum(GetCurrentPlayerVar("Split1")) - ToNum(GetCurrentPlayerVar("sp1"));
setCurrentPlayerVar"sp1",ToNum(GetCurrentPlayerVar("Split1")) );
privMsglangEngine"^7First split difference: ^2-{0}",ToNum($difference)));
ENDIF
IF (
ToNum(GetCurrentPlayerVar("sp1")) != && ToNum(GetCurrentPlayerVar("Split1")) < ToNum(GetCurrentPlayerVar("sp1")))
THEN
$difference 
ToNum(GetCurrentPlayerVar("sp1")) - ToNum(GetCurrentPlayerVar("Split1"));
privMsglangEngine"^7First split difference: ^1+{0}",ToNum($difference)));
ENDIF
?>

Olivier

Time to learn a bit more. As GLscript is an interpreted language, try to limit the number of system calls you do, specifically using the ToNum and GetCurrentPlayerVar functions in the above code. it is more efficient for the compiler to allocate a variable than do multiple calls, so try changing it to:


<?php 
Event OnSplit1
$userName # Player event
    
$sp1 ToNum(GetCurrentPlayerVar("sp1"));
    
$Split1 ToNum(GetCurrentPlayerVar("Split1"));
    IF(
$sp1 == 0)
    
THEN
        setCurrentPlayerVar
"sp1",$Split1);
        
$tData SplitToArray$sp1),"?");
dumpVar($tData);
ENDIF
IF (
$sp1 != && $Split1 $sp1)
THEN
$difference 
$Split1 $sp1;
setCurrentPlayerVar"sp1",$Split1);
privMsglangEngine"^7First split difference: ^2-{0}",ToNum($difference)));
ENDIF
IF (
$sp1 != && $Split1 $sp1)
THEN
$difference 
$sp1 $Split1;
privMsglangEngine"^7First split difference: ^1+{0}",ToNum($difference)));
ENDIF
?>

Last edited by Krayy, .
Krayy
S2 licensed
Try using the ToNum function inside your IF statements to cast the operands to numerics. Lapper has a tendancy to assume that vars are strings rather than numbers when doing compares. i.e:


<?php 
...
IF ( 
ToNum($topSpeed) != && ToNum($instantSpeed) > ToNum($topSpeed) )
THEN
...
?>

...OR...
Do the casts when your first do the variable retrievals:

<?php 
...
$topSpeed ToNum(GetCurrentPlayerVar("topSpeed"));
$instantSpeed ToNum(GetCurrentPlayerVar("InstantSpeed"));
...
?>

Last edited by Krayy, .
Krayy
S2 licensed
I think he means that he would like some help setting up lapper with a registration system, i.e. registering and storing those player details.

Start by setting a password on your server, then have a look at some of the other threads here for membership systems
Krayy
S2 licensed
Quote from Fire_optikz001 :problem is not every one has your code for server admin and ucid

Ahhhh. I see. Sorry, I tought those functions had been put into Lapper in the last release. I'll work on a patch for it.
Krayy
S2 licensed
Quote from Fire_optikz001 :oh wait DOH my bad forgot to remove the # from the includes line 0

5/27/2010 2:44:46 PM -> Syntax error in cfg file "./member_admin.lpr" at line #178
Function not defined...UserIsServerAdmin
Function 'userisadmin' script aborted

5/27/2010 3:06:06 PM -> Syntax error in cfg file "./member_admin.lpr at line #148
Can't convert string "" to number ToNum
Function 'membertypedecrease' script aborted

:P might help if you include the exe with the mods required

I've updated the lpr file, as it had a missing $ on a var reference
Krayy
S2 licensed
Quote from Fire_optikz001 :hmm nice i will be checking this out

:/ it does not work for me :o

What errors are you getting in the lapper log?
Krayy
S2 licensed
Quote from Max Torque :...
i want to server welcome warning message, don't show to already accepted players...

Have a look here: http://www.lfsforum.net/showthread.php?p=1429435#post1429435
[CODE] Membership Administration
Krayy
S2 licensed
This LPR script provides a GUI to enable Admins to set a connected users authorisation level. users can be set from Visitor up to Admin, and there is also an overloaded UserIsAdmin function included to activate new admins straight away.

Once a user's auth level has been set, you can use the MemberStype stored var to limit other functions execution.

Installation:
1. Save file into your includes file as member_admin.lpr and add the filename to your addonsused.lpr file.

2. Replace the existing OnConnect functions in the main LFSLapper.lpr file with these:


<?php 
Event OnConnect
$userName # Player event
    
$NickName GetCurrentPlayerVar("NickName");
    
$Posabs GetCurrentPlayerVar("PosAbs");
    
$Groupqual GetCurrentPlayerVar("GroupQual");

    IF ( 
GetUserStoredNum("MemberType") >= $MEMBERTYPE_AFFILIATE )
    
THEN
        LoginMember
($userName);
    ELSE
        
openPrivButton"welc",25,50,150,15,12,-1,ISB_NONElangEngine("%{main_welc1}%"$NickName ) );
        
openPrivButton"pos",25,80,150,10,8,-1,ISB_NONE,langEngine("%{main_welc2}%",$Posabs,$Posqual,$Groupqual  ) );
        
openPrivButton"clos",78,120,20,10,10,-1,ISB_DARK,langEngine("%{main_accept}%"),OnConnectClose );
        
openPrivButton"ref",103,120,20,10,10,-1,ISB_DARK,langEngine("%{main_deny}%"),OnConnectCloseKick );
    ENDIF
EndEvent

Sub OnConnectClose
$KeyFlags,$id )
    
closePrivButton("welc&pos&clos&ref");
    
LoginNonMember(GetCurrentPlayerVar"UserName" ));
EndSub

Sub OnConnectCloseKick
$KeyFlags,$id )
    
closePrivButton("welc&pos&clos&ref");
    
cmdLFS("/kick " GetCurrentPlayerVar("UserName") );
EndSub
?>


Last edited by Krayy, .
Krayy
S2 licensed
Quote from Gai-Luron :I think ( i am not sure ) const don't work in array Index. You can bypass it using

GlobalVar $MemberTypes;
$idx = MEMBERTYPE_VISITOR;
$MemberTypes[$idx] = "Visitor";
$idx = MEMBERTYPE_GUEST;
$MemberTypes$idx] = "Guest";
...
and so on

Gai-Luron

Looks like the same applies to CASE statements as well, where I need to explicitly cast a const to be able to use it...i.e:

<?php 
    
SWITCH( $mType )

        CASE 
ToNum(MEMBERTYPE_VISITOR):
...
etc
?>


Here a cast, there a cast...
Krayy
S2 licensed
Okay, so I am defining an array using some Consts as the index like this:

consts.lpr:

<?php 
# Membership status
const MEMBERTYPE_UNKNOWN        -1# Player has not been here before
const MEMBERTYPE_VISITOR        0# Player is a visitor
const MEMBERTYPE_GUEST            1# Player is a vouched for guest
const MEMBERTYPE_JUNIOR            2# Player is Junior Member and subject to review
const MEMBERTYPE_FULL            3# Player is a full member
const MEMBERTYPE_MAX            4# Used as a upper limit for iterators
?>

utils.lpr:

<?php 
CatchEvent OnLapperStart
()
    
### Global vars for Membership names ####
    
GlobalVar $MemberTypes;
    
$MemberTypes[MEMBERTYPE_VISITOR] = "Visitor";
    
$MemberTypes[MEMBERTYPE_GUEST] = "Guest";
    
$MemberTypes[MEMBERTYPE_JUNIOR] = "Junior";
    
$MemberTypes[MEMBERTYPE_FULL] = "Full";
    
$MemberTypes[MEMBERTYPE_MAX] = "MAX";
EndCatchEvent
?>


When I try to use that array like this:

<?php 
    $mName 
$MemberTypes[2];
?>

, I get a NULL string. Turns out that I have to explicitly cast the Const as a number to initialise the aray like this:

utils.lpr:

<?php 
CatchEvent OnLapperStart
()
    
### Global vars for Membership names ####
    
GlobalVar $MemberTypes;
    
$MemberTypes[ToNum(MEMBERTYPE_VISITOR)] = "Visitor";
    
$MemberTypes[ToNum(MEMBERTYPE_GUEST)] = "Guest";
    
$MemberTypes[ToNum(MEMBERTYPE_JUNIOR)] = "Junior";
    
$MemberTypes[ToNum(MEMBERTYPE_FULL)] = "Full";
    
$MemberTypes[ToNum(MEMBERTYPE_MAX)] = "MAX";
EndCatchEvent
?>


Hmm. Is this a problem with the parser not realising tha the Const is a numeric? Because as far as I can tell, all of the Const.lpr entries are numbers, not strings.
Krayy
S2 licensed
You have semi colons after the declaraion of the Event, and after the IF conditional tests:


<?php 
$MaxSessionLaps 
2;
Event OnMaxSessionLaps$userName ); #this is line 1001
IF($SessLaps == 1;)
?>

Should be:

<?php 
$MaxSessionLaps 
2;
Event OnMaxSessionLaps$userName #this is line 1001
IF($SessLaps == 1)
?>

The IF is repeated further down
Krayy
S2 licensed
Quote from Gai-Luron :Hello,

Store session lap in player Var and test it when player rejoin the qual. But this dosen't prevent player to disconnect and reconnect.

Gai-Luron

This is why I got you add the RaceId var:


<?php 
    $RaceID 
getLapperVar"RaceId" );
    
SetStoredValue"RaceID"$RaceID);
....
CatchEvent OnNewPlayerJoin$userName )  # Player event
    
$PlayerRaceID GetUserStoredValue "PlayerRaceID");
    IF ( 
$PlayerRaceID == $RaceID )
    
THEN
        
# Rejoining from a previous session
    
ELSE
       
# Firstt ime in this session
       
SetUserStoredValue "PlayerRaceID"$RaceID);
    ENDIF
?>

Krayy
S2 licensed
Quote from Krayy :Here's a short patch to add some extra functionality, and a potential bugfix for FinishedPos:

New GetPlayerVars: ucid, plid

New functions:
getplayervarbyucid
getplayervarbyplid
userisserveradmin

Dang, my casts were causing a crash, so this is the correct patch file:
Krayy
S2 licensed
Here's a short patch to add some extra functionality, and a potential bugfix for FinishedPos:

New GetPlayerVars: ucid, plid

New functions:
getplayervarbyucid
getplayervarbyplid
userisserveradmin
Last edited by Krayy, .
Krayy
S2 licensed
Quote from lysergic :Hi, I'm sorry to ask again for your help, but I cannot make "autorestart" function working well.

My need is to have 30 minutes of qual, and then 30 or 60 minutes of races with autorestart 120 seconds after the end of each race.

But if I set autorestart = 120 every session (qual and race) restart every 120 seconds!!

Any help?

The problem is that Lapper sets the next race restart time when you have confimed results in either a race OR a qual ssession. It doesn't check whether the current session is a qual or race. Most race servers will only do race rotations, not quals.

if you have the source code, you could modify the file to restart only if its a race session.

Replace the line in managePacket.cs:

<?php 
...
        
void managePacket(InSim.Decoder.RES res// RESult (qualify or confirmed finish)
        
{
            if (
newCfg.varsLapper.AutoRestartRaceSec && ( currRace.autoRestartOn == false || newCfg.varsLapper.AutoRestartOnFirstFinished == false ))
?>

with:

<?php 
...
        
void managePacket(InSim.Decoder.RES res// RESult (qualify or confirmed finish)
        
{
            if (
newCfg.varsLapper.AutoRestartRaceSec && currRace.qualMins == && ( currRace.autoRestartOn == false || newCfg.varsLapper.AutoRestartOnFirstFinished == false ))
?>

That will only do a restart if the session has qualMins == 0, which indicates that its a race.
Krayy
S2 licensed
How about a Global stored value database that resides in the Lapper.exe directory so that you can store common variables across all Lapper instances, like Player membership status, last server joined etc. Used like:


<?php 
SetGlobalUserStoredValue
$uName"H_Mass"GetPlayerVar($uName,"H_Mass"));
$uMass GetGlobalUserStoredValue$uName"H_Mass");
?>

Krayy
S2 licensed
Quote from Gai-Luron :Hello

Sound Good.

Anyway i'am little affraid about OnDrive event called 10 time/second. It's for each player or for all?
Because that's can charge CPU. Don't forgot that GLScript is tokenized interpreted language. If you have done test and this don't change usage CPU, forgot that i say previously .

For your's modification in Lapper can you send me a svn patch?

Good job


for mode, maybe a modes.lpr displaying all mode avaiable mode registered on catchEvent OnLapperStart with function
registerMode( $idMode, "Libel mode",$state_mode, backcallOnChange );

retreived or setted by
$myMode = getMode( $idMode );
setMode( $idMode, $state );

$idMode and unique id of registered Mode
$state = "Yes" or "Complete" etc...

$state_mode are all mode selectable in gui select screen mode
example:
"Yes|No"
"Complete|Partial|None"


I hope you understand my very good english

I dont know if backcallOnChange is very usefull, in this case i have to dev a new GLScript function CallSub("nameOfSub"[,arg1,arg2,...,argn] ) to have this to work in script language



Gai-Luron

I think the idea of specific functions to register and retrieve Modes are a little too overly complex. Setting a Global using a Const as the value is a heck of a lot less fiddly, and it's only GL scripts that would use it, so a Callback would hav no purpose. i.e. the Lapper instance wouldn't care about the mode, unless you want to rewrite all of the internal functions that check if LFS is in a race, practice, qualify or other.
Krayy
S2 licensed
Okay...firstly, the http Lapper command doesn't actually make an http call and return a value, so you cannot use it in the way that you are doing.

The reason it doesn't is because it basically queues the web request and processes it in order, i.e. if someone else has sent a web request, yours will process after it and so forth, so the web request is not real time.

Also, the data that is returned by the web request is Queued in your player GL command queue, so the return form the web request should actually be a valid Lapper script command. Try something like this:

<?php 
$status 
http("http://t3charmy.tk/LFSLapper-Cruise/test.php");

Sub ShowStatus($status)
SWITCH( 
$status )
                            CASE 
"0":
WriteLine"insim is EXPIRED" );
                            BREAK;
                            CASE 
"1":
WriteLine"insim EXPIRES Today" );
                            BREAK;
                            CASE 
"2":
WriteLine"insim is not EXPIRED" );
                            BREAK;
                            DEFAULT:
WriteLine"ERROR" );                              
                            BREAK;
ENDSWITCH  
EndSub
?>


Web page should be something like this:

<?php 

$date 
"07/03";
$u_date strtotime ($date);

if (
$u_date == strtotime(date("d/m")) )
{ Print 
"1"; }
else
if (
$u_date strtotime(date("d/m")) )
{ Print 
"ShowStatus(0);"; }
else
{ Print 
"ShowStatus(2);"; }    
  
?>

Krayy
S2 licensed
Quote from Fire_optikz001 :and the $mode is also in the updated !gui (not released yet)

All the more reason to put it into Utils.lpr to make it a standard part of Lapper, so that there is one interface for turning the different modes on or off
Krayy
S2 licensed
From what you're saying, I'm assuming that you have modified the source code to allow for the custom variables. What I would suggest is to post the modifications that you have made to the code into the "Requests" thread so that Gai can integrate the modifications into future releases.

I would also suggest that you have a look at the Cruise.lpr addon, which has added the $Mode global variable to Lapper, and maybe integrate the drift system so that the drift score info only occurs when you are in Drift mode (Probably by typing "!mode drift")

NB: Acutaly we should move the !mode command inot Utils.lpr so that it becomes a standard part of Lapper. Then people can code addons to use Drift, Cruise or Race modes
Krayy
S2 licensed
Quote from Gai-Luron :Bug in who.lpr

Add line unset( $currPly ); near line 105 in who.lpr


$currUserName = $ListOfPlayersDoWho[$i];
unset( $currPly );
$currPly = getplayerinfo($ListOfPlayersDoWho[$i] );


My bad...I couldn't use a FOREACH as the FOR loop is required to print from user 16 to 32 on a 2 page output.

Also, the line above that unset ($currUserName = $ListOfPlayersDoWho[$i] is not required at all.
Krayy
S2 licensed
Quote from lysergic :No sorry, bad english. I meant that I don't want pb and splits messages to be displayed by default while racing.

PBs and splits are displayed in the Pitboard.lpr file, so if you comment out the includes for pitboard.lpr & pitwindow_gui.lpr in the addonsused.lpr file, then that will remove them.
Krayy
S2 licensed
When executing an OnLap, OnPB, OnPBQual or OnSplitX, how about passing the lap or split time as a parameter. That would save a call back in GL to retrieve the relevant playervar with very little overhead.

Maybe also the gap times for the OnNewGapPlayerBehind and OnNewGapPlayerBefore functions?
Krayy
S2 licensed
This has been asked a few times by others (myself included), as we were trying to do something similar. Bottom line is that if you are using a dedicated host, the CCH packets don't get sent at all, and if you are using a client, the CCH packets only get sent to the host each time you change viewpoint. Other LFS clients won't get the packets.

It seems to be a glaring oversight, but essentially we cannot do anything about it
Krayy
S2 licensed
Updated to ver 1.0.4 for Lapper 5.926b, and also uses new DialogCreate function in updated utils.lpr file
FGED GREDG RDFGDR GSFDG