Quantcast

Jump to content

» «
Photo

Check if player is wearing armour

5 replies to this topic
thrndm
  • thrndm

    Player Hater

  • Members
  • Joined: 05 Mar 2010

#1

Posted 18 March 2012 - 12:47 PM Edited by thrndm, 18 March 2012 - 04:47 PM.

Hello there. I'm trying to check if player is wearing armour and sitting in vehicle. There is no 04DD opcode in III so I'm forced to use memory-related functions to get current armour value. Temporary test code below is supposed to show tiny weapon icon when player is on foot and quickly switch between tiny and large-sized weapon icon when player wears armour and uses vehicle. Instead it crashes my game as soon as I enter the car. I got feeling that something is wrong with read_memory related part of code but I'm unable to find an error here.
I hope someone could help me on this. Thanks in advance.
CODE
{$CLEO}  
0000:  

:CARH0
wait 0 ms
if
0256:player $2 defined
jf @CARH0
035E:set_player $2 armour_to 100

:CARH1
wait 0 ms        
05DF:write_memory 0x5FDBB0 size 4 value 16.0 virtual_protect 0
if
00E0:player $2 driving
jf @CARH1

:CARH2
wait 0
05E6:1@ = actor $2 struct
1@ += 0x2C0
1@ += 0x4
05E0:1@ = read_memory 1@ size 4 virtual_protect 0
008C:1@ = float_to_integer 1@
if
1@ > 0
jf @CARH2

:CARNO
wait 0 ms                    
05DF:write_memory 0x5FDBB0 size 4 value 128.0 virtual_protect 0
jump @CARH1

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#2

Posted 18 March 2012 - 01:01 PM Edited by Ashwin the new boy, 18 March 2012 - 01:06 PM.

the problem is
CODE

05E6:1@ = actor $2 struct

actor is $3
$2 is used for Player_CHAR
and
another thing is '05E6' also crash the game, (for me)

also start label after new line, it makes easy to read,

use 0x2C4
instead of
1@ += 0x2C0
1@ += 0x4

and i am not sure your mem add,

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci Racing
  • Joined: 30 Jan 2011
  • Brazil

#3

Posted 18 March 2012 - 01:15 PM

CODE
05E6:1@ = actor $2 struct

$2 isn't a actor, is a player, use $3 for player actor handle.

EDIT: Sorry, I posted too late, ashwin already posted bored.gif

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#4

Posted 18 March 2012 - 01:22 PM

i want to say something for you LINK,
* you were not here when i post this reply,
* you have not edited you post you just add that last sentence during reply,
* i think you are just increasing your POST,
sorry if i am wrong,

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci Racing
  • Joined: 30 Jan 2011
  • Brazil

#5

Posted 18 March 2012 - 01:31 PM

QUOTE
* you were not here when i post this reply,

I was logged as anonymous.

QUOTE
* you have not edited you post you just add that last sentence during reply,

Wrong, If you say it because the post doesn't contain a "This post has been edited by...", that is because I edited in the same instant that I posted, So this msg doesn't appears

QUOTE
* i think you are just increasing your POST,

If I'm interested in increase my post count I was flooding in other forum sections, but I'm posting just here in coding section (and sometimes only).

Don't acknowledge people thus dozingoff.gif

thrndm
  • thrndm

    Player Hater

  • Members
  • Joined: 05 Mar 2010

#6

Posted 18 March 2012 - 04:46 PM Edited by thrndm, 18 March 2012 - 04:49 PM.

Alright, looks like this one works. ..Thanks to ThirteenAG.
CODE
{$CLEO}  
0000:  

:CARH0
wait 0 ms
if
0256:player $2 defined
jf @CARH0
035E:set_player $2 armour_to 100

:CARH1
wait 0 ms        
05DF:write_memory 0x5FDBB0 size 4 value 16.0 virtual_protect 0
if
00E0:player $2 driving
jf @CARH1

:CARH2
wait 0
05E6:1@ = actor $SCRIPT_CONTROLLED_PLAYER struct
000A:1@ += 704
000A:1@ += 4
05E0:1@ = read_memory 12@ size 4 virtual_protect 0
008C:1@ = float_to_integer 12@
if
1@ > 0
jf @CARH2

:CARNO
wait 0 ms                    
05DF:write_memory 0x5FDBB0 size 4 value 128.0 virtual_protect 0
jump @CARH1

Thread may be closed now I guess, thanks to everyone.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users