Помогите с кодом

Статус
В этой теме нельзя размещать новые ответы.

Licht

Известный
Автор темы
238
32
Lua:
function main()
  repeat wait(0) until isSampAvailable()
  wait(-1)
end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
  lua_thread.create(function()
    if wasKeyPressed(88) then
    if playerId ~= nil and playerId ~= tonumber('65535') and weapon ~= nil and damage ~= nil then
        local color = string.sub(string.format('%x', sampGetPlayerColor(playerId)), 3)
        if color == 'ffff' or weapon == 34 then
            hkill = true
            damageplayer = sampGetPlayerNickname(playerId)
            weaponinfo = 'Вооружённое нападение'
        else
            damageplayer = sampGetPlayerNickname(playerId)
            hkill = false
            if weapon == 0 or weapon == 46 then
                if isCharModel(playerPed, 295) or isCharModel(playerPed, 287) or isCharModel(playerPed, 285) or isCharModel(playerPed, 179) or isCharModel(playerPed, 255) or isCharModel(playerPed, 191) or isCharModel(playerPed, 73) or isCharModel(playerPed, 61) or isCharModel(playerPed, 284) or isCharModel(playerPed, 283) or isCharModel(playerPed, 282) or isCharModel(playerPed, 281) or isCharModel(playerPed, 280) or isCharModel(playerPed, 265) or isCharModel(playerPed, 266) or isCharModel(playerPed, 267) or isCharModel(playerPed, 309) or isCharModel(playerPed, 310) or isCharModel(playerPed, 311) or isCharModel(playerPed, 300) or isCharModel(playerPed, 301) or isCharModel(playerPed, 302) or isCharModel(playerPed, 286) or isCharModel(playerPed, 165) or isCharModel(playerPed, 166) then
                    weaponinfo = 'Нападение на сотр. ПО'
                else
                    weaponinfo = 'Нападение на гражд. лицо'
                end
            else
                weaponinfo = 'Вооружённое нападение'
            end
        end
        playerId = nil
        damage = nil
    end
    end
  end)
end

Что тут не так? Туда ли впихнул if waskeypressed...?
 

штейн

Известный
Проверенный
1,003
688
Lua:
function main()
  repeat wait(0) until isSampAvailable()
  wait(-1)
end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
  lua_thread.create(function()
    if wasKeyPressed(88) then
    if playerId ~= nil and playerId ~= tonumber('65535') and weapon ~= nil and damage ~= nil then
        local color = string.sub(string.format('%x', sampGetPlayerColor(playerId)), 3)
        if color == 'ffff' or weapon == 34 then
            hkill = true
            damageplayer = sampGetPlayerNickname(playerId)
            weaponinfo = 'Вооружённое нападение'
        else
            damageplayer = sampGetPlayerNickname(playerId)
            hkill = false
            if weapon == 0 or weapon == 46 then
                if isCharModel(playerPed, 295) or isCharModel(playerPed, 287) or isCharModel(playerPed, 285) or isCharModel(playerPed, 179) or isCharModel(playerPed, 255) or isCharModel(playerPed, 191) or isCharModel(playerPed, 73) or isCharModel(playerPed, 61) or isCharModel(playerPed, 284) or isCharModel(playerPed, 283) or isCharModel(playerPed, 282) or isCharModel(playerPed, 281) or isCharModel(playerPed, 280) or isCharModel(playerPed, 265) or isCharModel(playerPed, 266) or isCharModel(playerPed, 267) or isCharModel(playerPed, 309) or isCharModel(playerPed, 310) or isCharModel(playerPed, 311) or isCharModel(playerPed, 300) or isCharModel(playerPed, 301) or isCharModel(playerPed, 302) or isCharModel(playerPed, 286) or isCharModel(playerPed, 165) or isCharModel(playerPed, 166) then
                    weaponinfo = 'Нападение на сотр. ПО'
                else
                    weaponinfo = 'Нападение на гражд. лицо'
                end
            else
                weaponinfo = 'Вооружённое нападение'
            end
        end
        playerId = nil
        damage = nil
    end
    end
  end)
end

Что тут не так? Туда ли впихнул if waskeypressed...?

