The online racing simulator
Searching in All forums
(446 results)
Krayy
S2 licensed
Updated code to ver 1.0.1 to fix a problem where the brackets are reversed i.e. Krayy]LFSNZ[ will now give Team warning rather than crash Lapper ;-)

NOTE: The code matches the FIRST occurrences of each bracket, so having your name as "Krayy[[lfsnz]" wil show team as [LFSNZ. I have to assume that people are not that stupid as to use heaps of square brackets in their name, unless that are l33t of course.
Krayy
S2 licensed
Quote from Krayy :If you have the latest Lapper and utils.lpr from the community edition, the !am command is already there.

I'm also just about finished a !tc command for team chat whoich wil abstract the !red command to send messages to anyone who hasd the same team as you, as long as it is surrounded by the same delimiter like square brackets. Will post later today

TeamChat Lapper module now in this thread: http://www.lfsforum.net/showthread.php?p=1540420#post1540420
[CODE] TeamChat Lapper script
Krayy
S2 licensed
Hi all,

Here's v1.0.0 of a module that had it's genesis in a discussion in the Config thread, being able to send a chat message to everyone in your team. To use it just save this file in your includes directory, rename it to TeamChat.lpr then add this module name to your addonsused.lpr file.

To use it in game, make sure that you and the other members of your team have their in game Name set with their team name in square brackets (this can be changed in the module) i.e. Krayy[LFSNZ]. Then when you type "!tc <msg>" everyone who has the same team name will see the message and no one else.

Any bugs, PM me or post here so I can fix it up.
Last edited by Krayy, .
Krayy
S2 licensed
Quote from m1chi119 :Thanks :-)
how to create a similar chat-command like !red but let the chat only be viewable by admins? :-) so let it check if ppl are admins then send to them? :-O

If you have the latest Lapper and utils.lpr from the community edition, the !am command is already there.

I'm also just about finished a !tc command for team chat whoich wil abstract the !red command to send messages to anyone who hasd the same team as you, as long as it is surrounded by the same delimiter like square brackets. Will post later today
Krayy
S2 licensed
Quote from vdl-nei :Hi i've read posts on the sub forum but i've not find the answer about the disparition of flags during the race.
Is there a method or a code to correct it?

Could you explain the problem a little bit more? I'm not sure what you are trying to fix.
Krayy
S2 licensed
Your IF statement where you check if the IndexOf was successful is using the wrong var - idxSpace instead of IdxOfTag. Change it to this:

<?php 
        
CASE "!red"
            IF( 
$argv != "" )    
            
THEN  
            $temp 
GetListOfPlayers( );                    
                FOREACH( 
$maVar IN $temp )  
                
$NickName GetPlayerVar($maVar["value"], "NickName");  
                
$NickStrip StripLFSColorToLower($NickName) );  
                
$IdxOfTag indexOf$NickStrip "[r]");  
                    IF( 
$IdxOfTag != -)  
                    
THEN  
                        privMsg 
($maVar["value"],"^1Red: ^7".$argv);
                    ENDIF  
                ENDFOREACH  
            ENDIF  
        BREAK;
?>

Krayy
S2 licensed
Quote from emit-nl :Cool, I'm looking foward to see the result! ^^

Tim

Me too...even I don't know what I'm up to some of the time
Krayy
S2 licensed
Quote from emit-nl :Hi Krayy,

When do you think the CIF will be released?
Are you planning to release the CIF framework first or the whole CIF at once?

I would like to have a look on the new framework when it's finished, because then I can maybe add some functions too.

Hope to hear from you soon

Tim

Hi Tim,

I was in the USA for a week at a conference and am trying to catch up with work et al, so I should have something ready for release v.soon.
Krayy
S2 licensed
Quote from Fire_optikz001 :is there anyway i could add custom permissions? such as CRUISE_POLICE and CRUISE_TOW?

Just add the new member types in between GUEST and AFFILIATE in the top of the membership.lpr file and increases the membertype numbers like this:


<?php 
    
# Membership status Globals
    
GlobalVar $MEMBERTYPE_UNKNOWN;     $MEMBERTYPE_UNKNOWN    = -1# Player has not been here before
    
GlobalVar $MEMBERTYPE_VISITOR;     $MEMBERTYPE_VISITOR    0# Player is a visitor
    
GlobalVar $MEMBERTYPE_GUEST;     $MEMBERTYPE_GUEST    1# Player is a vouched for guest
    
