Online skater name colour by server position

Discuss thug2 modding, post your own, share your ideas, ask questions.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Online skater name colour by server position

Postby Anteara » Thu Jun 02, 2011 6:02 pm

Hi, The title may be hard to understand, but I know that when one joins a server, the host is generally always in red.
Second is always in Blue,
Third, in Green, etc.

Obviously, there is some sort of code that is able to identify each specific person in a server, as 0,1,2,3,4, etc. I'm assuming that the code that sorts player names colours is able to do this.

Does anyone know where to find the code that is responsible for this? For one of my functions, i need to be able to identify the mod users position in the server.

Thanks.

P.S: The reason I've been inactive lately is because I've been learning Python. It's a great language, imo.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Online skater name colour by server position

Postby Morten1337 » Fri Jun 03, 2011 3:49 am

There is a function "GetSkaterNum" not sure how it works, but it might help... I've never seen it being used.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Online skater name colour by server position

Postby Anteara » Sun Jun 05, 2011 9:59 am

Morten1337 wrote:There is a function "GetSkaterNum" not sure how it works, but it might help... I've never seen it being used.


I've tried to use it a while back, but couldn't figure out how to implement it; I used it the same way a function like "GetCurrentSkaterProfileIndex" would work, but it didn't do anything
(":i $GetSkaterNumber$" and "$skater$ = %GLOBAL%$SkaterNumber$")

I've also tried "$skater$ = %GLOBAL%$player$".

I honestly can't figure out any way to do this, I've tried everything I can think of.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Online skater name colour by server position

Postby Anteara » Mon Jun 06, 2011 9:05 am

I'll take a look, but while i'm looking i'll try make a workaround as well just incase I can't find it,

Code: Select all

   :i if ($skater$ = %i(1,00000001))
      :i call $add_roundbar_menu_item$ arguments
         $text$ = %s(4,"test")$pad_choose_script$ = $test_anteara$
   :i endif


That if statement doesn't work, I don't know if it would be possible to make it work either, do you know how to make an if statement like that work? Also, I'll try find the function for $IsHost$ and $Onserver$ as they might provide some clues. Thanks.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Online skater name colour by server position

Postby Morten1337 » Mon Jun 06, 2011 4:41 pm

Code: Select all

:i function $SkaterNumberCaseThing_idk$
:i $GetSkaterNumber$

   :i switch %GLOBAL%$SkaterNumber$
      :i case %i(0,00000000) #//Always Host?
#/   ACTION IF SKATER IS 00
         :i endcase
      case %i(1,00000001)
#/   ACTION IF SKATER IS 01
         :i endcase
      case %i(2,00000002)
#/   ACTION IF SKATER IS 02
         :i endcase
      case %i(3,00000003)
#/   ACTION IF SKATER IS 03
         :i endcase
      case %i(4,00000004)
#/   ACTION IF SKATER IS 04
         :i endcase
      case %i(5,00000005)
#/   ACTION IF SKATER IS 05
         :i endcase
      case %i(6,00000006)
#/   ACTION IF SKATER IS 06
         :i endcase
      case %i(7,00000007)
#/   ACTION IF SKATER IS 07
         :i end_switch
         
:i endfunction

(y)
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Online skater name colour by server position

Postby Anteara » Tue Jun 07, 2011 1:22 pm

Hi, Thanks Morten, I've taken that piece of code you've given me and I've expanded on it a little bit, I've tested my code, I know my code is working properly, there isn't anything wrong with it, so i think I've confirmed that $SkaterNumber$ and $GetSkaterNumber$ do absolutely nothing.

Can you please confirm that the code I've written would prove/disprove that $SkaterNumber$ actually does anything. Thanks, and If i've proven that $SkaterNumber$ does nothing, do you think I'm out of luck? ><


Heres the code.

Code: Select all

   :i $GetSkaterNumber$   
 :i switch %GLOBAL%$SkaterNumber$
   :i case %i(0,00000000)
         :i $text$ = %s(9,"host test")
         :i endcase
      case %i(1,00000001)
         :i $text$ = %s(8,"player 1")
         :i endcase
      case %i(2,00000002)
         :i $text$ = %s(8,"player 2")
         :i endcase
      case %i(3,00000003)
         :i $text$ = %s(8,"player 3")
         :i endcase
      case %i(4,00000004)
         :i $text$ = %s(8,"player 4")
         :i endcase
      case %i(5,00000005)
         :i $text$ = %s(8,"player 5")
         :i endcase
      case %i(6,00000006)
         :i $text$ = %s(8,"player 6")
         :i endcase
      case %i(7,00000007)
         :i $text$ = %s(8,"player 7")
         :i end_switch
         
   :i call $add_roundbar_menu_item$ arguments
      $text$ = %GLOBAL%$text$$id$ = $menu_SkaterNumber$$pad_choose_script$ = $test_SkaterNumber$
   :i $roundbar_menu_finish$
:i endfunction


