Help Need help whit .lua

mesa

Member
Joined
Dec 20, 2018
Messages
6
Reaction score
0
require "lib.moonloader" local sampev = require("samp.events") local vkeys = require 'vkeys' if isKeyDown(VK_MENU) and isKeyJustPressed(VK_F2) then local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) if valid and doesCharExist(ped) then local result, id = sampGetPlayerIdByCharHandle(ped) if result then sampSendChat("ok") wait(200) sampSendChat("/ant "..id) end end end
I have this code, it loads into moonloader successfully, but the F2 button dosent work. Its a simple script i know but, I'm new for this shit so please help..
 

Saam

Active member
Joined
Apr 18, 2021
Messages
121
Solutions
1
Reaction score
64
Location
0x73616D
Test it
JSON:
require "lib.moonloader"
local sampev = require("samp.events")
local vkeys = require 'vkeys'

function main()
    while not isSampAvailable() do wait(0) end
        
    while true do
        wait(0)
        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_F2) then       
            local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
            if valid and doesCharExist(ped) then
              local result, id = sampGetPlayerIdByCharHandle(ped)
              if result then
                sampSendChat("ok")
                wait(200) sampSendChat("/ant "..id)
               end
            end
        end
    end
end
 

mesa

Member
Joined
Dec 20, 2018
Messages
6
Reaction score
0
Test it
JSON:
require "lib.moonloader"
local sampev = require("samp.events")
local vkeys = require 'vkeys'

function main()
    while not isSampAvailable() do wait(0) end
       
    while true do
        wait(0)
        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_F2) then      
            local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
            if valid and doesCharExist(ped) then
              local result, id = sampGetPlayerIdByCharHandle(ped)
              if result then
                sampSendChat("ok")
                wait(200) sampSendChat("/ant "..id)
               end
            end
        end
    end
end
Thanks a lot for replying, the same shit happening, I can see in moonloader.log that the script loaded successfully but it dose not work ing...
 
Top