GlobalVar $CRUISE_TOW;     $CRUISE_TOW    2;
    
GlobalVar $CRUISE_POLICE;     $CRUISE_POLICE    3;
    
GlobalVar $MEMBERTYPE_AFFILIATE;$MEMBERTYPE_AFFILIATE     4# Player is Affiliate Member and subject to review
    
GlobalVar $MEMBERTYPE_FULL;        $MEMBERTYPE_FULL    5# Player is a full member
    
GlobalVar $MEMBERTYPE_ADMIN;    $MEMBERTYPE_ADMIN    6# Player is an admin
    
GlobalVar $MEMBERTYPE_MAX;        $MEMBERTYPE_MAX        7# Used as a upper limit for iterators

    ### Global vars for Membership names ####
    
GlobalVar $MemberTypes;
    
$MemberTypes[$MEMBERTYPE_VISITOR] = "Visitor";
    
$MemberTypes[$MEMBERTYPE_GUEST] = "Guest";
    
$MemberTypes[$MEMBERTYPE_AFFILIATE] = "Affiliate";
    
$MemberTypes[$MEMBERTYPE_FULL] = "Full";
    
$MemberTypes[$MEMBERTYPE_ADMIN] = "Admin";
    
$MemberTypes[$MEMBERTYPE_MAX] = "MAX";
    
$MemberTypes[$CRUISE_TOW] = "Towtruck";
    
$MemberTypes[$CRUISE_POLICE] = "Copper";
?>

Krayy
S2 licensed
I meant data that could be grouped from a high to low value like !Top e.g. Speed at a track node, split times, points, total wins, wins at a track, wins in a car.

Basically what I'm thinking is a database that stores a key/value where the value is a numeric that can be sorted from high to low (or vice versa). Then you could write Lapper scripts to use it like:

GetVarList("cruise_points");
GetVarList("race_points");

or similar to return a list of the top cruise or race points, or any other user defined var name.
Krayy
S2 licensed
Quote from sinanju :...
Is it possible to do !top type command with this kind of value?

In a word, no. The GetListTop function is hard coded to accept only 3 parameters, which are a list of car names (with + signs between for multiple cars), a boolean value (TRUE or FALSE) for if it's Qaulifying times, and a boolean value for times that are near your pb i.e.

<?php 
 GetListTop
$argv,$flagQual,$flagNear );
?>

You can't use it to store fastest times.....yet ;-)
It's obviouse that people want to be able to store the best values of something so that they can use it to do stats like top, and I don't see why I can't modify the code to support virtually any kind of data, as long as it is numerically comparable like speeds, times, points etc.

So that being said, let's get a list together of what values people want to store and I'll see if I can modify the code to support it.

Note that this would be a code modification away from the standard LFS versions, but I'd submit it to Gai to see if he could incorporate it into the codebase.
Last edited by Krayy, .
Krayy
S2 licensed
I should have clarified the difference...

There's a rule of thumb that we need to consider here...you can only retrieve data from the User database (using GetUserStoredValue) if you know the users name. In most circumstances, this limits you to the users who are online.

So if you are want to store data that can refernce a user that is not online, then you will need to use the global Store and Get functions e.g. you want to display the # of races that users had run and include offline users, you would most likely need to use the global db, but then you need to store the data like this:

