The online racing simulator
Searching in All forums
(12 results)
mgunig
S2 licensed
Hi There,

Thank you very much for your help,its working.

Your code was getting distance between me and me not other player so l added "$players != $userName;" and now its working perfect.

Thank you again Smile
[Solved] Get NickName of Player close to me
mgunig
S2 licensed
Hi There,

Can you guys help me with by code below.

I'm trying to get NickName/username of player close to me,I dont know what I am doing wrong.
When l do this :


CatchEvent OnLapperStart()
OnLapperStart_Ctrack();
EndCatchEvent


CatchEvent OnMSO( $userName, $text ) # Player event

$idxOfFirtsSpace = indexOf( $text, " ");
IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!t":
$players = GetListOfPlayers("U");

FOREACH($play IN $players)
$distance = trackuserdistance($play,$userName);

IF ($distance <=5)
THEN
globalMsg("^6Twin ".GetCurrentPlayerVar("NickName")."^6 and ".GetPlayerVar($play,"NickName"));
ELSE
privMsg("No nearby Cars");
ENDIF
ENDFOREACH

BREAK;
ENDSWITCH
EndCatchEvent

I get Current user/player nickname but not the other player and even if the distance between the players is not less than 5 the code in globalMsg still execute.

Thank you.
mgunig
S2 licensed
I will try that, I want to create twin drift meter first then l will work on scores ,right now l want it to diplay my score just to see if it is working.

Thank you Bro for your help XD,will ask if l have any problems.
mgunig
S2 licensed
Hi Sinanju

Don't worry about
If (9 > 7)
If (7 > 6)
I only used that for testing, it does mean anything.

Will restart the script again and see how it goes,l only have 1 question ,is it possible to put CatchEvent onDriftScore under Sub and EndSub?

Thank you.
mgunig
S2 licensed
Yes,the script works but the only problem is it does not catch the drift scores.

See attached photo
mgunig
S2 licensed
CatchEvent/EndCatchEvent doesnt seem to work if I put it at the begining of the script
mgunig
S2 licensed
Dont mind my "IF" will work on that later
Here is my code:

CatchEvent OnMSO( $userName, $text ) # Player event
$idxOfFirstSpace = indexOf( $text, " ");
IF( $idxOfFirstSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirstSpace );
$argv = trim( subStr( $text,$idxOfFirstSpace ) );
ENDIF

SWITCH( $command )
CASE "!twin":
IF (9 > 7 )
THEN

$me = GetCurrentPlayerVar("NickName");
$behind = GetPlayerVar( GetCurrentPlayerVar( "UNameBehind" ),"NickName" );
$front = GetPlayerVar( GetCurrentPlayerVar( "UNameBefore" ),"NickName" );

globalMsg( langEngine( "%{main_twin}%" , $me,$behind));

IF (9 >7)

THEN

$AngleVelocity = GetCurrentPlayerVar( "AngleVelocity" );
$DriftScore = (GetCurrentPlayerVar( "DriftScore" ) * 2);
$LastDriftScore = (GetCurrentPlayerVar( "LastDriftScore" ) *2);

openPrivButton( "circledrift_back",97,57,165,165,1,-1,0,"^1•"); # red background
openPrivButton( "circledrift_back1",100,60,159,159,1,-1,0,"^3•"); # yellow foreground
openPrivButton( "circledrift_thisdrift",169,126,20,5,1,-1,0,"^1This Drift"); # red
openPrivButton( "circledrift_lastdriftscore",169,128,20,12,1,-1,0,langEngine( "%{circledrift_score}%" , $LastDriftScore ) );
openPrivButton( "circledrift_lapscore",169,148,20,15,1,-1,0,langEngine( "%{circledrift_combo}%" , $DriftScore ) );
openPrivButton( "circledrift_maxscore",169,159,20,5,1,-1,0,"^0Lap Score"); # black

ELSE
privMsg( langEngine( "%{main_nonearcars}%" ) );

ENDIF


IF( $AngleVelocity < 0 )

THEN
$AngleVelocity = -$AngleVelocity ;

SetCurrentPlayerVar("Angle_Reverse",$AngleVelocity);

closePrivButton( "circledrift_anglerev&circledrift_angle");
openPrivButton( "circledrift_anglerev",169,136,20,17,1,-1,0,langEngine( "%{circledrift_anglerev}%" , GetCurrentPlayerVar( "Angle_Reverse")));

ELSE

closePrivButton( "circledrift_anglerev&circledrift_angle");
openPrivButton( "circledrift_angle",169,136,20,17,1,-1,0,langEngine( "%{circledrift_angle}%" , $AngleVelocity ));

ENDIF


IF (7 > 6)

THEN

openPrivButton( "circledrift_lastdriftscore",169,128,20,12,1,-1,0, "^10" );
openPrivButton( "circledrift_lapscore",169,148,20,15,1,-1,0,"^10" );

ELSE

privMsg( langEngine( "%{main_nonearcars}%" ) );

ENDIF

IF (GetCurrentPlayerVar( SessLaps ) <1)
THEN
openPrivButton( "circledrift_angle",164,137,30,14,1,-1,0,"^1> Scores not saved <%at% " );
openPrivButton( "circledrift_anglerev",164,137,30,14,1,-1,0," %at%^1> on your outlap <" );
ELSE
openPrivButton( "circledrift_angle",164,137,30,14,1,-1,0,"^1> Too slow <%at% " );
openPrivButton( "circledrift_anglerev",164,137,30,14,1,-1,0," %at%^1> lost scores <" );
ENDIF


ELSE
privMsg( langEngine( "%{main_nonearcars}%" ) );

ENDIF


ELSE
privMsg( langEngine( "%{main_nonearcars}%" ) );
ENDIF
BREAK;
ENDSWITCH
EndCatchEvent
[Solved] Drift meter doesnt show scores
mgunig
S2 licensed
Got another problem , My drift meter does not show drift scores and l think the problem is i did not use "CatchEvent OnDriftScore( $userName )" and if l do lfs lapper crush.How can use "CatchEvent " in a sub or command section? and if there is another way to show drift scores can u please tell me.

Thank You.

EDIT: Moderator note: Create a new topic for each new question.
Last edited by Bass-Driver, .
mgunig
S2 licensed
Quote from sinanju :I'm not sure, but I don't think these UNameBefore/UNameBehind will work in a sub like that, as i'm sure they need a split/sector/lap Event to trigger, such as Event OnSpbSplit1( $userName ).

Maybe you could try with the distance done Event (Event OnDistDone)? If it does work, don't make it every single meter, but try every 10, 25, or 50?

Alternatively, maybe using Nodes, Zones or InSim circles in AutoX mode as the triggers?

I will try that aswell,Thank you
mgunig
S2 licensed
Hi

It does not seem to work here is my code and screen shot:

Sub myTwin($argv $msg)
$me = GetCurrentPlayerVar("NickName");
$behind = GetPlayerVar( GetCurrentPlayerVar( "UNameBehind");
$front = GetPlayerVar( GetCurrentPlayerVar( "UNameBefore" );

globalMsg( langEngine( "%{main_twin}%" , $me,$behind));
EndSub
mgunig
S2 licensed
Thank you,I will have a look at it. Smile
[Solved] Get nickname infront / behind me
mgunig
S2 licensed
Hi

Im trying to get nickname for player infront or behind me.
i tried using this code :
$other = getplayerinfo($UNameBehind("Nickname"));
and also tried :
$me = getplayerinfo($PlayerA);
$other = getplayerinfo($PlayerB);

but it does work.Can u guys help me
Last edited by Bass-Driver, .
FGED GREDG RDFGDR GSFDG