Files
wnsrc/gamemodes/darkrp/plugins/nicknames/sv_plugin.lua
lifestorm 6a58f406b1 Upload
2024-08-04 23:54:45 +03:00

53 lines
1.7 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
function PLUGIN:SetNickName(client, nickname)
if (nickname) then
if string.len(nickname) <= 1 then
client:Notify("Bu takma ad çok kısa!")
return
end
if string.len(nickname) > ix.config.Get("maxNicknameLength", 40) then
client:Notify("Bu takma ad çok uzun!")
return
end
end
local target = client:GetEyeTraceNoCursor().Entity
if (!IsValid(target) or !(target:IsPlayer() or target:GetClass() == "prop_ragdoll")) then
client:Notify("Geçerli bir hedefe bakıyor olmalısınız!")
return
end
if target:GetNetVar("ixMaskEquipped") then
client:Notify("Maskeli kişilere takma ad atayamazsınız!")
return false
end
if target:GetNetVar("combineMaskEquipped") then
client:Notify("Maskeli kişilere takma ad atayamazsınız!")
return false
end
local localChar = client:GetCharacter()
local targCharacter = (target.GetCharacter and target:GetCharacter() or false)
if !targCharacter or !localChar then return false end
local targetCharID = targCharacter:GetID()
local nickNames = localChar:GetNickNames()
nickNames[targetCharID] = nickname
localChar:SetNickNames(nickNames)
client:Notify((nickname and "Assigned" or "Removed").." nickname "..(!nickname and "" or "'"..nickname.."'")..(nickname and " to" or "from").." this character.")
end