CLEO Help Help me modify my lua.

CLEO related
Status
Not open for further replies.

Guel

Member
Joined
Aug 8, 2020
Messages
20
Reaction score
1
Location
Philippines
I want to remove the "_" in the name and get the weapon name I'm holding in the output, here's the code.

need help for the output: /me gets his ((the weapon im holding)) and shoots ((player ID im pointing to without underscore)) in the head.


Code:
require "moonloader"
require "sampfuncs"
local sampev = require "lib.samp.events"
local key = require 'vkeys'
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local vkeys = require 'vkeys'
script_name("AimVest")
script_author("SA:MP Squad")

function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("AimRP By {33CCFF}Migeru from {7289da}Hanako-Kai, {FF0000}Press Aim+Q to {FFA500}RP.", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, tPlayer = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys.VK_Q) then
            wait(500)
                local result, playerid = sampGetPlayerIdByCharHandle(tPlayer)
                name = sampGetPlayerNickname(playerid)
                if result then
                    sampSendChat("/me gets his deagle and shoots " .. name .. " in the head.")
                end
            end
        end
        wait(0)
    end
end
 

SobFoX

Expert
Joined
Jul 14, 2015
Messages
1,463
Solutions
5
Reaction score
916
Location
Israel
PHP:
require "moonloader"
require "sampfuncs"
local sampev = require "lib.samp.events"
local key = require 'vkeys'
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local vkeys = require 'vkeys'
script_name("AimVest")
script_author("SA:MP Squad")

function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("AimRP By {33CCFF}Migeru from {7289da}Hanako-Kai, {FF0000}Press Aim+Q to {FFA500}RP.", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, tPlayer = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys.VK_Q) then
            wait(500)
                local result, playerid = sampGetPlayerIdByCharHandle(tPlayer)
                name = sampGetPlayerNickname(playerid)
                name = name:str:gsub("_", " ")
                if result then
                    local weaponid = getCurrentCharWeapon(playerPed)
                    sampSendChat("/me gets his "..WeaponsName[weaponid].." and shoots " .. name .. " in the head.")
                end
            end
        end
        wait(0)
    end
end

WeaponsName =
{
    "Fist", "Brass Knuckles", "Golf Club", "Nightstick", "Knife", "Baseball Bat", "Shovel", "Pool Cue",
    "Katana", "Chainsaw", "Purple Dildo", "Dildo", "Vibrator", "Silver Vibrator", "Flowers", "Cane",
    "Grenade", "Tear Gas", "Molotov Cocktail", "", "", "", "9mm", "Silenced", "Desert Eagle", "Shotgun",
    "Sawnoff Shotgun", "Combat Shotgun", "Uzi", "MP5", "AK-47", "M4", "Tec-9", "Country Rifle", "Sniper Rifle",
    "RPG", "HS Rocket", "Flamethrower", "Minigun", "Satchel Charge", "Detonator", "Spraycan", "Fire Extinguisher",
    "Camera", "Night Vis Goggles", "Thermal Goggles", "Parachute"
}
 

Guel

Member
Joined
Aug 8, 2020
Messages
20
Reaction score
1
Location
Philippines
PHP:
require "moonloader"
require "sampfuncs"
local sampev = require "lib.samp.events"
local key = require 'vkeys'
local encoding = require "encoding"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local vkeys = require 'vkeys'
script_name("AimVest")
script_author("SA:MP Squad")

function main()
    while not isSampAvailable() do wait(50) end
    sampAddChatMessage("AimRP By {33CCFF}Migeru from {7289da}Hanako-Kai, {FF0000}Press Aim+Q to {FFA500}RP.", -1)
    while true do
        if not (sampIsChatInputActive() or sampIsDialogActive() or isSampfuncsConsoleActive()) then
            local res, tPlayer = getCharPlayerIsTargeting(playerHandle)
            if res and isKeyJustPressed(vkeys.VK_Q) then
            wait(500)
                local result, playerid = sampGetPlayerIdByCharHandle(tPlayer)
                name = sampGetPlayerNickname(playerid)
                name = name:str:gsub("_", " ")
                if result then
                    local weaponid = getCurrentCharWeapon(playerPed)
                    sampSendChat("/me gets his "..WeaponsName[weaponid].." and shoots " .. name .. " in the head.")
                end
            end
        end
        wait(0)
    end
end

WeaponsName =
{
    "Fist", "Brass Knuckles", "Golf Club", "Nightstick", "Knife", "Baseball Bat", "Shovel", "Pool Cue",
    "Katana", "Chainsaw", "Purple Dildo", "Dildo", "Vibrator", "Silver Vibrator", "Flowers", "Cane",
    "Grenade", "Tear Gas", "Molotov Cocktail", "", "", "", "9mm", "Silenced", "Desert Eagle", "Shotgun",
    "Sawnoff Shotgun", "Combat Shotgun", "Uzi", "MP5", "AK-47", "M4", "Tec-9", "Country Rifle", "Sniper Rifle",
    "RPG", "HS Rocket", "Flamethrower", "Minigun", "Satchel Charge", "Detonator", "Spraycan", "Fire Extinguisher",
    "Camera", "Night Vis Goggles", "Thermal Goggles", "Parachute"
}
THANK YOU SIR U GIVE ME AN IDEA !!!!!
 
Status
Not open for further replies.
Top