How to print Nickname in the chat

Userinspace

Новичок
Автор темы
12
3
Версия MoonLoader
Другое
Hello there!
So this mod prints the id of the person you are aiming at in the chat. I want the mod to print Nickname/username in the chat instead of the id.
I tried adding "sampGetPlayerNickname" but it didnt work for me. Can a good hearted soul please edit the code below and add nickname instead of id please.

Код:
function main()
    while not isSampAvailable() do wait(50) end
sampAddChatMessage("{2B60DE}Don't Be Wise! {FFFFFF} By {FF4545}[SALMAN] {FFFFFF}loaded {00FF00}successfully", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, player = getCharPlayerIsTargeting(playerHandle)
if res and isKeyJustPressed(vkeys. VK_U) then
                local result, playername = sampGetPlayerIdByCharHandle(player)
                if result then
                    sampSendChat("/b MOD test: " .. playername .. " !!")
                end
            end
        end
        wait(0)
    end
end
 

yung milonov

Известный
1,008
519
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("{2B60DE}Don't Be Wise! {FFFFFF} By {FF4545}[SALMAN] {FFFFFF}loaded {00FF00}successfully", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, player = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys. VK_U) then
                local result, id = sampGetPlayerIdByCharHandle(player)
                if result then
                    sampSendChat("/b MOD test: " .. sampGetPlayerNickname(id) .. " !!")
                end
            end
        end
        wait(0)
    end
end
 
  • Нравится
Реакции: Z3roKwq и YarikVL

Userinspace

Новичок
Автор темы
12
3
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("{2B60DE}Don't Be Wise! {FFFFFF} By {FF4545}[SALMAN] {FFFFFF}loaded {00FF00}successfully", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, player = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys. VK_U) then
                local result, id = sampGetPlayerIdByCharHandle(player)
                if result then
                    sampSendChat("/b MOD test: " .. sampGetPlayerNickname(id) .. " !!")
                end
            end
        end
        wait(0)
    end
end
Is it possible to remove the "_" in the nickname? So i want it to print " Full Name" instead of "Full_Name"
 

yung milonov

Известный
1,008
519
Is it possible to remove the "_" in the nickname? So i want it to print " Full Name" instead of "Full_Name"
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("{2B60DE}Don't Be Wise! {FFFFFF} By {FF4545}[SALMAN] {FFFFFF}loaded {00FF00}successfully", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, player = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys. VK_U) then
                local result, id = sampGetPlayerIdByCharHandle(player)
                if result then
                    sampSendChat("/b MOD test: " .. string.gsub(sampGetPlayerNickname(id), "_", " ") .. " !!")
                end
            end
        end
        wait(0)
    end
end
 

Userinspace

Новичок
Автор темы
12
3
Th
Lua:
function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("{2B60DE}Don't Be Wise! {FFFFFF} By {FF4545}[SALMAN] {FFFFFF}loaded {00FF00}successfully", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, player = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys. VK_U) then
                local result, id = sampGetPlayerIdByCharHandle(player)
                if result then
                    sampSendChat("/b MOD test: " .. string.gsub(sampGetPlayerNickname(id), "_", " ") .. " !!")
                end
            end
        end
        wait(0)
    end
end
Thanks life saver.
 
  • Нравится
Реакции: yung milonov