CLEO Help request_animation crash

CLEO related
Status
Not open for further replies.

englezeanu

Active member
Joined
Dec 17, 2013
Messages
40
Reaction score
0
Hi. I'm trying to make an auto walking script ( i'm doing this using animations ).

When I put this in .cs file, SAMP crashes at startup ( after loading ):

Code:
:first_things
04ED: request_animation "PED"

I use it to preload the animation.

P.S: GTA SA singleplayer isn't crashing.
 

not490

Well-known member
Joined
Feb 8, 2014
Messages
438
Reaction score
4
Can u show me the script from a begin ? If its private, send me message. ill help u to fix this
 

englezeanu

Active member
Joined
Dec 17, 2013
Messages
40
Reaction score
0
not490 link said:
Can u show me the script from a begin ? If its private, send me message. ill help u to fix this

Code:
{$CLEO .cs}
:Move_1
thread "MOVE"

3@ = false

:first_things
04ED: request_animation "PED"

:move_checkkey
while true
wait 0
    if and
        0AB0: is_key_pressed 8
        0B21: NOT samp is_chat_opened
    then
        3@ = true
        0002: jump @start_move
        wait 1000
    end
   
    if and
        0AB0: is_key_pressed 8
        0B21: NOT samp is_chat_opened
    then
        3@ = false
        wait 1000
    end
end

:start_move
while 3@ == true
    wait 0

    0812: task_play_anim_non_interruptable $PLAYER_ACTOR anim "RUN_PLAYER" ifp "PED" framedelta 4.1 loop 0 lockX 0 lockY 0 lockF 0 time -1 // starts running
	wait 5000
	
	
	0614: set_char_anim_current_time $PLAYER_ACTOR anim "RUN_PLAYER" to 1.0 // stops after 5sec
    wait 50
    
    // attack!
	0AB1: call @keyPress 2 key 0x1D time 50 // press ctrl ( attack )
end

:keyPress // got from ugbase
// 0@ - key, 1@ - time
// Example: 0AB1: call @keyPress 2 key 0@ time 1@
// 0x1D - LCTRL - http://msdn.microsoft.com/en-us/library/windows/desktop/ms646304(v=vs.85).aspx

if 0AA2: 2@ = load_library "User32.dll"
then
     if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
     then
         0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
         wait 1@
         0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
     end
end
0AB2: ret 0

Also, there are another 2 problems:
- I made this script to activate when you press backspace and you are not in chat, but, actually, script activates when you press backspace AND you are in chat
- It doesn't 'press' LCTRL
 

not490

Well-known member
Joined
Feb 8, 2014
Messages
438
Reaction score
4
Well its pretty hard to start from animations, try this first


Code:
{$CLEO .cs} // allways add {$CLEO .cs} because its the file u gonna compile out soon. Remember the (space) at here  {$CLEO .cs}
 0000: // sometimes it wont let u compile the cleo if u dont add this right here before {$CLEO .cs}             
:THREAD_1 //Here your work begins
wait 0 // this is good to be here, because without this there will be caused an crash
if 
key_down 49
else_jump @THREAD_1 // This means if you are not pressed KEY 49(1) then it goes back to begin and looks if the key is now pressed
0ACD: show_text_highpriority "Gratz, this was your first cleo" time 2000  // remember time is as milliseconds  so 2000ms = 2sec, the time it shows the text
jump @THREAD_1 // after its done, it jumps back to THREAD_1, what is in the begin.



//BTW this  "//" what i did whole time is just an comment what does not matter on your script, it is just a help comment for other scripters 

Read that carefully and test does it works.
 

englezeanu

Active member
Joined
Dec 17, 2013
Messages
40
Reaction score
0
I'm not new to programming. I already know something about cleo. The only thing that I doesn't know NOW is WHY that opcode ( request_animation ) crashes my game ( only MP ).

I tried to 'request animation' on a key press, but it is still crashing ( crashes when I press that key )
 

not490

Well-known member
Joined
Feb 8, 2014
Messages
438
Reaction score
4
Because there is THREADs in wrong places and many other thing too, look at this Flamez made this:   
Code:
{$CLEO .cs}
0000: NOP 
:NONAME_2
wait 0 
04ED: load_animation "BEACH" 
if and
0AB0: key_pressed 32  
not Actor.Driving($PLAYER_ACTOR)
else_jump @NONAME_2 
wait 0 
0605: actor $PLAYER_ACTOR perform_animation_sequence "ParkSit_W_loop" IFP_file "BEACH" 4.0 loop 0 0 0 0 time 1 // versionA 
wait o
jump @NONAME_2
Also download SAMPFUNCS 3.1.2.
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
{$CLEO .cs}

thread "MOVE"

wait 0
3@ = false
04ED: request_animation "PED"

:move_checkkey
while true
wait 0
    if and
        0AB0: is_key_pressed 8
        0B21: NOT samp is_chat_opened
    then
        3@ = true
        0002: jump @start_move
        wait 1000
    end
 
    if and
        0AB0: is_key_pressed 8
        0B21: NOT samp is_chat_opened
    then
        3@ = false
        wait 1000
    end
end

:start_move
while 3@ == true
    wait 0

    0812: task_play_anim_non_interruptable $PLAYER_ACTOR anim "RUN_PLAYER" ifp "PED" framedelta 4.1 loop 0 lockX 0 lockY 0 lockF 0 time -1 // starts running
wait 5000


0614: set_char_anim_current_time $PLAYER_ACTOR anim "RUN_PLAYER" to 1.0 // stops after 5sec
    wait 50
   
0AB1: call @keyPress 2 key 0x1D time 50 // press ctrl ( attack )
end

:keyPress

if 0AA2: 2@ = load_library "User32.dll"
then
    if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
    then
        0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
        wait 1@
        0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
    end
end
0AB2: ret 0
 
Status
Not open for further replies.
Top