Lua:
models = {295, 287, 285, 179, 255, 191, 73, 61, 284, 283, 282, 281, 280, 265, 266, 267, 309, 310, 311, 300, 301, 302, 286, 165, 166}

function main()
  repeat wait(0) until isSampAvailable()
  wait(-1)
end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    lua_thread.create(function()
        while true do wait(0)
            if wasKeyPressed(88) then
                if playerId and playerId ~= tonumber('65535') and weapon and damage then
                    if string.sub(string.format('%x', sampGetPlayerColor(playerId)), 3) == 'ffff' or weapon == 34 then
                        hkill, damageplayer, weaponinfo = true, sampGetPlayerNickname(playerId), 'Вооружённое нападение'
                    else
                        hkill = false
                        if weapon == 0 or weapon == 46 then
                            for _, i in pairs(models) do
                                if isCharModel(playerPed, i) then weaponinfo = 'Нападение на сотр. ПО'
                                else weaponinfo = 'Нападение на гражд. лицо' end
                            end
                        else weaponinfo = 'Вооружённое нападение' end
                    end; playerId, damage = nil, nil
                end
            end
        end
    end)
end -- ot schweitzerrewzeischa ky nub
 
Последнее редактирование:

Licht

Известный
Автор темы
238
32
Добавил даже local, и не работает....
Lua:
models = {295, 287, 285, 179, 255, 191, 73, 61, 284, 283, 282, 281, 280, 265, 266, 267, 309, 310, 311, 300, 301, 302, 286, 165, 166}

local sampev = require 'lib.samp.events'


function main()
  repeat wait(0) until isSampAvailable() wait(-1) end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    lua_thread.create(function()
        while true do wait(0)
            if wasKeyPressed(88) then
                if playerId and playerId ~= tonumber('65535') and weapon and damage then
                    if string.sub(string.format('%x', sampGetPlayerColor(playerId)), 3) == 'ffff' or weapon == 34 then
                        hkill, damageplayer, weaponinfo = true, sampGetPlayerNickname(playerId), 'Вооружённое нападение'
                    else
                        hkill = false
                        if weapon == 0 or weapon == 46 then
                            for _, i in pairs(models) do
                                if isCharModel(playerPed, i) then weaponinfo = 'Нападение на сотр. ПО'
                                else weaponinfo = 'Нападение на гражд. лицо' end
                            end
                        else weaponinfo = 'Вооружённое нападение' end
                    end; playerId, damage = nil, nil
                end
            end
        end
    end)
end
 
Последнее редактирование:

штейн

Известный
Проверенный
1,003
688
Добавил даже local, и не работает....
Lua:
models = {295, 287, 285, 179, 255, 191, 73, 61, 284, 283, 282, 281, 280, 265, 266, 267, 309, 310, 311, 300, 301, 302, 286, 165, 166}

local sampev = require 'lib.samp.events'


function main()
  repeat wait(0) until isSampAvailable() wait(-1) end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    lua_thread.create(function()
        while true do wait(0)
            if wasKeyPressed(88) then
                if playerId and playerId ~= tonumber('65535') and weapon and damage then
                    if string.sub(string.format('%x', sampGetPlayerColor(playerId)), 3) == 'ffff' or weapon == 34 then
                        hkill, damageplayer, weaponinfo = true, sampGetPlayerNickname(playerId), 'Вооружённое нападение'
                    else
                        hkill = false
                        if weapon == 0 or weapon == 46 then
                            for _, i in pairs(models) do
                                if isCharModel(playerPed, i) then weaponinfo = 'Нападение на сотр. ПО'
                                else weaponinfo = 'Нападение на гражд. лицо' end
                            end
                        else weaponinfo = 'Вооружённое нападение' end
                    end; playerId, damage = nil, nil
                end
            end
        end
    end)
