CatchEvent OnLapperStart()
# Some functions ... #
RegisterScheduleAction( "* * * * * * *", Second_Timer ); # Execute every second.
EndCatchEvent
Sub Second_Timer() # Timer #
writeline( "RSB_Time timer " . GetLapperVar( "longtime" ) );
$mList = GetListOfPlayers();
$mListCount = arrayCount( $mList ); # Reports as 0 entries.
writeline( "RSB_Time $mList: " . $mListCount . " entries: " . $mList[0] . ", " . $mList[1] . "." );
FOREACH ( $maVar IN $mList )
writeline( "RSB_Time FOREACH" );
IF ( GetPlayerVar( $maVar["value"] , "UserName" ) != "" ) # Not Host #
THEN
# DO SOMETHING #
writeline( "RSB_Time Username exists" );
IF ( GetPlayerVar( $maVar["value"] , "Delivery" ) != "" )
THEN
$distance = ToNum( trackuserdistance( GetPlayerVar( $maVar["value"] , "Delivery" ) , $maVar["value"] ));
IF ( $distance < 5 )
THEN
SetPlayerVar( $maVar["value"] , "DeliveryTick" , ToNum( GetPlayerVar( $maVar["value"] , "DeliveryTick" ) + 1 ) );
$TickCount = ToNum(GetPlayerVar( $maVar["value"] , "DeliveryTick" ));
IF ( $TickCount >= 3 )
THEN
SetPlayerVar( $maVar["value"] , "DeliveryStatus" , "1" );
$DeliverToUserID = GetPlayerVar( GetPlayerVar( $maVar["value"] , "Delivery" ) , "UserID" ); #Get Receiving Player UCID.
FOREACH ( $CompanyArray IN $Companies )
$OrderVar = ToString( "UserName_Order_" . $CompanyArray["value"] . "_" . $DeliverToUserID );
$OrderCompany = ToString( $CompanyArray["value"] );
IF ( GetStoredValue( $OrderVar ) != "" )
THEN
$DeliverToNickName = GetPlayerVar( GetStoredValue( "UserName_Number_" . $DeliverToUserID ) , "NickName" );
PrivMsg( $maVar["value"] , "^7You have ^2successfully delivered ^7to " . $DeliverToNickName );
Delivery_Order_Delivered( $OrderCompany , $DeliverToUserID );
ENDIF
ENDFOREACH
ENDIF
ENDIF
ENDIF
ENDIF
ENDFOREACH
EndSub
## This part of the code is within a FOR loop, algorithm works, SetUserStoredValue doesn't.
## $IDUser = GetStoredValue( "UserName_Number_" . $i ) ## from FOR loop ##
writeline( "attempting to give user " . $IDUser . " cash from " . GetUserStoredValue( $IDUser, "Cash" ) );
SetUserStoredValue( $IDUser , "Cash", Round(ToNum( GetUserStoredValue( $IDUser, "Cash" ) + $Dividend ),2) );
writeline( "attempted to give user " . $IDUser . " cash to " . GetUserStoredValue( $IDUser, "Cash" ) );
[b]CatchEvent OnConnect ( $userName )[/b]
....does some stuff....
IF ( GetStoredValue( "REGISTER_COUNTER" ) == "" )
... # see my previous post for whole section of relevant code # ....
ENDFOR
... some other stuff ...
EndCatchEvent
IF ( GetStoredValue( "UserName_Number_" . $i ) != "" )
THEN
IF ( GetPlayerVar( GetStoredValue( "UserName_Number_" . $i ), "NickName" ) == "" ) # Offline
THEN
# distribute dividend by set/getuserstoredvalue. #
ELSE
IF ( GetPlayerVar( GetStoredValue( "UserName_Number_" . $i ), "NickName" ) != "" ) # Online
THEN # distribute dividend normally by set/getplayervar. #
ENDIF
ENDIF
ENDIF
IF ( GetStoredValue( "REGISTER_COUNTER" ) == "" )
THEN
SetStoredValue( "REGISTER_COUNTER" , ToNum("2") );
ENDIF
$register_counter = ToNum( GetStoredValue( "REGISTER_COUNTER" ) );
IF ($register_counter == "")
THEN
$register_counter=2;
ENDIF
FOR ( $i = 1; $i < $register_counter; $i = $i + 1 ) ### Set $i as 1 unit under $register_counter. ###
IF ( ToString(GetStoredValue( "UserName_Number_" . $i )) == ToString(GetPlayerVar( $userName , "UserName" )) )
THEN
GlobalMsg( "User already registered on system" );
GlobalMsg( "^7User ID: ^6" . $i );
writeline( "User already registered on system" );
$i = $i + $register_counter;
ELSE
IF (( GetStoredValue( "UserName_Number_" . $i ) != "" ) && ( GetStoredValue( "UserName_Number_" . $i ) != "0" ))
THEN
GlobalMsg( "^7Stored User/ID " . GetStoredValue( "UserName_Number_" . $i ) . "/" . $i . "." );
ELSE
IF ( ( GetStoredValue( "UserName_Number_" . $i ) == "" ) || ( GetStoredValue( "UserName_Number_" . $i ) == "0" ) )
THEN
SetStoredValue( "UserName_Number_" . ToString( $register_counter ) , $userName );
SetStoredValue( "REGISTER_COUNTER" , ToNum( GetStoredValue( "REGISTER_COUNTER" ) + 1 ) );
GlobalMsg( "^7New User (^6" . $userName . "^7) has been registered." );
GlobalMsg( "^7New User ID: ^6" . ToNum( $register_counter ) );
writeline( "^7New User (^6" . $userName . "^7) has been registered." );
ENDIF
ENDIF
ENDIF
ENDFOR
Sub < this sub >
$mList = [b]< Get List of All Players' "UserNames" from storedvalue.dbs >[/b] ;
FOREACH ( $maVar IN $mList )
IF ( <they are online, their nickname != "" > )
THEN
# Distribute moneys #
SetPlayerVar( $maVar["value"] , "<var>" , <change> );
ELSE
# Rest aren't online, so distribute moneys to remaining (offline) players too #
SetUserStoredValue( $maVar["value"] , "<var>" , <change> );
ENDIF
ENDFOREACH
EndSub
openPrivTextButton( "BAN_" . $Prefix ,$ModBtnX+80,$ModBtnY + 2 + ( $PanelRowHeight * ( $plyNum+1 ) ),20,$PanelRowHeight,5,16,"^3No. of Days?","",3, BanPanel_Ban );
IF ( $Mode == "Cruise" )EndSub
THEN
GlobalMsg( "Player is Exiting Pits" );ENDIF
IF ( GetPlayerVar( $userName, $Direction ) != "0" )
THENENDIF
GlobalMsg( "Attempting to Spectate Player for Wrong Way" );
cmdLFS( "/pitlane " . GetPlayerVar( $userName , "UserName") );
HERE I JUST ADD MESSAGES AND FINES