$varname = "topspeed_" . $track . "_" . $car; # Like topspeed_AS1_BL1
SetStoredValue($varname, "sinanju:160,krayy:155,tim_nl:90,etc);

$times = SplitToArray($varname, ",");
FOR( $i = 0; $i < 10; $i = $i + 1)
privMsg("Racer number ". $i . " is " . $times[$i]):
ENDFOR
Krayy
S2 licensed
// Confirmation flags

#define CONF_MENTIONED 1
#define CONF_CONFIRMED 2
#define CONF_PENALTY_DT 4
#define CONF_PENALTY_SG 8
#define CONF_PENALTY_30 16
#define CONF_PENALTY_45 32
#define CONF_DID_NOT_PIT 64

#define CONF_DISQ (CONF_PENALTY_DT | CONF_PENALTY_SG | CONF_DID_NOT_PIT)
#define CONF_TIME (CONF_PENALTY_30 | CONF_PENALTY_45)
Krayy
S2 licensed
Quote from Dygear :I was hoping that GLScript would have some Bitwise operators, maybe someone with more knowledge could help with that.

You can replace that with this until then:


<?php 
IF $flagConfirm == || $flagConfirm == 18 || $flagConfirm == 34 THEN
?>



It does indeed have both Bitwise and boolean operators which are:

|| = Boolean OR
&& = Boolean AND
| = Botwise OR
& = Bitwise AND

So the shorthand for (which is incorrect btw:

<?php 
     
IF(( $flagConfirm == )||( $flagConfirm == 18 )||( $flagConfirm == 34 ))
?>

Would be:

<?php 
IF ( $flagConfirm 50 )
THEN
...
?>

There is no XOR operator though, so you'll need to fake that if you want to.
utils.lpr - Community Edition
Krayy
S2 licensed
Hi guys,

There are a few addons floating around that depend on a number of globals or functions that are buried within the forums, so in the interest of making it a little easier for people to find them, I would suggest that we maintain a Community Edition utils.lpr that is as up to date as it can be. This would be for GlobalVars and utility functions that can be used in any other module, not ones that are tied to a specific use.

To use, download file, then rename it to "utils.lpr" and put it in your Lapper instance includes directory, e,g. c:\LFSLapper\default\includes.

Have a look at it and send on any updates you thiink would be useful and I'll update the file as we go.

Note that this utils.lpr is designed to work with Lapper versions > 5.925


2/1//2010: Number of additions to include DEBUG and Admin Messaging functions
31/12/2010: Added StrReplace function to replace a string within a string
12/01/2011: Added array that contains LFS car defines for new CIF !top module
24/01/2011: Changed LFSCarList array define to make more streamlined
2/7/2012 - Minor updates
Last edited by Krayy, .
Krayy
S2 licensed
Quote from Dygear :That should be easier to debug, and maintain.

Use an array for the date conversion instead of huge IF loops which are inefficient and can become hard to maintain. It also means that you only need to define the months or whatever data you're using once and it can be reused any time. Also, you can use the language functiosn to make your months language specific:

This goes in utils.lpr:

<?php 
CatchEvent OnLapperStart
()
    
GlobalVar $MONTHS;
    
$MONTHS[1] = "January";
    
$MONTHS[2] = "February";
    
$MONTHS[3] = "March";
    
$MONTHS[4] = "April";
    
$MONTHS[5] = "May";
    
$MONTHS[6] = "June";
    
$MONTHS[7] = "July";
    
$MONTHS[8] = "August";
    
$MONTHS[9] = "September";
    
$MONTHS[10] = "October";
    
$MONTHS[11] = "November";
    
$MONTHS[12] = "December";
EndCatchEvent

Sub GetMonth
()
    
$date getLapperVar("ShortDate");    # Get date in dd/mm/yyyy format
    
return($MONTHS[ToNum((substr($date32)))]);        # Strip the month from the short date
EndSub
?>


Now you can get the current Month by calling that function like:

<?php 
$month 
GetMonth();
?>

This goes in whatever .lpr file you're using the function in:

<?php 
Event OnResult
($userName$flagConfirm)    # Player event
    
$date getLapperVar("ShortDate");    # Get date in dd/mm/yyyy format
    
$year substr($date64);        # Find the year
    
$month GetMonth();        # Strip the month from the short date

    
$champs $month " " $year;
    
SetCurrentPlayerVar($champsgetUserStoredValue($champs));
    IF (
GetCurrentPlayerVar($champs) == ""THEN
        SetCurrentPlayerVar
($champs"0");
    ENDIF

    
$Pos GetCurrentPlayerVar("FinishedPos");
    IF ((
$Points = (($ps_max_points 1) - $Pos)) < 1THEN
        $Points 
0;
    ENDIF
    
SetCurrentPlayerVar("ps_race_points"$Points);

    
# Print Header
    
IF ($Pos == 1THEN
        openGlobalButton
("PointHeaderName"$point_L$point_T 44044, -196"^7 Race on ^3" getLapperVar("LongDate") . " @ " getLapperVar("LongTime"));
        
openGlobalButton("PointHeaderPoints"$point_L 40$point_T 4644, -196"^7points");
    ENDIF

    IF 
$flagConfirm 2 THEN # 2 means that the result is confirmed. (As CONF_CONFIRMED = 2);
        
openGlobalButton("PointBodyName" $Pos$point_L$point_T + ($Pos 4), 4044, -196"^7" $Pos " : " GetCurrentPlayerVar("NickName"));
        
openGlobalButton("PointBodyPoints" $Pos$point_L 40$point_T + ($Pos 4), 644, -132"^3" $Points);
    ENDIF
EndEvent
?>


Last edited by Krayy, .
Krayy
S2 licensed
Quote from sinanju :...
User var functions (fi_user_value):
SetUserStoredValue($track, $car, $username, "varname", $value) - Sets a variable ("varname") based on current track and car

where $track, $car and $username vars in the user functions are optional. If omitted, then it will retrieve values for the current user on current track in current car.

This would make it easier to collect data, but still going to be issues when trying to output when output relies on specific track and/or car.

You couldn't do that as vars are stored as a single value using a single name. One solution would be to do this:

<?php 
SetStoredValue
("varname_" $track "_" $car "_" $username$value);
?>

Then you could use the split function to break it up when doing a Get:

<?php 
$fields 
SplitToArray(GetStoredValue("varname_AS1_BL1_Krayy"));
$Track $fields[1];
$Car $fields[2];
etc
?>


Krayy
S2 licensed
1. argv is the rest of the command line that comes after the actual Lapper command. e.g. with the command "!top xfg", argv would equal "xfg", with "!msg I'm a coconut" argv would de "I'm a coconut" and would be used in the !msg command

2. Depends on how you've stored the data. Your problem will be looping through 200 (or however many racers you have) records to sort out the top 3. One way around this is to store a comma delimited list of results in a single database entry then use SplitToArray to split them into an array (god, I KILL me :spin and then process them from there. Psuedo code:
OnLapperStart
GetStoredValue("top5")
$TOP5 = SplitTOArray( GetStoredValue("top5") , "," );
privmsg("Top racer is " . $TOP5[0]);
...

I'll expand on this later on,

This goes back to the discussion that was going on about a common points system for Lapper which has sort of defaulted to Tim's system. It's a good start, although it's fairly basic at the moment. The codes a bit gnarly too, although a rewrite of some of it to use shorter loops and arrays for lookups etc could go a long way. Storing the data and reporting on it is another thing that would need looking at, and if we could come up with a good design document for the scoring system which goes into what functionality you would need, then I don't see any reason why the Top system couldn't be expanded to support race points, drift points etc.

So to throw the cat amongst the pigeons, what exactly do we need a points system to do?
Databases 101
Krayy
S2 licensed
I find it best to think about the database like a special type of variable storage rather than as a separate entity. Database functions can be global (not tied to a user) or user specific. Here are the functions:

Global var functions (fi_stored):
SetStoredValue("varname", $value) - sets a variable
GetStoredValue("varname") - returns variable as a string
GetStoredNum("varname") - returns variable as a numeric (or as -1 if it's not a number), so you don't need to do a ToNum($var) conversion if you're doing numeric comparisons

User var functions (fi_user_value):
SetUserStoredValue($username, "varname", $value) - Sets a variable
GetUserStoredValue($username, "varname") - returns variable as a string
GetUserStoredNum($username, "varname") - returns variable as a numeric
*Note -
The $username var in the user functions is optional. If it's omitted, then it will retrieve values for the current user.

So, now we know which are global and user, so where do we store data? Easy...if the data pertains to a user, store it using the user functions, if it's not, use the global ones, i.e. DefaultTopCar = global, MyBestLap = user

A lot of internal Lapper data have hard coded internal functions to mash data and then store it such as the fastest lap times that you see in !top. The way it retrieves that data is also hard coded. Doing it inside Lapper would be inefficient, adn this is where you need to be a bit creative.

If you want to compare values before storing the largest in the databse, you will need to do a Get, Compare, then Set. So I'd do this:


<?php 
IF ( $TopSpeed GetUserStoredNum("TopSpeed"))
THEN
SetUserStoredValue
("TopSpeed"$TopSpeed);
ENDIF
?>

If haven't tested that but it should work as the GetUserStoredNum returns a numeric so can be used in a numeric comparision without doing a ToNum conversion.
Krayy
S2 licensed
Quote from emit-nl :Nice work!
By the way, I do have an idea for a new admin module for the GUI.
I think it should be nice if there is a module were you can set handicaps for cars.
For example: with this module you can force all racers that drive a FZR to add 2KG weight to the car and 1KG when they are driving an FXR.
In this module the handicaps per car can be set and saved in the database (SetStoredValue).

I hope you can understand what I mean. What do you think?
I'm looking foward to see the new CIF!

Tim

Thats definitely doable....I can modify the existing handicap module to support that by using a button at the bottom to toggle between user and car/track handicaps. I'll let you know how I go
Krayy
S2 licensed
At first glance, there are syntax errors in your SetUserStoredValue statements (extra opening parentheses) and the GetStoredValue statements should be GetUserStoredValue:

<?php 
...
SetCurrentPlayerVar"lap_time_time",GetUserStoredValue"lap_time_time" ) );
SetCurrentPlayerVar"lap_time_number",GetUserStoredValue"lap_time_number" ) );
SetCurrentPlayerVar"drift_score",GetUserStoredValue"drift_score" ) );
SetCurrentPlayerVar"drift_skill",GetUserStoredValue"drift_skill" ) );
SetCurrentPlayerVar"average_speed_kmh",GetUserStoredValue"average_speed_kmh" ) );
SetCurrentPlayerVar"average_speed_mph",GetUserStoredValue"average_speed_mph" ) );
...
    
