|
80 | 80 | RegisterNetEvent("vMenu:kickPlayer") |
81 | 81 | AddEventHandler("vMenu:kickPlayer", function(targetId, reason) |
82 | 82 | local src = source |
83 | | - local adminName = GetPlayerName(src) |
84 | | - |
85 | | - if GetPlayerPing(targetId) > 0 then -- Check if player exists |
86 | | - local targetName = GetPlayerName(targetId) |
87 | | - DropPlayer(targetId, "Kicked by " .. adminName .. " - Reason: " .. reason) |
88 | | - |
89 | | - TriggerClientEvent('chat:addMessage', -1, { |
90 | | - color = {255, 165, 0}, |
91 | | - multiline = true, |
92 | | - args = {"[Admin]", targetName .. " was kicked by " .. adminName .. " - Reason: " .. reason} |
93 | | - }) |
94 | | - else |
| 83 | + local adminName = GetPlayerName(src) or "Console" |
| 84 | + if src ~= 0 and not IsPlayerAceAllowed(src, "vmenu.ban") then |
95 | 85 | TriggerClientEvent('chat:addMessage', src, { |
96 | 86 | color = {255, 0, 0}, |
97 | 87 | multiline = true, |
98 | | - args = {"[Error]", "Player not found"} |
| 88 | + args = {"[Error]", "You do not have permission to use this command."} |
99 | 89 | }) |
| 90 | + return |
| 91 | + end |
| 92 | + if GetPlayerPing(targetId) > 0 then |
| 93 | + local targetName = GetPlayerName(targetId) |
| 94 | + DropPlayer(targetId, "Kicked by " .. adminName .. " - Reason: " .. reason) |
| 95 | + else |
100 | 96 | end |
101 | 97 | end) |
102 | 98 |
|
| 99 | + |
103 | 100 | RegisterNetEvent("vMenu:banPlayer") |
104 | 101 | AddEventHandler("vMenu:banPlayer", function(targetId, reason) |
105 | 102 | local src = source |
106 | | - local adminName = GetPlayerName(src) |
107 | | - |
108 | | - if GetPlayerPing(targetId) > 0 then -- Check if player exists |
109 | | - local targetName = GetPlayerName(targetId) |
110 | | - local identifier = GetPlayerIdentifier(targetId, 0) |
111 | | - |
112 | | - -- You would typically save this to a database |
113 | | - -- For now, just kick the player |
114 | | - DropPlayer(targetId, "Banned by " .. adminName .. " - Reason: " .. reason) |
115 | | - |
116 | | - TriggerClientEvent('chat:addMessage', -1, { |
117 | | - color = {255, 0, 0}, |
118 | | - multiline = true, |
119 | | - args = {"[Admin]", targetName .. " was banned by " .. adminName .. " - Reason: " .. reason} |
120 | | - }) |
121 | | - else |
| 103 | + local adminName = GetPlayerName(src) or "Console" |
| 104 | + if src ~= 0 and not IsPlayerAceAllowed(src, "vmenu.ban") then |
122 | 105 | TriggerClientEvent('chat:addMessage', src, { |
123 | 106 | color = {255, 0, 0}, |
124 | 107 | multiline = true, |
125 | | - args = {"[Error]", "Player not found"} |
| 108 | + args = {"[Error]", "You do not have permission to use this command."} |
126 | 109 | }) |
| 110 | + return |
| 111 | + end |
| 112 | + |
| 113 | + if GetPlayerPing(targetId) > 0 then |
| 114 | + local targetName = GetPlayerName(targetId) |
| 115 | + local identifier = GetPlayerIdentifier(targetId, 0) |
| 116 | + |
| 117 | + DropPlayer(targetId, "Banned by " .. adminName .. " - Reason: " .. reason) |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + print(("[sMenu] %s banned %s (%s) - Reason: %s"):format(adminName, targetName, identifier or "unknown", reason or "none")) |
| 122 | + else |
| 123 | + |
127 | 124 | end |
128 | 125 | end) |
129 | 126 |
|
| 127 | + |
130 | 128 | RegisterNetEvent("vMenu:teleportToPlayer") |
131 | 129 | AddEventHandler("vMenu:teleportToPlayer", function(targetId) |
132 | 130 | local src = source |
133 | 131 |
|
134 | | - if GetPlayerPing(targetId) > 0 then -- Check if player exists |
| 132 | + if GetPlayerPing(targetId) > 0 then |
135 | 133 | local targetPed = GetPlayerPed(targetId) |
136 | 134 | local targetCoords = GetEntityCoords(targetPed) |
137 | 135 |
|
|
0 commit comments