end
попробуй на своё говно заменить может в этом проблема
if isCharModel(playerPed, 295) or isCharModel(playerPed, 287) or isCharModel(playerPed, 285) or isCharModel(playerPed, 179) or isCharModel(playerPed, 255) or isCharModel(playerPed, 191) or isCharModel(playerPed, 73) or isCharModel(playerPed, 61) or isCharModel(playerPed, 284) or isCharModel(playerPed, 283) or isCharModel(playerPed, 282) or isCharModel(playerPed, 281) or isCharModel(playerPed, 280) or isCharModel(playerPed, 265) or isCharModel(playerPed, 266) or isCharModel(playerPed, 267) or isCharModel(playerPed, 309) or isCharModel(playerPed, 310) or isCharModel(playerPed, 311) or isCharModel(playerPed, 300) or isCharModel(playerPed, 301) or isCharModel(playerPed, 302) or isCharModel(playerPed, 286) or isCharModel(playerPed, 165) or isCharModel(playerPed, 166) then
мне лень этим заниматься
 

imring

Ride the Lightning
Всефорумный модератор
2,362
2,544
playerId ~= tonumber('65535')
upload_2018-12-16_12-50-16.png

Lua:
local sampev = require 'samp.events'
local bit = require 'bit'

local skins = { 295, 287, 285, 179, 255, 191, 73, 61, 284, 283, 282, 281, 280, 265, 266, 267 309, 310, 311, 300, 301, 302, 286, 165, 166 }

local func = lua_thread.create_suspended(function(playerId, damage, weapon, bodypart)
    while not wasKeyPressed(88) do wait(0) end
        if playerId and playerId ~= 65535 and weapon and damage then
            damageplayer = sampGetPlayerNickname(playerId)
            local color = bit.band(sampGetPlayerColor(playerId), 0xFFFFFF)
            if color == 0xFFFFFF or weapon == 34 then
                hkill = true
                weaponinfo = 'Вооружённое нападение'
            else
                damageplayer = sampGetPlayerNickname(playerId)
                hkill = false
                if weapon == 0 or weapon == 46 then
                    local b = false
                    for i = 1, #skins do
                        if isCharModel(playerPed, skins[i]) then
                            b = true
                            break
                        end
                    end
                    weaponinfo = ( b and 'Нападение на сотр. ПО' or 'Нападение на гражд. лицо' )
                else
                    weaponinfo = 'Вооружённое нападение'
                end
            end
            print(damageplayer, hkill, weaponinfo)
        end
end)

function main() wait(-1) end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    if func:status() == 'running' then func:terminate() end
    func:run(playerId, damage, weapon, bodypart)
end
 

Licht

Известный
Автор темы
238
32
Посмотреть вложение 22661
Lua:
local sampev = require 'samp.events'
local bit = require 'bit'

local skins = { 295, 287, 285, 179, 255, 191, 73, 61, 284, 283, 282, 281, 280, 265, 266, 267 309, 310, 311, 300, 301, 302, 286, 165, 166 }

local func = lua_thread.create_suspended(function(playerId, damage, weapon, bodypart)
    while not wasKeyPressed(88) do wait(0) end
        if playerId and playerId ~= 65535 and weapon and damage then
            damageplayer = sampGetPlayerNickname(playerId)
            local color = bit.band(sampGetPlayerColor(playerId), 0xFFFFFF)
            if color == 0xFFFFFF or weapon == 34 then
                hkill = true
                weaponinfo = 'Вооружённое нападение'
            else
                damageplayer = sampGetPlayerNickname(playerId)
                hkill = false
                if weapon == 0 or weapon == 46 then
                    local b = false
                    for i = 1, #skins do
                        if isCharModel(playerPed, skins[i]) then
                            b = true
                            break
                        end
                    end
                    weaponinfo = ( b and 'Нападение на сотр. ПО' or 'Нападение на гражд. лицо' )
                else
                    weaponinfo = 'Вооружённое нападение'
                end
            end
            print(damageplayer, hkill, weaponinfo)
        end
end)

function main() wait(-1) end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    if func:status() == 'running' then func:terminate() end
    func:run(playerId, damage, weapon, bodypart)
end

[07:42:17.406043] (error) damag_wanted_testing.lua: ...ames\GTA San Andreas\moonloader\damag_wanted_testing.lua:6: '}' expected near '309'
[07:42:17.406043] (error) damag_wanted_testing.lua: Script died due to an error. (0FCD6C4C)
 
Статус
В этой теме нельзя размещать новые ответы.