How To: Zoom Controls

aussj4link

New Member
Reaction score
3
You know how in Battle Tanks you can adjust the camera with a simple -zoom X command? I was wondering how that is done, I always liked that about that map and wanted to see if it would go well with my map. Thanks!
 

Never_Quit

New Member
Reaction score
16
its a trigger

event
each player types message -zoom as substring
conditions
is "-zoom " from chat message substring 1,6?
actions
set camera distance for triggering integer conversion player substring 7,10

this is not defensive and will only allow up to 9999 zoom
the player will have to retype it when they scroll or use insert or delete
 

jig7c

Stop reading me...-statement
Reaction score
123
Trigger:
  • Camera
    • Events
      • Player - Player 1 (Red) types a chat message containing -zoom as A substring
      • Player - Player 2 (Blue) types a chat message containing -zoom as A substring
      • Player - Player 3 (Teal) types a chat message containing -zoom as A substring
      • Player - Player 4 (Purple) types a chat message containing -zoom as A substring
      • Player - Player 5 (Yellow) types a chat message containing -zoom as A substring
      • Player - Player 6 (Orange) types a chat message containing -zoom as A substring
      • Player - Player 7 (Green) types a chat message containing -zoom as A substring
      • Player - Player 8 (Pink) types a chat message containing -zoom as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -zoom
    • Actions
      • Camera - Set (Triggering player)'s camera Distance to target to (Real((Substring((Entered chat string), 7, (Length of (Entered chat string)))))) over 2.00 seconds
      • Game - Display to (Player group((Triggering player))) the text: (Camera Distance Set To: + (Substring((Entered chat string), 7, (Length of (Entered chat string)))))
 

aussj4link

New Member
Reaction score
3
Did I do something wrong here?

Trigger:
  • Zoom
    • Events
      • Player - Player 1 (Red) types a chat message containing -zoom as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -zoom
    • Actions
      • Camera - Set (Triggering player)'s camera Distance to target to (Real((Substring((Entered chat string), 7, (Length of (Entered chat string)))))) over 2.00 seconds


I basically just tried to copy it word for word but it doesn't seem to be working. When I type -zoom without a number it zooms all the way in, if I use a number though nothing happens. Like I said I tried to do it word for word because I don't quite understand what some of it means like the 1, 6 and 7 and stuff.
 

aussj4link

New Member
Reaction score
3
Ok I added this to see if it would at least show the number I type but it shows nothing I'm guessing that means the problem is in the substring?

Trigger:
  • Game - Display to (Player group((Triggering player))) for 15.00 seconds the text: (Camera Distance Set To: + (Substring((Entered chat string), 7, (Length of (Entered chat string)))))


HAHA! Delete the condition and it works! I have no idea why but it does wewt!
 

Never_Quit

New Member
Reaction score
16
you probably need "-zoom " (notice the space in the condition) Your current trigger will run whenever anyone types anything and there are integers past character 7.
 

tooltiperror

Super Moderator
Reaction score
231
Of course you might as well set a string in a custom script, since using substrings in GUI wastes a function call.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
JASS:
scope Height initializer HeightInit
    
    private function HeightStart takes nothing returns nothing
        local string s = GetEventPlayerChatString()
        
        set CameraHeight[GetPlayerId(GetTriggerPlayer())] = R2I(S2R(SubString(s, 6, StringLength(s))))
        call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "Changing camera height to: " + I2S(CameraHeight[GetPlayerId(GetTriggerPlayer())]))
    endfunction
    
    private function HeightInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        loop
        exitwhen i == 13
            set CameraHeight<i> == 700
            call TriggerRegisterPlayerChatEvent(t, Player(i), &quot;-zoom &quot;, false)
        set i = i + 1
        endloop
        call TriggerAddAction(t, function HeightStart)
    endfunction

endscope
</i>


JASS:
scope CH initializer CHinit

    globals
        integer array CameraHeight[13]
    endglobals
    
    private function CHstart takes nothing returns nothing
        local integer i = 0
        
        loop
        exitwhen i == 4
            
            if GetLocalPlayer() == Player(i) then
                call SetCameraField(CAMERA_FIELD_ZOFFSET, CameraHeight<i>, 0.1)
            endif
            
        set i = i + 1
        endloop
    endfunction
    
    private function CHinit takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterTimerEvent(t, 0.2, true)
        call TriggerAddAction(t, function CHstart)

    endfunction

endscope
</i>


To use it, the player just has to type '-zoom<space><A Number>'
ie. '-zoom 1000' or '-zoom -9000'
(Yes, negative zooms are allowed)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top