I know this code works so it should make a good example for how CMD's can be used for activation of certain simple loop CLEO's, will have to be done differently if it's something else like "/slap [ID]"
Code:
{$CLEO .cs}
thread 'Knife'
0@ = 0 // Ensures hack is turned off as game starts.
// Making sure samp is loaded before using any sampfuncs stuff.
repeat
wait 0
until 0AFA: is_samp_available
0B34: samp register_client_command ".kn" to_label @toggle // REF toggle for new activation method.
// Main loop of code.
while true
wait 0
0B2B: samp 1@ = get_player_id_by_actor_handle $PLAYER_ACTOR
0B57: samp 2@ = player 1@ animation_id
if and
0039: 0@ == 1 // Var 0@ must be equal to 1 which is determined by the :toggle label which switches var 0@ between 1 and 0 upon cmd.
0039: 2@ == 748
044B: actor $PLAYER_ACTOR on_foot
02D8: actor $PLAYER_ACTOR current_weapon == 4
then
wait 50
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x22
end
end
:toggle
wait 0
if
0039: 0@ == 0 // OFF
then
0006: 0@ = 1 // ON
0AF8: "{00FF00}Knife on" 1
else
0AF8: "{FF0000}Knife off" 1
0006: 0@ = 0 // OFF
end
0B43: samp cmd_ret
// All in all this toggle label just sets a var(0@) to either 1(on) or 0(off) which is checked in main loop as activation.
:FAKE_KEYPRESS
1@ = 0xB73458
005A: 1@ += 0@ // (int)
0A8C: write_memory 1@ size 1 value 255 virtual_protect 0
0AB2: ret 0
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.