что здесь не так?

Sam201

Известный
Автор темы
103
5
Версия MoonLoader
.027.0-preview
что здесь не так?
Lua:
function sampev.onRemovePlayerFromVehicle()
    if enabled then
        -- Check if the player is in a Sultan (model ID 560)
        local vehicle = sampGetPlayerVehicle(playerId)
        if vehicle and getElementModel(vehicle) == 560 then
           --[код]
 

Iskon

Участник
110
18
что здесь не так?
Lua:
function sampev.onRemovePlayerFromVehicle()
    if enabled then
        -- Check if the player is in a Sultan (model ID 560)
        local vehicle = sampGetPlayerVehicle(playerId)
        if vehicle and getElementModel(vehicle) == 560 then
           --[код]
Ты забыл в параметрах функции записать переменную enabled, и остальные, если они есть
 

Sam201

Известный
Автор темы
103
5
You forgot to write the enabled variable in the function parameters, and the rest, if any,
local enabled
это в коде

Что-то еще не так?

Lua:
require "moonloader"
require 'sampfuncs'

local sampev = require "lib.samp.events"
local enabled = true
local playerId = nil

function main()
    while not isSampAvailable() do wait(50) end

    sampAddChatMessage("{9BBC57}test loaded!", -1)
    playerId = sampGetPlayerIdByCharHandle(PLAYER_PED)
    sampRegisterChatCommand("test", function()
        enabled = not enabled
        if enabled then
            sampAddChatMessage("{2471A3}test{FFFFFF} has been {0FFF00}Enabled", -1)
        else
            sampAddChatMessage("{2471A3}test{FFFFFF} has been {FF0000}Disabled", -1)
        end
    end)
end

function sampev.onRemovePlayerFromVehicle()
    if enabled then
        -- Check if the player is in a Sultan (model ID 560)
        local vehicle = sampGetPlayerVehicle(playerId)
        if vehicle and getElementModel(vehicle) == 560 then
 sampAddChatMessage("{FF0000}код работает", -1)
end
end
end

полный код
 
Последнее редактирование:

wojciech?

Известный
Проверенный
404
358
используешь несуществующие функции, вот и не работает
Lua:
function sampev.onRemovePlayerFromVehicle()
    if enabled and isCharSittingInAnyCar(PLAYER_PED) then
        -- Check if the player is in a Sultan (model ID 560)
        local vehicle = storeCarCharIsInNoSave(PLAYER_PED)
        if getCarModel(vehicle) == 560 then
            sampAddChatMessage("{FF0000}код работает", -1)
        end
    end
end
 
  • Влюблен
Реакции: Sam201

Sam201

Известный
Автор темы
103
5
используешь несуществующие функции, вот и не работает
Lua:
function sampev.onRemovePlayerFromVehicle()
    if enabled and isCharSittingInAnyCar(PLAYER_PED) then
        -- Check if the player is in a Sultan (model ID 560)
        local vehicle = storeCarCharIsInNoSave(PLAYER_PED)
        if getCarModel(vehicle) == 560 then
            sampAddChatMessage("{FF0000}код работает", -1)
        end
    end
end
Большое спасибо!