Page 1 of 1

CHECK_CHAR_CURR_WEAPON crashes game

Posted: 28 Mar 2018, 01:13
by Rick
Hi.
I didn´t find a solution here in the forum.

I detected a line of code in my script which causes problems:

Code: Select all

IF(CHECK_CHAR_CURR_WEAPON (p2, WEAPON_14))
... do something here...
ENDIF

In game everything works well and I pretty need this check.
Only when p2 ( or any other player than p1 ) leaves the game it crashes every particpant instance.
Is there a known solution to handle this bug?

Or is it possible to set a flag, when a player actually left?

CHECK_CHARACTER_HEALTH(p2, 0))
doesn´t return FALSE after leaving at least :(
I guess the player dummy still remains somewhere in the memory, right?

Thanks for any tipps.

Re: CHECK_CHAR_CURR_WEAPON crashes game

Posted: 28 Mar 2018, 01:47
by Sektor
There are some checks that return false when a player leaves but I can't remember which one right now, I must have recorded it somewhere.

There are some crashes related to the unused weapons like WEAPON_14, it may crash if a cop sees you fire it.

edit:

Found this in my testflight script http://gtamp.com/maps/testflight.7z
[mis]
//do all this stuff to the current player then move to next player
//the CHECK_SCORE_GREATER is to detect if a player leaves the game
//leaving the game doesn't kill your character, so health check won't work
WHILE_EXEC ((player<playercount) AND (CHECK_SCORE_GREATER (p,0)))
[/mis]
You would have to make sure the players always have at least $1. When a player leaves, they turn into a bot. Bots can't have money, so it always returns 0 for them.

Re: CHECK_CHAR_CURR_WEAPON crashes game

Posted: 28 Mar 2018, 02:12
by Logofero
Another example (did not check it). But in theory it should work.

Code: Select all

IF (NOT (HAS_CHARACTER_DIED (player2)))
    IF (CHECK_CHAR_CURR_WEAPON (player2, GRENADE))
        GIVE_WEAPON(player2, PISTOL)
    ENDIF
ENDIF

Re: CHECK_CHAR_CURR_WEAPON crashes game

Posted: 28 Mar 2018, 09:47
by Rick
Wrapping it into CHECK_SCORE_GREATER(0,p) works splendid. :)

As I first thought checking the players individually is the way to solve it
this now allowed me to tidy things up again a little.

I also had tried your approach, Logofero.
But I had no success.

I tested the following using an ONSCREEN_COUNTER for inc:

Code: Select all

IF (HAS_CHARACTER_DIED (p2))
     ++inc
ENDIF
But inc was just raised every now and then, I guess that´s why it won´t work, also it seems logical in a way.

Thanks a lot! [respect]