[Guide] AutoHotkey in-game note taking script

Find all sorts of guides created by our community here. Includes guides such as drug use, roleplaying different types of characters, weapons etc.
Forum rules
The guides you see here have been unofficially created by the players, for the players. LSRP cannot be held responsible for the accuracy of any of the content you see here.
Post Reply
User avatar
Joe
Wannabe Don
Wannabe Don
Posts: 1405
Joined: Thu Oct 16, 2014 12:38 am
Location: England

[Guide] AutoHotkey in-game note taking script

Post by Joe » Thu Jul 05, 2018 3:35 pm


Image


This thread will walk you through how to create a simple note-taking script in-game (using SA:MP UDF for AutoHotkey), with fully working commands which allow you to create, view and delete your logs.

This script works by using the SA:MP UDF to integrate SA:MP UI into your script - this allows you to create many functional scripts which use the SA:MP interface, to do things like display messages in your chat box, tell you how much HP/armour you have, send chat messages, tell you details about your vehicle, and much more.

Below is a video, displaying the script in action:


CLICK HERE TO DOWNLOAD OR READ ON FOR HOW TO ADD TO YOUR OWN SCRIPT


STEP 1
The first thing you want to do is download the SAMP UDF. Assuming you already have AutoHotkey installed, click the link and press the green 'clone or download' button, and download the zip archive. You want to then extract the 'SAMP.ahk' file into the same folder you have your other AHK bind files, like so:
Image

STEP 2
In your binds AHK file, add the following line to the top of the script:
#Include %A_ScriptDir%\SAMP.ahk
Like so:
Image
This will instruct your binds file to utilise the commands found in the SAMP.ahk file.

