Код крашит игру

Соколл

Новичок
Автор темы
4
0
Lua:
script_name('Autohistory')


local tag = "[FastHISTTEST]: "


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

        sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)

         sampRegisterChatCommand("hist", ima)

         while true do
            wait(0)
        end
    end

function ima()
    _, id = sampGetPlayerIdByCharHandle(ped)
    sampSendChat("/history "..sampGetPlayerNickname(id))
end

Что тут не так? введя в игре команду /hist id игра крашит
 
Последнее редактирование:

MrCreepTon

Неизвестный
Всефорумный модератор
2,133
4,730
Lua:
script_name('Autohistory')

local tag = "[FastHISTTEST]: "

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)
    sampRegisterChatCommand("hist", function(param)
        if not param:match('%d+') then return sampAddChatMessage('use /hist [id]', -1) end
        if not sampIsPlayerConnected(param) then return sampAddChatMessage("can't get player", -1) end
        sampSendChat('/history '..param)
    end)
    while true do
        wait(0)   
    end
end
 

Соколл

Новичок
Автор темы
4
0
Lua:
script_name('Autohistory')

local tag = "[FastHISTTEST]: "

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)
    sampRegisterChatCommand("hist", function(param)
        if not param:match('%d+') then return sampAddChatMessage('use /hist [id]', -1) end
        if not sampIsPlayerConnected(param) then return sampAddChatMessage("can't get player", -1) end
        sampSendChat('/history '..param)
    end)
    while true do
        wait(0)  
    end
end
Не работает.
 

Pakulichev

Software Developer & System Administrator
Друг
1,789
2,135
Lua:
script_name('Autohistory')

local tag = "[FastHISTTEST]: "

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)
    sampRegisterChatCommand("hist", function(param)
        if not param:match('%d+') then return sampAddChatMessage('use /hist [id]', -1) end
        if not sampIsPlayerConnected(tonumber(param)) then return sampAddChatMessage("can't get player", -1) end
        sampSendChat('/history '..tonumber(param))
    end)
    while true do
        wait(0) 
    end
end
Нужно вводить никнейм, а не ID.
Lua:
script_name('Autohistory')

local tag = "[FastHISTTEST]: "

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)
    sampRegisterChatCommand("hist", function(param)
        if not param:match('%d+') then return sampAddChatMessage('use /hist [id]', -1) end
        if not sampIsPlayerConnected(tonumber(param)) then return sampAddChatMessage("can't get player", -1) end
        sampSendChat('/history '..sampGetPlayerNickname(tonumber(param)))
    end)
    while true do
        wait(0)
    end
end
 
  • Нравится
Реакции: MrCreepTon

Соколл

Новичок
Автор темы
4
0
Нужно вводить никнейм, а не ID.
Lua:
script_name('Autohistory')

local tag = "[FastHISTTEST]: "

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)
    sampRegisterChatCommand("hist", function(param)
        if not param:match('%d+') then return sampAddChatMessage('use /hist [id]', -1) end
        if not sampIsPlayerConnected(tonumber(param)) then return sampAddChatMessage("can't get player", -1) end
        sampSendChat('/history '..sampGetPlayerNickname(tonumber(param)))
    end)
    while true do
        wait(0)
    end
end
Дак зачем мне никнейм? я специально и хочу скрипт для ид
 

Pakulichev

Software Developer & System Administrator
Друг
1,789
2,135
Дак зачем мне никнейм? я специально и хочу скрипт для ид
Я про то, что команда history принимает никнейм, а @MrCreepTon подставляет туда ID игрока, что неверно. Проверь код - должен работать. Использовать: /hist ID.
 

MrCreepTon

Неизвестный
Всефорумный модератор
2,133
4,730
Нужно вводить никнейм, а не ID.
Lua:
script_name('Autohistory')

local tag = "[FastHISTTEST]: "

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage(tag.."{C71585}СОКОЛ СКРИПТ БЫЛ ЗАГРУЖЕН",-1)
    sampRegisterChatCommand("hist", function(param)
        if not param:match('%d+') then return sampAddChatMessage('use /hist [id]', -1) end
        if not sampIsPlayerConnected(tonumber(param)) then return sampAddChatMessage("can't get player", -1) end
        sampSendChat('/history '..sampGetPlayerNickname(tonumber(param)))
    end)
    while true do
        wait(0)
    end
end
tonumber в данном случае не играет роли, но это мелочь уже