Jump to content

[CLEO]


Moderat
 Share

Recommended Posts

Hello,

 

There is a CLEO script, made by TheTom, which places a checkpoint on your map and in the game, at coordinates that are being read from a .ini file.

 

The original script has about 300 KB, because for every checkpoint, there is the same code being repeated in the script over and over again.

 

What I am trying to do is to use the integer that I pass via a chat command, to dynamically change to which coordinate in the .ini file I want to load.

 

This is the whole script:

{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available

chatmsg "{FF8C00}QuestHelper {ffffff}- /qhelp - {FF8C00}By TheTom" -1

0B34: samp register_client_command "qhelp" to_label @qhelp
0B34: samp register_client_command "last" to_label @last
0B34: samp register_client_command "ccp" to_label @ccp
0B34: samp register_client_command "scp" to_label @showcp


:repeat

wait 0
jump @repeat

:qhelp
chatmsg "{B399F1}/cp <numar> {ffffff} - seteaza checkpoint-ul cu numarul X" -1
chatmsg "{B399F1}/ccp{ffffff} - opreste afisarea pe harta checkpoint-ului curent" -1
chatmsg "{B399F1}/last{ffffff} - vezi care a fost ultimul checkpoint setat" -1
samp.CmdRet


:last
chatmsg "{B399F1}Ultimul checkpoint setat a fost {ffffff}%d" -1 18@ 
samp.CmdRet


:showcp
SAMP.IsCommandTyped(18@)
06D6: disable_racing_checkpoint 2@ 
08FB: set_checkpoint 2@ type_to 0 
08FB: set_checkpoint 3@ type_to 0
06D6: disable_racing_checkpoint 3@ 
0AF0: 20@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key "x1"
0AF0: 21@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key "y1"
0AF0: 22@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key "z1"
06D5: 2@ = create_racing_checkpoint_at 20@ 21@ 22@ point_to 0 0 0 type 1 radius 3.0 
08FB: set_checkpoint 2@ type_to 1 
018A: 3@ = create_checkpoint_at 20@ 21@ 22@
08FB: set_checkpoint 3@ type_to 1 
25@ = 1
chatmsg "{B399F1}A fost setat checkpoint-ul %s" -1 18@
samp.CmdRet

:ccp
06D6: disable_racing_checkpoint 2@ 
08FB: set_checkpoint 2@ type_to 0 
08FB: set_checkpoint 3@ type_to 0
06D6: disable_racing_checkpoint 3@
chatmsg "{B399F1}Checkpoint-ul a fost sters." -1
samp.CmdRet

 

 

What I want to do, exactly, is using "18@" (which is the integer passed with the "/scp <integer>" command) with "x", "y", and "z", at the "section "QuestHelper" key "x1" part. This would make the same portion of the code reusable, instead of having the same code repeated 300 times (like in the original script).

 

Is this possible to do somehow? The first instinct was to try:

0AF0: 20@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key "x%s" 18@

which of course, doesn't work. Having "%d" instead of "%s" doesn't work either, and normally you can't combine strings with integers anyways, so it must be taken as a string.

Edited by Moderat
Link to comment
Share on other sites

Thanks!

 

This is the final version, that is now working, thanks to you.

{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available

chatmsg "{FF8C00}[QuestHelper]{FFFFFF} - /qhelp - {FF8C00}By TheTom (modified by {8DA5ED}Moderat{FFFFFF})" -1

0B34: samp register_client_command "qhelp" to_label @qhelp
0B34: samp register_client_command "last" to_label @last
0B34: samp register_client_command "ccp" to_label @ccp
0B34: samp register_client_command "scp" to_label @showcp

:repeat
wait 0
jump @repeat

:qhelp
chatmsg "{B399F1}[/cp <numãr>]{FFFFFF} - seteazã checkpoint-ul cu numãrul X." -1
chatmsg "{B399F1}[/ccp]{FFFFFF} - opreste afisarea pe hartã si în joc a checkpoint-ului curent." -1
chatmsg "{B399F1}[/last]{FFFFFF} - vezi care a fost ultimul checkpoint setat." -1
samp.CmdRet


:last
chatmsg "{B399F1}Ultimul checkpoint setat a fost{FFFFFF} %d" -1 31@ 
samp.CmdRet


:showcp
SAMP.IsCommandTyped(18@)
if
    0AD4: 19@ = scan_string 18@ format "%d" 31@
then
    format 22@v "x%d" 31@
    format 25@v "y%d" 31@
    format 28@v "z%d" 31@ 
    06D6: disable_racing_checkpoint 2@ 
    08FB: set_checkpoint 2@ type_to 0 
    08FB: set_checkpoint 3@ type_to 0
    06D6: disable_racing_checkpoint 3@ 
    0AF0: 10@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key 22@v
    0AF0: 11@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key 25@v
    0AF0: 12@ = get_int_from_ini_file "CLEO\QuestHelper.ini" section "QuestHelper" key 28@v
    06D5: 2@ = create_racing_checkpoint_at 10@ 11@ 12@ point_to 0 0 0 type 1 radius 3.0 
    08FB: set_checkpoint 2@ type_to 1 
    018A: 3@ = create_checkpoint_at 10@ 11@ 12@
    08FB: set_checkpoint 3@ type_to 1 
    chatmsg "{B399F1}A fost setat checkpoint-ul %d." -1 31@
else
    chatmsg "{B399F1}Pentru a seta un checkpoint, foloseste [/scp <numãr>]." -1
end
samp.CmdRet

:ccp
06D6: disable_racing_checkpoint 2@ 
08FB: set_checkpoint 2@ type_to 0 
08FB: set_checkpoint 3@ type_to 0
06D6: disable_racing_checkpoint 3@
chatmsg "{B399F1}Checkpoint-ul a fost sters." -1
samp.CmdRet

 

Edited by Moderat
Link to comment
Share on other sites

  • Nic locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.