# Follow system V1.00 21-03-13 First coding # ######################################################################### CatchEvent OnSpbSplit1( $userName ) OnSpbSplit1_Follow(); 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 "!follow": follow ( 0,0 ); BREAK; ENDSWITCH EndCatchEvent Sub follow( $KeyFlags,$id ) ### Set initial values for left/right and top/bottom coordinates ### $left_right_follow = 29; $top_bottom_follow = 50; ### End ### $mList = GetListOfPlayers("N"); $mCount = arrayCount( $mList ); $plyNum=0; openPrivButton( "follow_screen_bg",$left_right_follow,$top_bottom_follow,142,105,5,-1,16,""); WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; openPrivButton ("player_".$plyNum."_number",$left_right_follow+1,$top_bottom_follow+1,5,5,5,-1,32,$plyNum+1); openPrivButton ("player_".$plyNum."_nickname",$left_right_follow+7,$top_bottom_follow+1,25,5,5,-1,32,GetPlayerVar($uName,"NickName") ); IF ( GetCurrentPlayerVar( "following_player" ) == GetPlayerVar( $uName,"NickName" ) ) THEN openPrivButton ("p_follow_".$plyNum,$left_right_follow+33,$top_bottom_follow+1,35,5,5,-1,32,"^2Following player",stop_follow_player); ELSE openPrivButton ("p_follow_".$plyNum,$left_right_follow+33,$top_bottom_follow+1,35,5,5,-1,32,"^3Follow player",follow_player); ENDIF ### Raise $top_bottom_connected with 5 before drawing next button $top_bottom_follow=$top_bottom_follow+5; ### End ### $plyNum=$plyNum+1; ### When player 16 is reached, change value of $left_right_follow to start next colum. Set $top_bottom_follow to initial value ### IF ($plyNum == 16) THEN $left_right_follow = 100; $top_bottom_follow = 50; ENDIF ### End ### ENDWHILE #openPrivButton( "refresh_follow",69,144,20,5,10,10,32,"^3Refresh (%cpt%)",follow ); openPrivButton( "close_follow",90,144,20,5,10,-1,32,"^3Close",close_follow ); EndSub Sub follow_player ( $KeyFlags, $id ) $id = Substr($id,9); $mList = GetListOfPlayers("N"); $uName = $mList[$id+0]; SetCurrentPlayerVar( "following_player", GetPlayerVar ( $uName,"NickName") ); PrivMsg ("^7You are now following: " . GetPlayerVar ( $uName,"NickName") ); follow( 0,0 ); EndSub Sub stop_follow_player ( $KeyFlags, $id ) $id = Substr($id,9); $mList = GetListOfPlayers("N"); $uName = $mList[$id+0]; SetCurrentPlayerVar( "following_player", "" ); PrivMsg ("^7You are no longer following: " . GetPlayerVar ( $uName,"NickName") ); closeButton( GetCurrentPlayerVar("UserName"), "follow_speed_1&follow_speed_2&follow_sector_1&follow_sector_2&follow_node_1&follow_node_2&follow_before_1&follow_before_2&follow_behind_1&follow_behind_2" ); follow( 0,0 ); EndSub Sub close_follow ( $KeyFlags,$id ) closePrivButton ("follow_screen_bg&close_follow"); FOR ($i=0;$i<=32;$i=$i+1) closePrivButton ("player_".$i."_number&player_".$i."_nickname&player_".$i."_status"); closePrivButton ("p_follow_".$i); ENDFOR #PrivMsg ( "^7DEBUG 1: ". GetCurrentPlayerVar( "following_player" ) ); IF ( GetCurrentPlayerVar( "following_player" ) != "") THEN test_follow(0,0); ENDIF EndSub Sub test_follow( $KeyFlags, $id ) $mList = GetListOfPlayers("N"); $mCount = arrayCount( $mList ); $plyNum=0; #PrivMsg ( "^7DEBUG 2A: ^2HERE " ); #PrivMsg ( "^7DEBUG 2B: ^2" . GetCurrentPlayerVar("UserName") ); WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; IF ( GetPlayerVar( GetCurrentPlayerVar("UserName"), "following_player" ) == GetPlayerVar( $uName, "NickName") ) THEN #PrivMsg ( "^7DEBUG 3: ^1HERE " ); openButton( GetCurrentPlayerVar("UserName"), "follow_speed_1",1,124,10,5,5,-1,80,"^3Speed: " ); openButton( GetCurrentPlayerVar("UserName"), "follow_speed_2",11,124,22,5,5,2,80,"^7" . GetPlayerVar( $uName, "InstantSpeed") . " " . GetPlayerVar( $uName, "UnitSpeed"),test_follow ); openButton( GetCurrentPlayerVar("UserName"), "follow_sector_1",1,129,10,5,5,-1,80,"^3Sector: " ); openButton( GetCurrentPlayerVar("UserName"), "follow_sector_2",11,129,22,5,5,-1,80,"^7" . GetPlayerVar( $uName, "Sector") ); openButton( GetCurrentPlayerVar("UserName"), "follow_node_1",1,134,10,5,5,-1,80,"^3Node: " ); openButton( GetCurrentPlayerVar("UserName"), "follow_node_2",11,134,22,5,5,-1,80,"^7" . GetPlayerVar( $uName, "CurrNode") ); openButton( GetCurrentPlayerVar("UserName"), "follow_before_1",1,139,10,5,5,-1,80,"^3Before: " ); openButton( GetCurrentPlayerVar("UserName"), "follow_before_2",11,139,22,5,5,-1,80,"^7" . GetPlayerVar( $uName, "GapBefore") ); openButton( GetCurrentPlayerVar("UserName"), "follow_behind_1",1,144,10,5,5,-1,80,"^3Behind: " ); openButton( GetCurrentPlayerVar("UserName"), "follow_behind_2",11,144,22,5,5,-1,80,"^7" . GetPlayerVar( $uName, "GapBehind") ); break; ENDIF $plyNum=$plyNum+1; ENDWHILE EndSub Sub OnSpbSplit1_Follow() # Player event $mList = GetListOfPlayers("N"); $mCount = arrayCount( $mList ); $plyNum=0; WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; IF ( GetPlayerVar( $uName, "following_player" ) == GetCurrentPlayerVar("NickName") ) THEN privMsg( $uName,"^2DEBUG - Split 1 crossed by: " . GetCurrentPlayerVar("NickName") ); ENDIF $plyNum=$plyNum+1; ENDWHILE EndSub