SetUserStoredValue"lap_time_time"$lap_time_time);
    
SetUserStoredValue"lap_time_number"$lap_time_number);
    
SetUserStoredValue"drift_score"$drift_score);
    
SetUserStoredValue"drift_skill"$drift_skill);
    
SetUserStoredValue"average_speed_kmh"$average_speed_kmh);
    
SetUserStoredValue(  "average_speed_mph"$average_speed_mph);
...
?>

Then you should see the values in the fi_user_value table, not fi_stored.
Krayy
S2 licensed
I was going to ask if someone could make a relevant acronym for CLIT, but alas it's not to be. CIF it is (sorry sinanju).

Here's a list of current working modules within the rewritten framework:

For users:
Handicaps (display only)
Who (with a click through to get server race stats)
Top (along with a UI to set DefaultTopCar for each user or globally if you're an admin)
Help files

For admins:
Handicaps (set user handicaps)
Membership Admin (used to control who is admin, guest, etc)
Race setup (sets laps, track, cars, laps etc)
Server Options (in beta, but can set who can log on, server restrictions like view, can reset,
Penalties (set server penalties for speeding, car reset etc)

If you have modded any of the original modules that you think make it better, send me a PM, or email them to me at krayy0@gmail.com

I'll look at finalising (well beta-ing) the revised framework in the next week or so, which will make adding new modules a heap easier too.
Krayy
S2 licensed
Hi guys,

I'm starting to find time to get back to work on the common look interface but need to seek some quick opinions. I'm redoing a bunch of the modules and the main interface, so I need to separate it from the original version, and to do that I reckon I need to rename the framework. Here are the options I want to go with. Cast your vote for which one you like best:

cif Common Interface Framework
clif Common Look Interface Framework
cmi Common Menu Interface
cui Common User Interface

Remember that the interface can be used to support User modules, Admin modules, Help or any other thing that needs multiple tabs, so I would like the name to be as generic as possible. My current favourite is the Common Interface Framework, as that to me is the most descriptive.

Throw in your .02 cents worth and I'll try to have a spanky new download in the next couple of weeks.
Krayy
S2 licensed
Quote from emit-nl :Hi,
I think it would be nice if the !top and !drf windows get a previous/next button.
Would this be easy to realise? I've checked the tops.lpr file, but I don't know where to start (and !near, !drfnear, eg)

Is it possible in the lpr file or only in the hard code of LFSLapper itself? (Cause there is the base of the top command, isn't it?)

Thanks in advance.

Regards,
Tim

Depends on how many results you are after. Most people only want to check what the absolute fastest top 10 times are so they know how much they have to push to get within that grouping. Trying to see the last top 100 times is a bit of overkill. Then again, lowering the font size on the text in the !top lpr file can get more results on the screen.

PS: I'm wokring on integrating the !top command into the GUI system too so will have a look at it then.
Krayy
S2 licensed
Quote from emit-nl :
I also changed some things in the 'gui_admin_membership.lpr' and the 'gui_admin_handicaps.lpr' file. Now users that aren't admin can see this windows too, but only admins can change settings. I attached the files to this post.
...
Also, what do you think: Should it be cool if the WHO.lpr script is being implemented in your GUI? Otherwise you have diffirent windows instead of one clear page.

I've been a bit busy at work (promotion, yay!) to do any updates, but this functionality is being addressed in the upcoming gui_user modules. I have ported the who, handicaps and some other stuff the the gui, but have as yet to publish it here. The reason for supplying them as seperate modules, even though the functionality is similar, is to allow for finer detail in what to allow access to from a server admins perspective.

Also helps with ordering them in the admin or user gui lists
FGED GREDG RDFGDR GSFDG