Skip to content

Commit c5145d3

Browse files
committed
Update key defines so they match and handle false returns from getWeaponNameFromID in GetWeaponName
1 parent 97b77f6 commit c5145d3

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

amx/server/defines.lua

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,25 @@ local controlMappingMT = {
8282

8383
g_KeyMapping = setmetatable({
8484
[1] = 'action',
85-
[2] = 'crouch',
86-
[4] = { 'fire', 'vehicle_fire' },
87-
[8] = 'sprint',
88-
[16] = 'vehicle_secondary_fire',
89-
[32] = 'jump',
90-
[64] = 'vehicle_look_right',
91-
[128] = 'handbrake',
92-
[256] = 'vehicle_look_left',
93-
[512] = { 'look_behind', 'sub_mission' },
94-
[1024] = 'walk',
95-
[2048] = 'special_control_up',
96-
[4096] = 'special_control_down',
97-
[8192] = 'special_control_left',
98-
[16384] = 'special_control_right',
85+
[2 ^ 1] = 'crouch',
86+
[2 ^ 2] = { 'fire', 'vehicle_fire' },
87+
[2 ^ 3] = 'sprint',
88+
[2 ^ 4] = { 'enter_exit','vehicle_secondary_fire' },
89+
[2 ^ 5] = 'jump',
90+
[2 ^ 6] = 'vehicle_look_right',
91+
[2 ^ 7] = { 'handbrake', 'aim_weapon' },
92+
[2 ^ 8] = 'vehicle_look_left',
93+
[2 ^ 9] = { 'look_behind', 'sub_mission' },
94+
[2 ^ 10] = 'walk',
95+
[2 ^ 11] = 'special_control_up',
96+
[2 ^ 12] = 'special_control_down',
97+
[2 ^ 13] = 'special_control_left',
98+
[2 ^ 14] = 'special_control_right',
99+
[2 ^ 15] = 'not_used',
100+
[2 ^ 16] = 'conversation_yes',
101+
[2 ^ 17] = 'conversation_no',
102+
[2 ^ 18] = 'group_control_back',
103+
[2 ^ 19] = 'enter_passenger', --This one's undefined
99104
}, controlMappingMT)
100105

101106
g_LeftRightMapping = setmetatable({

amx/server/syscalls.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,14 @@ end
894894

895895
function GetWeaponName(amx, weaponID, buf, len)
896896
local name = getWeaponNameFromID(weaponID)
897-
if #name < len then
897+
if name ~= false and #name < len then
898898
writeMemString(amx, buf, name)
899+
return 1
900+
else
901+
writeMemString(amx, buf, '') --I was going to return 'None' in here, but I believe SA-MP just returns a blank string
902+
return 0
899903
end
904+
return 1
900905
end
901906

902907
function GivePlayerMoney(amx, player, amount)

0 commit comments

Comments
 (0)