Pointer script issues

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Pointer script issues

Post by elypter »

i copied some code from the superman test map but when i run it the game crashes instantly. it crashes on the first gang respect reading call. does anyone have an idea whats wrong?
Attachments
tafl.7z
(3.85 KiB) Downloaded 548 times
yur sa'nok ngeyä
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Pointer script issues

Post by Sektor »

It was trying to read x for players that didn't exist, so I moved all the code into the CHECK_HEALTH_GREATER to make sure they exist. The WHILE_EXEC(player<6) ran 6 times and never again, so it would have been trying to read player 6. I put WHILE_EXEC(player<6) inside WHILE_EXEC ( neverends = 1 ) and I reset player counter to 0, so that the loop could start again from player 1.

[mis]//{ //Header
// Tafl
// script and map by Elypter

//}

//{ //Declares
//{ //PlayerDefines
//{ //Player
CHAR_DATA p
COUNTER px=0
COUNTER py=0
//}
//{ //Player1
PLAYER_PED p1 = (124.5, 125.5, 255.0) 7 45
COUNTER p1x=0
COUNTER p1y=0
//}
//{ //Player2
PLAYER_PED p2 = (116.5, 117.5, 255.0) 8 225
COUNTER p2x=0
COUNTER p2y=0
//}
//{ //Player3
PLAYER_PED p3 = (120.5, 117.5, 255.0) 9 180
COUNTER p3x=0
COUNTER p3y=0
//}
//{ //Player4
PLAYER_PED p4 = (120.5, 125.5, 255.0) 10 180
COUNTER p4x=0
COUNTER p4y=0
//}
//{ //Player5
PLAYER_PED p5 = (124.5, 117.5, 255.0) 11 135
COUNTER p5x=0
COUNTER p5y=0
//}
//{ //Player6
PLAYER_PED p6 = (116.5, 125.5, 255.0) 12 315
COUNTER p6x=0
COUNTER p6y=0
//}
//}

COUNTER player=0
COUNTER neverends=1
COUNTER in=0
COUNTER out=0
COUNTER diffx=0
COUNTER diffy=0
//}

LEVELSTART

WHILE_EXEC ( neverends = 1 )

SET player=0

WHILE_EXEC(player<6)
//{ //PlayerPointers
++player
if(player=1)
SET p=(p1+0)
SET px=(p1x+0)
SET py=(p1y+0)
endif
if(player=2)
SET p=(p2+0)
SET px=(p2x+0)
SET py=(p2y+0)
endif
if(player=3)
SET p=(p3+0)
SET px=(p3x+0)
SET py=(p3y+0)
endif
if(player=4)
SET p=(p4+0)
SET px=(p4x+0)
SET py=(p4y+0)
endif
if(player=5)
SET p=(p5+0)
SET px=(p5x+0)
SET py=(p5y+0)
endif
if(player=6)
SET p=(p6+0)
SET px=(p6x+0)
SET py=(p6y+0)
endif
//}

IF (CHECK_CHARACTER_HEALTH(p, 0))

//{ //read player x

SET in = (p+360)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+128)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+20)

CHANGE_GANG_CHAR_RESPECT (in,px,104) //read x
//}
//{ //read player y
SET in = (p+360)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+128)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+24)
CHANGE_GANG_CHAR_RESPECT (in,py,104) //read y
//}

//diff=diff-((diff/2)*2)
SET diffx=(px/2)
SET diffx=(diffx*2)
SET diffx=(px - diffx)
SET diffy=(py/2)
SET diffy=(diffy*2)
SET diffy=(py - diffy)

IF (((diffx=0) AND (NOT (diffy=0)))OR((NOT(diffx=0)) AND (diffy=0)))
REMOVE_WEAPONS (p)
GIVE_WEAPON (p,ROCKET_LAUNCHER,10)
else
REMOVE_WEAPONS (p)
GIVE_WEAPON (p,FLAME_THROWER,10)
endif
IF((px=120)AND(py=121))
REMOVE_WEAPONS (p)
GIVE_WEAPON (p,ROCKET_LAUNCHER,10)
//fast reload
endif
ENDIF
ENDWHILE
ENDWHILE

LEVELEND[/mis]
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Pointer script issues

Post by elypter »

oh thanks, its really been a while since i was coding last time.

edit: now i was trying to find fast reload. i was playing around with some pointers and suddenly something weird happens when you go on the field in the middle wich gives you electrogun(for testing). the player gets stuck but the game does not crash but continues
Attachments
tafl.7z
(5.73 KiB) Downloaded 552 times
Last edited by elypter on 26 Dec 2014, 08:52, edited 1 time in total.
yur sa'nok ngeyä
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Pointer script issues

Post by Sektor »

Good to see someone attempting to use the peek/poke CHANGE_GANG_CHAR_RESPECT command. So many cool things can be done with it but so far I'm the only one who has used it and I just made test/example scripts.

What is your script supposed to do?
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Pointer script issues

Post by elypter »

*edit in posting above
the script should give the player different weapons depending on the field they are standing on. the central field should get fast reload and rocket launcher. the others flamer or rocket depending on the color of the field. i also wanted to add molotovs
yur sa'nok ngeyä
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Pointer script issues

Post by Sektor »

You can make the fast reload hud icon display by changing the player bitmask (p1+540) to the right value. I haven't looked up the value. I think it would just be cosmetic since more bytes need changing to actually enable fast reload.

There's a way to adjust the reload delay to any value you like:

[mis]
//change reload delay
COUNTER reload
SET in=(p+368) //player + 368 is a pointer to the player ammo (only for first weapon slot)
CHANGE_GANG_CHAR_RESPECT (in,out,104) //read those 4 bytes
IF (out>0)
SET reload=(out+2) //we don't care about ammo, reload countdown is located at ammo location + 2
CHANGE_GANG_CHAR_RESPECT (reload,out,101) //read 1 byte
IF (out>5) // replace 5 with the reload time you want, 0 is instant reload
SET out=5 // replace 5 with the reload time you want, 0 is instant reload
CHANGE_GANG_CHAR_RESPECT (reload,out,111) //write 1 byte
ENDIF
ENDIF
[/mis]
Post Reply