CHECK_CHAR_CURR_WEAPON crashes game

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
Rick
Car Jacker
Car Jacker
Posts: 33
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

CHECK_CHAR_CURR_WEAPON crashes game

Post 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.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: CHECK_CHAR_CURR_WEAPON crashes game

Post 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.
Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Re: CHECK_CHAR_CURR_WEAPON crashes game

Post 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
Rick
Car Jacker
Car Jacker
Posts: 33
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

Re: CHECK_CHAR_CURR_WEAPON crashes game

Post 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]
Post Reply