STEP 3
In your binds AHK file, add the following to your script for the /log command:
:?:/log::
AddChatMessage("{FF0000}LOGBOOK - {FFFFFF}Please enter the note you wish to save. Time = your time.")
SendInput /log{Space}
Input varName, V M,{enter}
SendInput {end}+{home}{Del}{esc}
FormatTime, Date, , dd/MM/yyyy HH:mm
FileAppend, [%Date%] %varName%`r, Logbook.txt
AddChatMessage("{FF0000}LOGBOOK - {FFFFFF}Message saved successfully!")
Return
Nb. The notes will also save to the document in bold above, which is Logbook.txt. This file will automatically be created when you type the command. That's basically how this script works - it writes to the file and then displays the file's contents using the showlog command.
Nb. 2 Make sure to press space after you type /log for the first time, in order to input your message.

STEP 4
In your binds AHK file, add the following to your script for the /showlog command:
:?:/showlog::
AddChatMessage("{FF0000}LOGBOOK START")
Loop, read, Logbook.txt
Loop, parse, A_LoopReadLine, %A_Tab%
AddChatMessage(A_LoopReadLine)
AddChatMessage("{FF0000}LOGBOOK END")
Return
STEP 5
In your binds AHK file, add the following to your script for the /deletelog command:
:?:/deletelog::
FileDelete, Logbook.txt
AddChatMessage("{FF0000}LOGBOOK -{FFFFFF} Logbook Deleted")
Return


And that's it! The final document should look something like this:
Image

You can make as many of these you like - for example if you have four different characters and you want this to work on each of the characters, simply append the Logbook.txt file to something else for each script, like Logbook2.txt, Logbook3.txt, etc. My main use for this is for when role-playing taking notes on a pen and paper, but due to the difficult-to-use nature of the /note script, I decided to create this. It also has a few other uses, such as for storing information like drug prices so you remember, writing down key pieces of info/user names whom you may wish to report in the future.

You need to use this at your own discretion, though. I cannot be held accountable for any punishments you may receive for using this script - personally I see no issue with it, as long as you role-play around it correctly. To me, it's just the same as writing down on a piece of paper in front of your computer. It's useful for quickly writing down bits of information, particularly when role-playing illegally, such as when selling drugs - I find its best use when trying to remember how much you need to kick up to someone, or how much money you need to make on X batch of drugs.

Good luck, and have fun! If you have any questions pertaining to the use of this script or any other scripting possibilities using SAMP UDF, feel free to ask me.
Last edited by Joe on Fri Jul 06, 2018 7:40 pm, edited 1 time in total.

User avatar
Joe
Wannabe Don
Wannabe Don
Posts: 1405
Joined: Thu Oct 16, 2014 12:38 am
Location: England

Re: [Guide] AutoHotkey in-game note taking script

Post by Joe » Thu Jul 05, 2018 4:15 pm

Here are some other somewhat useful keybinds you guys might be able to put to good use (they do use the SAMP UDF as linked in the original post):

Display health and armour
:?:t/health::
if GetPlayerHealth() >= 150 {
AddChatMessage("{D6D6D6}Health:{008000} " GetPlayerHealth())
AddChatMessage("{D6D6D6}Armour:{C0C0C0} " GetPlayerArmor())
}
else {
AddChatMessage("{D6D6D6}Health:{FF0000} " GetPlayerHealth())
AddChatMessage("{D6D6D6}Armour:{C0C0C0} " GetPlayerArmor())
}
Return
Useful for getting an accurate representation of your HP and armour in number form - the HP colour will be green when at/above 150 (for all you coke heads) but red when less than 150. If your max HP is for example 130, change the 150 value to 130.
Image
Image

Force crash by typing a command, much faster
:?:t/crash::
Process, Close, gta_sa.exe
Return
Type /crash and you'll force crash much easier.

Vehicle model, model id and health
:?:t/vstats::
AddChatMessage("{D6D6D6}Vehicle:{FFFFFF}" A_Space GetVehicleModelName() A_Space "(" "{FFFF00}" GetVehicleModelID() "{FFFFFF})" A_Space "{D6D6D6}Vehicle Health:{FFFFFF}" A_Space GetVehicleHealth())
Return
Type the command /vstats and you'll be given the vehicle SA:MP model, vehicle model ID (such as for spawning a car in a movie server) and the HP of the vehicle. Each of these details are visible when typing /dl (minus the model name)
Image

User avatar
Joe
Wannabe Don
Wannabe Don
Posts: 1405
Joined: Thu Oct 16, 2014 12:38 am
Location: England

Re: [Guide] AutoHotkey in-game note taking script

Post by Joe » Fri Jul 06, 2018 7:48 pm

Updated the link to the SAMP UDF - posted the wrong one initially.

User avatar
les
Wannabe Mafia
Wannabe Mafia
Posts: 256
Joined: Fri May 11, 2018 12:39 pm
Ingame name: Jamar Mobley

Re: [Guide] AutoHotkey in-game note taking script

Post by les » Fri Jul 06, 2018 8:12 pm

Not bad.

User avatar
R.Marshall
Gangster
Gangster
Posts: 147
Joined: Wed Jul 24, 2013 7:21 pm
Ingame name: Rogan Marshall
Location: The Netherlands

Re: [Guide] AutoHotkey in-game note taking script

Post by R.Marshall » Mon Feb 11, 2019 2:10 pm

josef wrote: .
File not found. Plus does the UDF still work for you? Somehow I can't get it to work at all, anymore.
Image
POLICE OFFICER II ROGAN MARSHALL
G Platoon, D Platoon - Metropolitan Division
Los Santos Police Department — "To Protect and to Serve"

User avatar
Joe
Wannabe Don
Wannabe Don
Posts: 1405
Joined: Thu Oct 16, 2014 12:38 am
Location: England

Re: [Guide] AutoHotkey in-game note taking script

Post by Joe » Tue Feb 12, 2019 12:22 am

R.Marshall wrote:
Mon Feb 11, 2019 2:10 pm
josef wrote: .
File not found. Plus does the UDF still work for you? Somehow I can't get it to work at all, anymore.
The particular one I have included works fine, as it is compatible for 0.3DL. The original one I used to use (and I assume is the one you use) did not work for 0.3DL if I remember correctly. The new one is not in English (the comments that is) so is a little tricky to understand, but other than that I found it to work.

I'm sorry, I don't have the files saved locally anymore, but the guide includes full details on how to get the script working.

User avatar
R.Marshall
Gangster
Gangster
Posts: 147
Joined: Wed Jul 24, 2013 7:21 pm
Ingame name: Rogan Marshall
Location: The Netherlands

Re: [Guide] AutoHotkey in-game note taking script

Post by R.Marshall » Tue Feb 12, 2019 2:05 am

josef wrote:
Tue Feb 12, 2019 12:22 am
R.Marshall wrote:
Mon Feb 11, 2019 2:10 pm
josef wrote: .
File not found. Plus does the UDF still work for you? Somehow I can't get it to work at all, anymore.
The particular one I have included works fine, as it is compatible for 0.3DL. The original one I used to use (and I assume is the one you use) did not work for 0.3DL if I remember correctly. The new one is not in English (the comments that is) so is a little tricky to understand, but other than that I found it to work.

I'm sorry, I don't have the files saved locally anymore, but the guide includes full details on how to get the script working.
Thanks for the answer. Sadly it doesn´t work for me though, even with something basic as this: (also after compiling)
Spoiler: show
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
#Warn
#UseHook
#NoEnv
#SingleInstance force
#include %A_ScriptDir%\SAMP.ahk
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.


F1::
SendChat("test")
return

F2::
AddChatMessage("Test!")
return
Image
POLICE OFFICER II ROGAN MARSHALL
G Platoon, D Platoon - Metropolitan Division
Los Santos Police Department — "To Protect and to Serve"

User avatar
Frosty3712
Gangster
Gangster
Posts: 133
Joined: Sat Sep 08, 2018 9:35 am

Re: [Guide] AutoHotkey in-game note taking script

Post by Frosty3712 » Thu Jun 13, 2019 10:53 am

Very helpful, will try it out soon.

User avatar
xxxvi
Civilian
Civilian
Posts: 13
Joined: Wed Jan 10, 2018 10:19 am

Re: [Guide] AutoHotkey in-game note taking script

Post by xxxvi » Tue Sep 08, 2020 8:34 am

Can't get this to work, I can /log and it adds to the .txt but can't get anything to show up in the chat such as /health /vstats etc

Post Reply

Return to “Player-Created Guides”

Who is online

Users browsing this forum: No registered users