Why does this make me crash when I'm not hosting a server?

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

Why does this make me crash when I'm not hosting a server?

Postby Anteara » Sat Mar 26, 2011 11:41 am

Hi, Guys, I have a problem that I just cannot figure out.

When I am hosting a server, and use this function to call a vehicle model and refresh my model online, and then afterward set my physics to the vehicle that the correlates with the model, it works beautifully.

When I do it on a server i am NOT hosting, I crash. I have no idea why, does anyone have any idea as to why this may make me crash? I want this to work extremely bad as it would be something that I could be proud of as I haven't seen anyone do this in their mod before.

Anyway, here is the function.

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$ = %GLOBAL%$Vehicle_Name$:s}
         :i :s}
   :i call $RefreshSkaterModel$ arguments
      $profile$ = %GLOBAL%$currentSkaterProfileIndex$$skater$ = %i(0,00000000)
:i endfunction


The function is pretty straightforward, which is why I can't figure out why it makes me crash. Thankyou.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Why does this make me crash when I'm not hosting a server?

Postby Morten1337 » Sat Mar 26, 2011 12:55 pm

its because of this code:

Code: Select all

$skater$ = %i(0,00000000)

skater 0 is the host, so you would need to find your ow skater number.

EDIT: After some searching i found this "GetSkaterNumber" it returns "SkaterNumber".
so

Code: Select all

$skater$ = %GLOBAL%$SkaterNumber$
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Why does this make me crash when I'm not hosting a server?

Postby Anteara » Sat Mar 26, 2011 1:58 pm

Morten1337 wrote:its because of this code:

Code: Select all

$skater$ = %i(0,00000000)

skater 0 is the host, so you would need to find your ow skater number.

EDIT: After some searching i found this "GetSkaterNumber" it returns "SkaterNumber".
so

Code: Select all

$skater$ = %GLOBAL%$SkaterNumber$


Oh! So simple >_<. Thank you so much. :D


Edit: Hmm..... If i set

Code: Select all

$skater$ = %i(0,00000000)


to

Code: Select all

$skater$ = %i(1,00000001)


and join someones game, it will work....

But if i use "GetSkaterNumber" and "SkaterNumber", it still crashes... I'm assuming it is still returning a value of 0.

Code: Select all

:i function $Vehicle_Model_Create$
         :i $GetCurrentSkaterProfileIndex$
    :i $GetSkaterNumber$
         :i $EditPlayerAppearance$:s{
            :i $profile$ = %GLOBAL%$currentSkaterProfileIndex$
            :i $target$ = $SetPart$
            $targetParams$ = :s{$part$ = $deck_graphic$$desc_id$ = %GLOBAL%$Vehicle_Name$:s}
         :i :s}
   :i call $RefreshSkaterModel$ arguments
      $profile$ = %GLOBAL%$currentSkaterProfileIndex$$skater$ = %GLOBAL%$SkaterNumber$
:i endfunction


I'll keep trying. Any ideas though?

EDIT: I set "$skater$ = %GLOBAL%$skaterIndex$" and
" :i %GLOBAL%$skaterIndex$ = %i(1,00000001)"

So the problem is "GetSkaterNumber" not returning the correct value, any idea how i can do that?
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Why does this make me crash when I'm not hosting a server?

Postby Anteara » Sat Oct 08, 2011 11:56 pm

I'm just going to bump this, to let anyone know if they're interested that I managed to fix this problem with THUG2AMX. I was informed that this was impossible to do via .qb, and to try THUG2AMX, and it works perfectly.

(The problem being not able to use the script for 0-7 player id)
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Why does this make me crash when I'm not hosting a server?

Postby Anteara » Tue Oct 11, 2011 10:58 am

Okay, this is getting ridiculous, I desk checked the algorithm, it works PERFECTLY. It can return the skater number correctly every single time. However, my function still crashes.
Here is the desk check to confirm that I know what the function is doing.

I know that it is incrementing by one until the condition is met.

