The online racing simulator
#1 - SEV7N
[Solved] Help With registerzone
Hi, I have started a new .lpr file to go into the addonsused.lpr.

I am having trouble getting it started.

I can do it fine if I edit the "registerzone" in the main .lpr file, but I don't always want this add-on turned on, hence needing a fresh .lpr file.

I tried my best to do it but it's fair tricky to understand the first part of a script.

I have this sofar.



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

    SWITCH ( 
$command)
             CASE 
"!clips"
    
LoadClips(0,0);      
              BREAK;
    ENDSWITCH 
EndCatchEvent


Sub LoadClips
$KeyFlags,$id )
    
RegisterZoneAction"AU1" 41,-823LoadClips );
EndSub
?>


Thanks.Thumbs up
If you look at the main lapper.lpr file, you'll see that all RegisterZoneAction and RegisterNodeAction lines are included in the Event OnLapperStart() event.

If you want to make your own Register Actions within a separate .lpr file, then you need to put these in the same sort of event, but you have to 'Catch' it first, e.g.


<?php 
CatchEvent OnLapperStart
()
    
RegisterZoneAction"AU1" 41,-823SR_LoadClips );
EndCatchEvent
?>


From there, once a driver enters the specified zone, then the sub-routine SR_LoadClips is triggered. E.g.


<?php 
Sub SR_LoadClips
#  something happens, like button being drawn
EndSub
?>


You were telling your sub to look at your sub - so would have got stuck in an indefinite loop without anything happening, except possibly lapper crashing.

Quote from SEV7N :...I don't always want this add-on turned on....

If you tell lapper that there's a zone or node that triggers an event, then even if you have it in a separate enabled .lpr file, it will still be triggered.

I'm not sure if lapper really cares, but just in case, if used, put the OnLapperStart event in front of any other events, followed by the other events you use.
#3 - SEV7N
Quote from sinanju :


<?php 
Sub SR_LoadClips
#  something happens, like button being drawn
EndSub
?>


You were telling your sub to look at your sub - so would have got stuck in an indefinite loop without anything happening, except possibly lapper crashing.

Oh I see the error now, I tried OnLapperStart and Event as my beggining line, and it logged everyone on the server in as Admin, heheh.

registerzone,"AU1"1,1,1,1,1 "hi","SR_SayHi"

Sub SR_SaHi()
privmsg"hi there";

(I know the syntax probably wrong, just showing I have a fair idea of Sub's now. Thanks1000000

I am going to try these registerzone things again, Thanks for your help!
#4 - SEV7N
Hey again, after I tried what you said but it didn't bring up the test button.

I have it as an DAclips.lpr and included it in addonsused.

If I remove the daclips ad-don everything is fine.

Here is the code.

(I started a new .lpr file as I am planning to put the # in when I don't want to use the ad-don).

Sorry to be annoying heheh.




<?php 
CatchEvent OnLapperStart
()
    
RegisterZoneAction"AU1" , -32,-615SR_LoadClips );
EndCatchEvent

Sub SR_LoadClips
openPrivButton
"stop_light",53,38,60,15,6,-1,0,"^2test");
EndSub 
?>


EDIT: You forgot the () after Sub SR_LoadClips so it made everyone get (main_ not found) errors
Did you try something like the following?


<?php 
Sub SR_LoadClips
($userName)
    
openPrivButton"stop_light",53,38,60,15,6,-1,0,"^2test");
EndSub
?>


#6 - SEV7N
Quote from sinanju :Did you try something like the following?


<?php 
Sub SR_LoadClips
($userName)
    
openPrivButton"stop_light",53,38,60,15,6,-1,0,"^2test");
EndSub
?>



This is my script, I cant see the problem


<?php 
CatchEvent OnLapperStart
()
    
RegisterZoneAction"AU1" 23,-614SR_LoadClips );
EndCatchEvent 

Sub SR_LoadClips
($userName)
    
openPrivButton"stop_light",53,38,60,15,6,-1,0,"^2test");
EndSub 
?>


Cheers.
If using newer version of lapper, you may have to do following;

RegisterZoneAction( "AU1" , 23,-614, 2 , SR_LoadClips,"" );
-
(SEV7N) DELETED by SEV7N
#8 - SEV7N
Quote from sinanju :If using newer version of lapper, you may have to do following;

RegisterZoneAction( "AU1" , 23,-614, 2 , SR_LoadClips,"" );

Thanks buddy that done the trick, thanks 1000000!
-
(SEV7N) DELETED by SEV7N
#9 - SEV7N
I have one more question, I have made zone-events on ClipPoints, so when someone hits a clip-point, it counts the score like on the driftmeter.

I have it to open a window above the driftmeter, but unsure how to make it count. **Its only part of the script**
I have coded zones to all of my clips, but I don't know how to tell lapper to add points on each zone, (If the zone is driven in).


<?php 
CatchEvent OnLapperStart
()
   
RegisterZoneAction"AU1" , -91,-975SR_AwardPoints1,"" );
EndCatchEvent 


$PointsAwardedOnClipHit 
200# Point's to be awarded on cliphit


Sub SR_AwardPoints1($userName)
    
openPrivButton"award_points",5,125,20,12,6,-1,32,"",GetPlayerVar(PointsAwardedOnClipHit));
    
openPrivButton"award_points2",5,125,20,5,6,-1,0,"ClipBonus");
EndSub 
?>


Cheers Heaps!
Have a look at Tim[NL]'s Race Points system (HERE).

Basically you'll need a system for giving and adding points together to give you a total.

It will mean learning a bit about SET/GET variables.
Quote from sinanju :Have a look at Tim[NL]'s Race Points system (HERE).

Basically you'll need a system for giving and adding points together to give you a total.

It will mean learning a bit about SET/GET variables.

Cool thanks Sinanju, Im going to learn it now I have an idea of var's, (I know how to use getplayervar nickname function in a button or something, so couldn't be too hard.

Cheers for ya help, I uploaded here what you helped me achieve

It's a 99.9% completed addon for Autocross
Attached files
AU comp addon.zip - 8.5 KB - 201 views
This thread is closed

FGED GREDG RDFGDR GSFDG