:i function $test_SkaterNumber$
      :i $GetSkaterNumber$      
      :i switch %GLOBAL%$SkaterNumber$
      :i case %i(0,00000000)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(9,"host test")
         :i endcase
      case %i(1,00000001)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 1")
         :i endcase
      case %i(2,00000002)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 2")
         :i endcase
       case %i(3,00000003)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 3")
         :i endcase
      case %i(4,00000004)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 4")
         :i endcase
      case %i(5,00000005)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 5")
         :i endcase
      case %i(6,00000006)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 6")
         :i endcase
      case %i(7,00000007)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 7")
         :i end_switch
   
:i endfunction


I've tested this code without global (i.e. manually setting SkaterNumber to 0, 1, etc) and it works perfectly, but that doesn't get me anywhere. The only way I can do what i need to do is if I use global. Thanks.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Online skater name colour by server position

Postby Morten1337 » Tue Jun 07, 2011 3:50 pm

I'm 100% sure that GetSkaterNumber returns the int SkaterNumber. Unless its obsolete, which i doubt..
The problem is the switch/case, for some reason they do not work properly.

The code i posted earlier SHOULD work, but it doesn't.. try this in stead

Code: Select all

  :i $GetSkaterNumber$
...
:i if (%GLOBAL%$SkaterNumber$ = %i(3,00000003))
         :i call $SetScreenElementProps$ arguments
                  $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 3")
:i endif
:i if (%GLOBAL%$SkaterNumber$ = %i(4,00000004))
         :i call $SetScreenElementProps$ arguments
                  $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 4")
:i endif
...
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Online skater name colour by server position

Postby Anteara » Wed Jun 08, 2011 8:55 am

Morten1337 wrote:I'm 100% sure that GetSkaterNumber returns the int SkaterNumber. Unless its obsolete, which i doubt..
The problem is the switch/case, for some reason they do not work properly.

The code i posted earlier SHOULD work, but it doesn't.. try this in stead

Code: Select all

  :i $GetSkaterNumber$
...
:i if (%GLOBAL%$SkaterNumber$ = %i(3,00000003))
         :i call $SetScreenElementProps$ arguments
                  $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 3")
:i endif
:i if (%GLOBAL%$SkaterNumber$ = %i(4,00000004))
         :i call $SetScreenElementProps$ arguments
                  $id$ = :s{$menu_SkaterNumber$$child$ = %i(0,00000000):s}$text$ = %s(8,"player 4")
:i endif
...


Thanks, the new code works, however, it's still not returning anything, Once again, I confirmed that I'm not doing anything wrong, I replaced $SkaterNumber$ with $IsHost$ and $OnServer$ and both worked fine. The problem is still that $GetSkaterNumber$ is not returning any variable, I'm so confused, I have no idea why I can't get this to work...

Edit: I manually set SkaterNumber to 0, and it WORKS. The problem (I think) is that $GetSkaterNumber$ is not returning anything. Are you able to test this to confirm? I don't think I'm doing anything wrong as I can get it to work if I manually set it, with BOTH the switch and the if statements. I just can't get it to work if I use $GetSkaterNumber$ to return the variable.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Online skater name colour by server position

Postby Morten1337 » Wed Jun 08, 2011 1:38 pm

I just realized that GetSkaterNumber only returns 4 numbers. splitscreen
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Online skater name colour by server position

Postby Anteara » Sat Jun 11, 2011 5:41 pm

This is getting ridiculous.

I honestly don't understand Why I can't figure out how to do this. It, on paper, is SO simple.

I've found all these things that seem like they could help me (in no particular order);

Code: Select all

   :i call $GetSkaterID$ arguments
   $skater$ = %GLOBAL%$currentSkaterProfileIndex$

:i $GetCurrentSkaterProfileIndex$

:i %GLOBAL%$skaterIndex$ = %GLOBAL%$currentSkaterProfileIndex$

$skater$ = %GLOBAL%$skaterIndex$

:i $GetSkaterId$

$skater$ = %GLOBAL%$SkaterId$

:i %GLOBAL%$skaterId$ = %GLOBAL%$ObjId$

:i %GLOBAL%$skaterId$.$IsLocalSkater$


Yet none of them work! It's the last thing I need to do and it seems impossible for me, great...




Edit: This appears to work, it will sucessfully CHANGE the $skater$ int, but i still must do it manually...


Code: Select all

   :i switch $Skater$
      :i case %i(0,00000000)
         :i $text$ = %s(28,"Skater Number: 0 (Host)")
         :i endcase
       case %i(1,00000001)
         :i $text$ = %s(48,"Skater Number: 1 (First to join)")
         :i endcase
       case %i(2,00000002)
         :i $text$ = %s(49,"Skater Number: 2 (Second to join)")
         :i endcase
       case %i(3,00000003)
         :i $text$ = %s(48,"Skater Number: 3 (Third to join)")
         :i endcase
       case %i(4,00000004)
         :i $text$ = %s(49,"Skater Number: 4 (Fourth to join)")
         :i endcase
       case %i(5,00000005)
         :i $text$ = %s(48,"Skater Number: 5 (Fifth to join)")
         :i endcase
       case %i(6,00000006)
         :i $text$ = %s(48,"Skater Number: 6 (Sixth to join)")
         :i endcase
       case %i(7,00000007)
         :i $text$ = %s(49,"Skater Number: 7 (Seventh to join)")
         :i end_switch
   
   :i call $add_roundbar_menu_item$ arguments
      $text$ = %GLOBAL%$text$$id$ = $menu_SwitchSkaterNo$$pad_choose_script$ = $toggle_SwitchSkaterNo$