Code: Select all

My skater index is 0.
Skater Num is 0.
Skater = Skaternum = 0.
My skater index = Skaternum = 0.
Skaternum = Skaternum + 1 = 1

Skater num = 1
Skater = Skaternum = 1.
My skater index = skaternum = 1
Skaternum = Skaternum + 1 = 2

Skater num = 2
Skater = Skaternum = 2
My skater index = skaternum = 2
Skaternum = Skaternum + 1 = 3

Skater num = 3
Skater = Skaternum = 3
My skater index = skaternum = 3


SKATER, SKATERNUM, AND MY_SKATER_INDEX = 3 (Correct, I am the 4th person on the server.)


So as seen there, the algorithm works as intended.

Now, when I try to make this part of my function work,

Code: Select all

      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = ___________


It still crashes. I know with one hundred percent certainty that this is what is causing the crashes. I have underlined where in the code it is crashing, i have also removed what skater is equal to. I know what I should write. I should write "$Skater$ = %GLOBAL%$Skaternum$. I am PRETTY DARN SURE that is what it should be. However, no, it still crashes. Since Skater, skaternum and Skater index will all be 3 by this time, I have tried "Skater$ = %GLOBAL%$Skater$", "$Skater$ = %GLOBAL%$my_skater_index$", and "$Skater$ = %GLOBAL%$Skaternum$"

They all crash.

I know the algorithm is correct! I know the logic is correct! I have checked with three different variables that should all return the same thing, they are all correct! Yet THUG2 still crashes!

Pardon my language, but... what. the. fuck.

Any help is greatly appreciated. Thanks.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Why does this make me crash when I'm not hosting a server?

Postby Anteara » Wed Oct 12, 2011 7:40 am

as far as i know skater only accepts int, but i have an idea

Edit: So my idea worked, I removed the call script in the startup function, because I won't need it to be called upon startup, I'll simply start my vehicle script, then at the end of the script, call the function.

Code: Select all

:i function $test_number_id$
   :i %GLOBAL%$SkaterNum$ = %i(0,00000000)
   :i while
     
      :i if call $SkaterExists$ arguments
            $Skater$ = %GLOBAL%$SkaterNum$
         :i if %GLOBAL%$objID$.$IsLocalSkater$
            :i $my_skater_index$ = %GLOBAL%$SkaterNum$
      :i if  (%GLOBAL%$my_skater_index$ = %i(0,00000000))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(0,00000000)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(1,00000001))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(1,00000001)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(2,00000002))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(2,00000002)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(3,00000003))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(3,00000003)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(4,00000004))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(4,00000004)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(5,00000005))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(5,00000005)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(6,00000006))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(6,00000006)
      :i endif
      :i if  (%GLOBAL%$my_skater_index$ = %i(7,00000007))
      :i call $RefreshSkaterModel$ arguments
         $profile$ = %GLOBAL%$currentSkaterProfileIndex$$Skater$ = %i(7,00000007)
      :i endif
         :i endif
      :i endif
      :i %GLOBAL%$SkaterNum$ =  (%GLOBAL%$SkaterNum$ + %i(1,00000001))
   :i loop_to %i(8,00000008)
:i endfunction


It's pretty messy code, and I hate messy code. But this is the only way I could get it to work. $skater$ = %GLOBAL%$my_skater_index$ would not work, and it would not work if i set it to an ID, either. Based on the fact that it wouldn't work with %GLOBAL%$my_skater_index$ and as an ID, do you think i was doing something wrong, or do you think the game might be bugged or something, honestly, I'm going to go with the latter, because I seriously don't think I did anything wrong. Based on the assumption that I did nothing wrong, the way I've implemented this is the most efficient way to do this?

Example.

Escape > Anteara Menu > Vehicle Menu > Vehicle Script > Global model script > test_number_id

That means that I can still use only one function for each vehicle, regardless of the skater number.

Return to “THUG2 modding”

Who is online

Users browsing this forum: No registered users and 22 guests