The online racing simulator
Finding out which side you're standing on
Hello,
In the GPS system I will make and in the police system I have made, I want to find out where the chased person / the location I want to go is located by the driver.
If you don't understand, the following image may help you understand.

Thanks in advance
Attached images
Ekran Görüntüsü (1078).png
-
(Bass-Driver) DELETED by Bass-Driver : Wrong code.
Quote from Bass-Driver :Maybe this can be helpfull.


<?php 
RegisterPlayerDetection
(); #Detect player within a fieldofview and distance. 

            #Example
            #$userName = Set Player for the detector
            
$userName "Bass-Driver"#The Detector is now enabled for Bass-Driver

            #$FieldOfView = Set range of the view to detect players. (degrees)
            
$FieldOfView 30#view will be 0 to 30 and 0 to -30

            #$Distance = Max distance of detection (Meters)
            
$Distance 25;

            
#$NameofSubDetected = Execute Subcallback when 1 or more players are detected.
            
$NameofSubDetected "PlayerDetected";

            
RegisterPlayerDetection($userName,$FieldOfView,$Distance,$NameofSubDetected);

            
#==========================================
            #Sub callback
            #==========================================

            #If there are multiple players in the field of view, $detectedPlayer outputs  Player1+Player2+......
            #This means you have to split the string into seperated players.
            
Sub PlayerDetected($userName,$DetectedPlayer)
                
OpenButton$userName"PlayerName",170,115,30,5,2,5,96"^3Player: ^7".GetPlayerVar($DetectedPlayer,"NickName"));
                
OpenButton$userName"Speed",170,120,30,5,2,5,96"^3Speed: ^7".GetPlayerVar($DetectedPlayer,"InstantSpeed")." km/h");
                
OpenButton$userName"Distance",170,125,30,5,2,5,96"^3Heading: ^7".GetPlayerVar($DetectedPlayer,"Heading"));
            
EndSub
?>



First of all, thank you,
I'm already using it in the police system, but I don't see how it can help me find directions
ignore my first post.

I've implemented 2 functions to get the distance and angle between players/objects.

Get the username of the police and the suspect.
Or get the coordinates of the police and the suspect.

$GetDistanceInMeters = trackuserdistance($userNameOfPolice, $userNameOfSuspect);
$GetAngleInDegrees = GetAngle($userNameOfPolice,$userNameOfSuspect);

IF((ToNum($GetAngleInDegrees) > 80)&&(ToNum($GetAngleInDegrees) < 120))THEN
privmsg(>>>);
ENDIF


It will really help me a lot, thank you Thumbs up
Also, I opened a topic about the Character error, is there still no solution?
Quote from arda556 :It will really help me a lot, thank you Thumbs up
Also, I opened a topic about the Character error, is there still no solution?

haven't looked into it.
Quote from arda556 :I wonder if it's me or the lapper.

Its has something todo with encoding the characters.
So its a bug in LFSLapper.
Well, thanks for everything.
I can get the distance on my GPS system but it won't update

Sub gpsotel( $userName,$id ) # Lapper Event
openPrivButton( "gpsmesafe",180,27,20,6,4,-1,1,"^7GPS: ^8" . round( ToNum( DistFromUser($userName,$gpsotel) / 100 ),1 ) . " ^7Metre" );
HostDelayedCommand( 1, gpsotel);
EndSub
Just a few simple tasks to start debugging the code.

-Check the errorlog
-Create a "debug" message within the gpsotel() sub, to check if the sub is updating.

i prefer PlayerDelayedcommand(); for player specific delayedcommands


<?php 
PlayerDelayedcommand
(); #Start delayedcommand for a specific player

            
$UserName "Bass-Driver";
            
$NameOfDelay "CloseButton";
            
$DelayInSeconds 3;
            
$SubCallBack "ThisSub";

            
PlayerDelayedcommand($UserName,$NameOfDelay,$DelayInSeconds,$SubCallBack);

Sub CloseButton($userName)
privmsg($userName,"debug: this sub works");
EndSub
?>


Thank you,
My code works as follows, but when I change it to work when I click on a button, it does not work

<?php 
CASE "!gps":
deneme55$userName );
BREAK;
Sub deneme55$userName # Lapper Event
openPrivButton"gpsmesafe",180,27,20,6,4,-1,1,"^7GPS: ^8" roundToNumDistFromUser($userName,$gpsotel) / 100 ),) . " ^7Metre" );
privdelayedcommand1deneme55);
EndSub
?>


-Did you check the errorlogs?
-DistFromUser() Does this function exist?
7/9/2023 2:21:15 PM -> Syntax error: Incorrect number of arguments at line #40 in function 'deneme55' script aborted

<?php 
CASE "!gps":
gps$userName,$id );
BREAK;
ENDSWITCH
EndCatchEvent
Sub gps
$userName,$id # Lapper Event
openPrivButton"btn",55,27,90,6,6,-1,33,"- GPS SYSTEM -",iclose55 );
openPrivButton"btn2",55,34,30,12,4,-1,32,"^7Otel",deneme55 );
EndSub

Sub deneme55
$userName,$id # Lapper Event
closeprivbutton("btn&btn2");
openGlobalButton("safetycar_light_2",167,38,4,4,4,30,ISB_BLINK,"^1•" );
openPrivButton"gpsmesafe",180,27,20,6,4,-1,1,"^7GPS: ^8" roundToNumDistFromUser($userName,gpsotel) / 100 ),) . " ^7Metre" );
privdelayedcommand1deneme55);
EndSub
?>


now you know theres an error on line 40.
Goto line 40 in your script. To see which line gives the error.

Also check if all variables get an value. (also a part of debugging your code)

privmsg($userName); for example
I think the error I'm getting is that there is nothing like $username,$id in the sub
For example Sub deneme55( $userName,$KeyFlags ) as it should be but I don't know exactly what they are based on, I just know that when you go to a location for example you should use $username,$id
I hope I made myself clear
** Best answer **
Here is an example to start a loop for a specific player.
Did not test it, but its worth a try.


<?php 
CASE "!gps":
  
GPSMenu($userName,0);
BREAK;

Sub GPSMenu$userName,$id )
    
#Clickable Buttons
EndSub

Sub ClickedButton
$keyflags,$id # Lapper Event
    
$userName GetCurrentPlayerVar("UserName");
    
#Close unnecessary buttons here.
    
GPSLoop$userName);
EndSub


Sub GPSLoop
$userName# Lapper Event
    #Display Buttons
    #Delayedcommand for player 
    
PlayerDelayedCommand($userName,"GPSLoop_".$userName,1,GPSLoop);
EndSub

?>


To stop the loop.

<?php 
RemovePlayerDelayedCommand
($userName,"GPSLoop_".$userName);
?>

Thank you it works Smile

FGED GREDG RDFGDR GSFDG