Code: Select all

:i $skater$ = %i(7,00000007)
:i function $toggle_SwitchSkaterNo$
   :i switch $Skater$
      :i case %i(7,00000007)
         :i call $change$ arguments
            $Skater$ = %i(0,00000000)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(25,"Skater Number: 0 (Host)")

         :i endcase
      case %i(0,00000000)
         :i call $change$ arguments
            $Skater$ = %i(1,00000001)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(23,"Skater Number: 1 (First to join)")

         :i endcase
      case %i(1,00000001)
         :i call $change$ arguments
            $Skater$ = %i(2,00000002)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(30,"Skater Number: 2 (Second to join)")

         :i endcase
       case %i(2,00000002)
         :i call $change$ arguments
            $Skater$ = %i(3,00000003)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(26,"Skater Number: 3 (Third to join)")

         :i endcase
      case %i(3,00000003)
         :i call $change$ arguments
            $Skater$ = %i(4,00000004)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(25,"Skater Number: 4 (Fourth to join)")

         :i endcase
      case %i(4,00000004)
         :i call $change$ arguments
            $Skater$ = %i(5,00000005)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(25,"Skater Number: 5 (Fifth to join)")

         :i endcase
      case %i(5,00000005)
         :i call $change$ arguments
            $Skater$ = %i(6,00000006)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(24,"Skater Number: 6 (Sixth to join)")

         :i endcase
      case %i(6,00000006)
         :i call $change$ arguments
            $Skater$ = %i(7,00000007)
         :i call $SetScreenElementProps$ arguments
            $id$ = :s{$menu_SwitchSkaterNo$$child$ = %i(0,00000000):s}$text$ = %s(25,"Skater Number: 7 (Seventh to join)")
         :i end_switch
   
:i endfunction


Code: Select all

:i function $Vehicle_Model_Create$
  :i if ($skater$ = %i(0,00000000))
         :i $GetCurrentSkaterProfileIndex$
         :i $EditPlayerAppearance$:s{
            :i $profile$ = %GLOBAL%$currentSkaterProfileIndex$
            :i $target$ = $SetPart$
            $targetParams$ = :s{$part$ = $deck_graphic$$desc_id$ = $tricycle$:s}
         :i :s}
   :i call $RefreshSkaterModel$ arguments
      $profile$ = %GLOBAL%$currentSkaterProfileIndex$$skater$ = %i(0,00000000)
:i endif

  :i if ($skater$ = %i(1,00000001))
         :i $GetCurrentSkaterProfileIndex$
         :i $EditPlayerAppearance$:s{
            :i $profile$ = %GLOBAL%$currentSkaterProfileIndex$
            :i $target$ = $SetPart$
            $targetParams$ = :s{$part$ = $deck_graphic$$desc_id$ = $tricycle$:s}
         :i :s}
   :i call $RefreshSkaterModel$ arguments
      $profile$ = %GLOBAL%$currentSkaterProfileIndex$$skater$ = %i(1,00000001)
:i endif
:i endfunction



So, I am using the $switch$ to change the skater variable int, and then calling Vehicle_Model_Create with an if statement for skater = 0 or 1, and it works, but my problem is that I still must change the skater variable int manually...

Do either of you think it would be possible to do this (i.e. find something in the scripts that would find the skater variable int)

Also, semi on topic, I've found functions such as $IsHost$ and $OnServer$. These functions are not in ANY Qb files, Which makes me wonder, how does the game interact with them? Are they stored in the EXE? If not, do you know how I could access these functions?

Thanks.
quazz
Posts: 185
Joined: Sat May 01, 2010 5:57 pm
Contact:

Re: Online skater name colour by server position

Postby quazz » Mon Jun 13, 2011 1:18 am

Those are hardcoded into the EXE source.. they can't be edited. :@

Will this work? Still have to add the rest but its more concise!

Edit: Maybe $Player$ = %i(0,0000000) ? I saw that somewhere.

Code: Select all

:i function $Vehicle_Model_Create$
         :i $GetCurrentSkaterProfileIndex$
         :i $EditPlayerAppearance$:s{
            :i $profile$ = %GLOBAL%$currentSkaterProfileIndex$
            :i $target$ = $SetPart$
            $targetParams$ = :s{$part$ = $deck_graphic$$desc_id$ = $tricycle$:s}
         :i :s}
  :i if ($skater$ = %i(0,00000000))
   :i call $RefreshSkaterModel$ arguments
      $profile$ = %GLOBAL%$currentSkaterProfileIndex$$skater$ = %i(0,00000000)
:i else
  :i if ($skater$ = %i(1,00000001))
      $profile$ = %GLOBAL%$currentSkaterProfileIndex$$skater$ = %i(1,00000001)
:i endif
:i endfunction

Return to “THUG2 modding”

Who is online

Users browsing this forum: Google [Bot] and 24 guests