- SA-MP Version
-
- 0.3.7
- Dependencies
-
- SAMPFUNCS
Installation:
- Put both Killer Marker.cs and Killer Marker.ini inside your cleo\ folder.
- You can optionally install this script at your ModLoader but make sure that Killer Marker.cs and Killer Marker.ini were inside a folder named cleo\.
Script Features:
- Automatically Changes the Color of any Player that kills you. Their Color Marker can be changed on either through CMD or INI File.
- Change the Default Settings though a Configurable INI File named Killer Marker.ini .
- Built-in Commands:
- /killermarker mode 0 ~ Disables this Script.
- /killermarker mode 1 ~ Mark Killers, Unmark after his Death.
- /killermarker mode 2 ~ Mark Killers, Unmark when I Killed Him.
- /killermarker mode 3 ~ Mark Killers Permanently.
- /killermarker add <Player ID> ~ Manually Mark a Player using the Default Marker Color.
- /killermarker add <Player ID> <0xAARRGGBB> ~ Manually Mark a Player with a specified color.
- /killermarker del <Player ID> ~ Manually UnMark a Player.
- /killermarker cmc <0xAARRGGBB> ~ Change the Automatic Marker Color.
- /killermarker Blink 0 ~ Killer Marker will be a Solid Color.
- /killermarker Blink 1 ~ Killer Marker will have a Blinking effect.
- /killermarker cbi <Blinking Interval> ~ Change the Blinking Interval in MilliSeconds.
Inspiration for its Creation:
- To Publicly Create a Script Template that Scripters can use as their basis or reference.
- To Publicly Educate readers by providing a highly sophisticated source code consisting of:
- Bug Free System Mechanics.
- Comments providing Detailed Information/Explanation.
- Well Organized Script.
- Smart Memory Region Expansion for Database use purposes.
Source Codes:
PHP:
/*
Killer Marker v0.0.1 by AJOM
Publicly Released at UGBASE.EU
Requirements:
CLEO 4.4.0
SAMPFUNCS 3.4.1
Credits:
AJOM - Script Creator, Main Author
*/
{$CLEO}
{$USE SAMPFUNCS}
{$USE bitwise}
{$USE ini}
{$INCLUDE SF}
0000:
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Initialization~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
repeat
wait 0
until 0AFA: is_samp_available
const
SCRIPTFLAGS = 31@
BLINKINGMARKERCOLORS = 0
MODE = 30@
SCRIPTDISABLED = 0
UNMARK_EVERYTIME_HE_DIES = 1
UNMARK_AFTER_I_KILLED_HIM = 2
// Mark Killers Permanently = any value other than the parameters above
MARKERDATABASE = 29@
BLINKINTERVAL = 28@
MARKERCOLOR = 27@
MARKEDPLAYERSTRUCTSIZE = 10
end
// Load Settings
if 0AF0: 0@ = read_int_from_ini_file "cleo\Killer Marker.ini" section "DEFAULT" key "Blinking_Marker_Colors"
then
if 0@ <= 0
then 08C3: clear SCRIPTFLAGS bit BLINKINGMARKERCOLORS
else 08BD: set SCRIPTFLAGS bit BLINKINGMARKERCOLORS
end
else 08BD: set SCRIPTFLAGS bit BLINKINGMARKERCOLORS
end
if 8AF0: not BLINKINTERVAL = read_int_from_ini_file "cleo\Killer Marker.ini" section "DEFAULT" key "Blink_Interval_ms"
then BLINKINTERVAL = 500
end
if 8AF0: not MARKERCOLOR = read_int_from_ini_file "cleo\Killer Marker.ini" section "DEFAULT" key "Marker_Color"
then MARKERCOLOR = 0xFF00FF00
end
if 8AF0: not MODE = read_int_from_ini_file "cleo\Killer Marker.ini" section "DEFAULT" key "Mode"
then MODE = 2
end
//
/*
MARKERDATABASE Struct:
+0 ~ 2 bytes ~ Database Used Index Count
+0 ~ 2 bytes ~ Database Max Index Count
+4 ~ (DatabaseMaxIndexCount * 10) bytes ~ Marked Player List
For each Index:
+0 ~ 2 bytes ~ Player ID
+2 ~ 4 bytes ~ Marker Color
+6 ~ 4 bytes ~ Old Color
*/
0AC8: MARKERDATABASE = allocate_memory_size 14 // initial size
0A8C: write_memory MARKERDATABASE size 2 value 0 virtual_protect 0 // Initial Database Used Index Count
0A8E: 0@ = MARKERDATABASE + 2
0A8C: write_memory 0@ size 2 value 1 virtual_protect 0 // Initial Database Max Index Count
0@ += 2
0A8C: write_memory 0@ size 2 value 0xFFFF virtual_protect 0 // Null Player ID
// Setup Hooks
0BE3: raknet setup_incoming_rpc_hook @rpc
0BE1: raknet setup_outcoming_rpc_hook @rpc
0B34: samp register_client_command "killermarker" to_label @changesettings
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~End of Initialization~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Main Loop~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
while true
wait 0
if MODE <> SCRIPTDISABLED
then
if and
08B7: test SCRIPTFLAGS bit BLINKINGMARKERCOLORS
001D: TIMERA > BLINKINTERVAL
then
0A90: 0@ = BLINKINTERVAL * 2
if 002D: TIMERA >= 0@
then TIMERA = 0 // reset timer
end
0AB1: @MarkAllList 2 _MarkerDatabase MARKERDATABASE _UseTheirOldColor true
else 0AB1: @MarkAllList 2 _MarkerDatabase MARKERDATABASE _UseTheirOldColor false
end
end
end
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~End of Main Loop~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Functions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:SetSAMPPlayerARGBColor // 0AB1: @SetSAMPPlayerARGBColor 2 _OfPlayer 0@ _IntoARGBColor 1@
if 0AA2: 31@ = load_dynamic_library "samp.dll" // no need to free library
then
// ROR(1@,8) = Function Bit Rotate Right 1@ by 8
0085: 30@ = 1@
0B1C: 30@ >>= 24
0B1D: 1@ <<= 8
0B18: 1@ |= 30@
//
31@ += 0x216378
0@ *= 4
005A: 31@ += 0@
0A8C: write_memory 31@ size 4 value 1@ virtual_protect 0
end
ret 0
:MarkAllList
// Database Used Index Count
0A8D: 30@ = read_memory 0@ size 2 virtual_protect 0
//
0A8E: 31@ = 0@ + 4 // ->Marked Player List
0085: 29@ = 30@
while 29@ >= 1
0A8D: 28@ = read_memory 31@ size 2 virtual_protect 0 // Player ID
if 0B23: samp is_player_connected 28@
then
0C0C: 27@ = struct 31@ offset 2 size 4 // Player Marker Color
0C0C: 26@ = struct 31@ offset 6 size 4 // Player Old Color
0B37: samp 25@ = get_player_color 28@
if and
803B: not 25@ == 27@ // Current Player Color isn't his marker color
803B: not 25@ == 26@ // Current Player Color isn't his old color
then // update old color
0C0D: struct 31@ offset 6 size 4 = 25@
0085: 26@ = 25@
end
if 1@ == true // use old color?
then 0085: 27@ = 26@
end
if 803B: not 25@ == 27@ // Current Player Color isn't the target color
then 0AB1: @SetSAMPPlayerARGBColor 2 _OfPlayer 28@ _IntoARGBColor 27@
end
else if 28@ <= 1004
then 0AB1: @RemoveToMarkList 2 _MarkerDatabase 0@ _PlayerID 28@
end
end
31@ += MARKEDPLAYERSTRUCTSIZE // next index
29@--
end
ret 0
:AddToMarkList
0A8D: 29@ = read_memory 0@ size 2 virtual_protect 0 // Database Used Index Count
// Database Max Index Count
0A8E: 31@ = 0@ + 2
0A8D: 30@ = read_memory 31@ size 2 virtual_protect 0
//
// check if player is already marked
0A8E: 28@ = 31@ + 2 // ->Marked Player List
0085: 27@ = 29@
while 27@ >= 1
0A8D: 26@ = read_memory 28@ size 2 virtual_protect 0 // Player ID
if 003B: 26@ == 1@ // added player ID already exists on our list
then
28@ += 2
0A8D: 25@ = read_memory 28@ size 4 virtual_protect 0 // Marker Color
if 803B: not 25@ == 2@ // color is not the same
then 0A8C: write_memory 28@ size 4 value 2@ virtual_protect 0 // Update Color
end
0AB1: @SetSAMPPlayerARGBColor 2 _OfPlayer 1@ _IntoARGBColor 2@
ret 1 0@
else 28@ += MARKEDPLAYERSTRUCTSIZE // next index
end
27@--
end
//
0A8E: 28@ = 29@ + 1 // new Database Used Index Count because we will add a new marked player
if 001D: 28@ > 30@ // insufficient index available
then // reallocate memory size
// calculate new MARKERDATABASE struct size
0C8B: samp 26@ = get_player_count streamed_only false
0A90: 0@ = 26@ * MARKEDPLAYERSTRUCTSIZE // Marked Player List Struct Size
0@ += 4 // max and Used Index Count
//
0AC8: 0@ = allocate_memory_size 0@
0A8C: write_memory 0@ size 2 value 28@ virtual_protect 0 // New Database Used Index Count
0A8E: 27@ = 0@ + 2 // ->New Database Used Index Count
0A8C: write_memory 27@ size 2 value 26@ virtual_protect 0 // New Database Max Index Count
27@ += 2 // ->New Marked Player List Struct
31@ += 2 // ->Old Marked Player List Struct
0A90: 26@ = 29@ * MARKEDPLAYERSTRUCTSIZE // Old Marked Player List Struct Size
0C10: memcpy destination 27@ source 31@ size 26@ // copy the old data onto the new one
31@ -= 4 // Beggining of the Old MARKERDATABASE Struct
0AC9: free_allocated_memory 31@
// ->New MarkedPlayerList[NewUsedIndex]
0A8E: 31@ = 0@ + 26@
31@ += 4
//
else
0A8C: write_memory 0@ size 2 value 28@ virtual_protect 0 // New Database Used Index Count
// ->MarkedPlayerList[NewUsedIndex]
31@ += 2
0A90: 28@ = 29@ * MARKEDPLAYERSTRUCTSIZE
005A: 31@ += 28@
//
end
// add the new Marked Player info
0A8C: write_memory 31@ size 2 value 1@ virtual_protect 0 // Player ID
// Marker Color
31@ += 2
0A8C: write_memory 31@ size 4 value 2@ virtual_protect 0
//
// Old Color
0B37: samp 30@ = get_player_color 1@
31@ += 4
0A8C: write_memory 31@ size 4 value 30@ virtual_protect 0
//
0AB1: @SetSAMPPlayerARGBColor 2 _OfPlayer 1@ _IntoARGBColor 2@
ret 1 0@
:RemoveToMarkList
0A8D: 29@ = read_memory 0@ size 2 virtual_protect 0 // Database Used Index Count
0A8E: 30@ = 0@ + 4 // ->Marked Player List Struct
0085: 28@ = 29@
while 28@ >= 1
0A8D: 27@ = read_memory 30@ size 2 virtual_protect 0 // Player ID
if 003B: 27@ == 1@ // target player ID found
then
// revert his old color
if 0B23: samp is_player_connected 27@
then
0C0C: 26@ = struct 30@ offset 2 size 4 // Target Player Marker Color
0C0C: 25@ = struct 30@ offset 6 size 4 // Target Player Old Color
0B37: samp 24@ = get_player_color 27@
if 003B: 24@ == 26@ // target player color is the marker color
then 0AB1: @SetSAMPPlayerARGBColor 2 _OfPlayer 27@ _IntoARGBColor 25@
end
end
//
// remove index
0A8E: 27@ = 30@ + MARKEDPLAYERSTRUCTSIZE // next index
0A8F: 26@ = 29@ - 28@ // remaining index
26@ *= MARKEDPLAYERSTRUCTSIZE // remaining region to read
0C10: memcpy destination 30@ source 27@ size 26@
29@-- // decrease index count
0A8C: write_memory 0@ size 2 value 29@ virtual_protect 0 // New Used Index Count
//
ret 0
else 30@ += MARKEDPLAYERSTRUCTSIZE // next index
end
28@--
end
ret 0
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~End of Functions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CMD Hooks~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:changesettings
0B35: samp 0@ = get_last_command_params
if 0AD4: 3@ = scan_string 0@ format "add %d %X" 1@ 2@
then
if 0B23: samp is_player_connected 1@
then
0AB1: @AddToMarkList 3 _MarkerDatabase MARKERDATABASE _PlayerID 1@ _Color 2@ _ReturnNewDatabase MARKERDATABASE
0AF8: samp add_message_to_chat "Marked Player %d as a Killer" color 2@ 1@
else
:playernotconnectedcmdmessage
0AF8: samp add_message_to_chat "Player not Connected!" color 0xFFFF0000
end
else if 0AD4: 3@ = scan_string 0@ format "add %d" 1@
then
if 0B23: samp is_player_connected 1@
then
0AB1: @AddToMarkList 3 _MarkerDatabase MARKERDATABASE _PlayerID 1@ _Color MARKERCOLOR _ReturnNewDatabase MARKERDATABASE
0AF8: samp add_message_to_chat "Marked Player %d as a Killer" color MARKERCOLOR 1@
else jump @playernotconnectedcmdmessage
end
else if 0AD4: 3@ = scan_string 0@ format "del %d" 1@
then
if 0B23: samp is_player_connected 1@
then
0AB1: @RemoveToMarkList 2 _MarkerDatabase MARKERDATABASE _PlayerID 1@
0AF8: samp add_message_to_chat "Unmarked Player %d" color 0xFF00FF00 1@
else jump @playernotconnectedcmdmessage
end
else if 0AD4: 3@ = scan_string 0@ format "cmc %X" 1@
then
0085: MARKERCOLOR = 1@
0AF8: samp add_message_to_chat "Killer Marker Default Color has been changed into this message color!" color MARKERCOLOR
else if 0AD4: 3@ = scan_string 0@ format "blink %d" 1@
then
if 1@ <= 0
then
08C3: clear SCRIPTFLAGS bit BLINKINGMARKERCOLORS
0AF8: samp add_message_to_chat "Killer Marker: Solid Color" color 0xFF00FF00
else
08BD: set SCRIPTFLAGS bit BLINKINGMARKERCOLORS
0AF8: samp add_message_to_chat "Killer Marker: Blinking" color 0xFF00FF00
end
else if 0AD4: 3@ = scan_string 0@ format "cbi %d" 1@
then
0085: BLINKINTERVAL = 1@
0AF8: samp add_message_to_chat "Changed Killer Marker Blinking Interval into %dms" color 0xFF00FFFF BLINKINTERVAL
else if 0AD4: 3@ = scan_string 0@ format "mode %d" 1@
then
0085: MODE = 1@
if MODE == SCRIPTDISABLED
then
0AB1: @MarkAllList 2 _MarkerDatabase MARKERDATABASE _UseTheirOldColor true
0AF8: samp add_message_to_chat "Killer Marker: Disabled!" color 0xFFFF0000
else if MODE == UNMARK_EVERYTIME_HE_DIES
then 0AF8: samp add_message_to_chat "Killer Marker: Mark Killers, Unmark after his Death!" color 0xFFFFFF00
else if MODE == UNMARK_AFTER_I_KILLED_HIM
then 0AF8: samp add_message_to_chat "Killer Marker: Mark Killers, Unmark when I Killed Him!" color 0xFFFF00FF
else 0AF8: samp add_message_to_chat "Killer Marker: Mark Killers Permanently!" color 0xFF00FF00
end
end
end
else
0AF8: samp add_message_to_chat "Killer Marker {0000ff}by {00ff00}AJOM from UGBASE.EU" color 0xFFFF0000
0AF8: samp add_message_to_chat "Commands:" color 0xFFFFFFFF
0AF8: samp add_message_to_chat "/killermarker mode 0 {ffff00}~ Disables this Script." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker mode 1 {ffff00}~ Mark Killers, Unmark after his Death." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker mode 2 {ffff00}~ Mark Killers, Unmark when I Killed Him." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker mode 3 {ffff00}~ Mark Killers Permanently." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker add <Player ID> {ffff00}~ Manually Mark a Player using the Default Marker Color." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker add <Player ID> <0xAARRGGBB> {ffff00}~ Manually Mark a Player with a specified color." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker del <Player ID> {ffff00}~ Manually UnMark a Player." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker cmc <0xAARRGGBB> {ffff00}~ Change the Marker Color." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker Blink 0 {ffff00}~ Killer Marker will be a Solid Color." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker Blink 1 {ffff00}~ Killer Marker will have a Blinking effect." color 0xFFFF00FF
0AF8: samp add_message_to_chat "/killermarker cbi <Blinking Interval> {ffff00}~ Change the Blinking Interval in MilliSeconds." color 0xFFFF00FF
end
end
end
end
end
end
end
0B43: samp cmd_ret
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~End of CMD Hooks~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Raknet Hooks~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:rpc
0BE5: raknet 0@ = get_hook_param PARAM_PACKETID
if 0@ == RPC_DEATH
then
0BE5: raknet 0@ = get_hook_param PARAM_BITSTREAM
0BEB: raknet bit_stream 0@ ignore_bits 8 // bReason
0BE7: raknet 1@ = bit_stream_read 0@ type BS_TYPE_SHORT // sKillerID
0C8A: samp 2@ = get_max_player_id streamed_only false
if and
// 1@ <> 0xFFFF // killer isn't undefined
// killer ID is valid
1@ >= 0
002D: 2@ >= 1@
//
then 0AB1: @AddToMarkList 3 _MarkerDatabase MARKERDATABASE _PlayerID 1@ _Color MARKERCOLOR _ReturnNewDatabase MARKERDATABASE
end
else if 0@ == RPC_SCRDEATHMESSAGE
then
0BE5: raknet 0@ = get_hook_param PARAM_BITSTREAM
0BE7: raknet 1@ = bit_stream_read 0@ type BS_TYPE_SHORT // sKillerID
0BE7: raknet 2@ = bit_stream_read 0@ type BS_TYPE_SHORT // sPlayerID
0C8A: samp 3@ = get_max_player_id streamed_only false
if and
// 1@ <> 0xFFFF // killer isn't undefined
// killer ID is valid
1@ >= 0
002D: 3@ >= 1@
//
then
0B2B: samp 3@ = get_player_id_by_actor_handle $PLAYER_ACTOR
if 003B: 3@ == 2@ // I was the one who got killed
then 0AB1: @AddToMarkList 3 _MarkerDatabase MARKERDATABASE _PlayerID 1@ _Color MARKERCOLOR _ReturnNewDatabase MARKERDATABASE
else if and
MODE == UNMARK_AFTER_I_KILLED_HIM
003B: 3@ == 1@ // I was the one who killed a certain player
then 0AB1: @RemoveToMarkList 2 _MarkerDatabase MARKERDATABASE _PlayerID 2@
else if MODE == UNMARK_EVERYTIME_HE_DIES
then 0AB1: @RemoveToMarkList 2 _MarkerDatabase MARKERDATABASE _PlayerID 2@
end
end
end
end
end
end
0BE0: raknet hook_ret true
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~End of Raknet Hooks~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PHP:
[DEFAULT]
; Mode = 0 // Script is Disabled
; Mode = 1 // Mark Killers, but unmark them when they die
; Mode = 2 // Mark Killers, but unmark them when I Killed them
; Mode = <other values> // Mark Killers permanently
Mode = 1
Blinking_Marker_Colors = 1
Blink_Interval_ms = 500
Marker_Color = 0xFFFF0000
; Killer Marker {0000ff}by {00ff00}AJOM
; Commands:
; /killermarker mode 0 ~ Disables this Script.
; /killermarker mode 1 ~ Mark Killers, Unmark after his Death.
; /killermarker mode 2 ~ Mark Killers, Unmark when I Killed Him.
; /killermarker mode 3 ~ Mark Killers Permanently.
; /killermarker add <Player ID> ~ Manually Mark a Player using the Default Marker Color.
; /killermarker add <Player ID> <0xAARRGGBB> ~ Manually Mark a Player with a specified color.
; /killermarker del <Player ID> ~ Manually UnMark a Player.
; /killermarker cmc <0xAARRGGBB> ~ Change the Marker Color.
; /killermarker Blink 0 ~ Killer Marker will be a Solid Color.
; /killermarker Blink 1 ~ Killer Marker will have a Blinking effect.
; /killermarker cbi <Blinking Interval> ~ Change the Blinking Interval in MilliSeconds.
Credits:
- AJOM - Script Creator/Author