Jump to content

A way?


manve1

Recommended Posts

Posted

would there be a way i could make my script blow someones vehicles when i do: /boom ?

function ( player ) 
            local vehicle = getPedOccupiedVehicle ( player ) 
            if ( vehicle ) then 
                if ( boom ) then 
                    blowVehicle ( vehicle ) 
                end 
            end 
        end 

Looking for tutorials or information? check out: www.simpleask.co.uk

Posted

ya, try this:

function power(source,action,player) 
    player = getPlayerFromName(player) 
    if not player then outputChatBox("sorry, but we need the player full name!",source) return end 
    if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end 
    local vehicle = getPedOccupiedVehicle ( player ) 
    if ( action == "fix" ) then 
        fixVehicle ( vehicle ) 
    elseif ( action == "blow" ) then 
        blowVehicle ( vehicle ) 
    end 
end 
addCommandHandler("blow",power) 
addCommandHandler("fix",power) 

oh, server-side BTW, unless you want it client-side try this:

function power(action,player) 
    player = getPlayerFromName(player) 
    if not player then outputChatBox("sorry, but we need the player full name!") return end 
    if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!") return end 
    local vehicle = getPedOccupiedVehicle ( player ) 
    if ( action == "fix" ) then 
        fixVehicle ( vehicle ) 
    elseif ( action == "blow" ) then 
        blowVehicle ( vehicle ) 
    end 
end 
addCommandHandler("blow",power) 
addCommandHandler("fix",power) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

You may want to use getPlayerFromNamePart from Wiki's Useful Functions.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
dont work :( no output or anything

They should work, which one did you try?

It will never work because you used getPlayerFromName which will only work if you write the full name ( with color codes ).

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Anderl code looks like this:

    function power(source,action,player) 
        player = getPlayerFromNamePart(player) 
        if not player then outputChatBox("sorry, but we need the player full name!",source) return end 
        if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( action == "fix" ) then 
            fixVehicle ( vehicle ) 
        elseif ( action == "blow" ) then 
            blowVehicle ( vehicle ) 
        end 
    end 
    addCommandHandler("blow",power) 
    addCommandHandler("fix",power) 

Looking for tutorials or information? check out: www.simpleask.co.uk

Posted

oh, got confused now

confused of how should i make the getPlayerFromNamePart

EDIT: i tried making it work .. but failed:

    function power(source,action,player) 
    player = getPlayerName( source ) 
        if name then  
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player  
            end 
        end 
        if not player then outputChatBox("sorry, but we need the player full name!",source) return end 
        if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( action == "fix" ) then 
            fixVehicle ( vehicle ) 
        elseif ( action == "blow" ) then 
            blowVehicle ( vehicle ) 
        end 
    end 
    end 
    addCommandHandler("blow",power) 
    addCommandHandler("fix",power) 

Looking for tutorials or information? check out: www.simpleask.co.uk

Posted
oh, got confused now

confused of how should i make the getPlayerFromNamePart

EDIT: i tried making it work .. but failed:

    function power(source,action,player) 
    player = getPlayerName( source ) 
        if name then  
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player  
            end 
        end 
        if not player then outputChatBox("sorry, but we need the player full name!",source) return end 
        if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( action == "fix" ) then 
            fixVehicle ( vehicle ) 
        elseif ( action == "blow" ) then 
            blowVehicle ( vehicle ) 
        end 
    end 
    end 
    addCommandHandler("blow",power) 
    addCommandHandler("fix",power) 

Your code makes totally no sense.

Is it that hard to copy a function to your code?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
function getPlayerFromNamePart(name) 
    if name then  
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player  
            end 
        end 
    end 
    return false 
end 
  
function onPlayerCommands ( source, cmd, target ) 
    local targetplayer = getPlayerFromNamePart ( target ) 
    if ( targetplayer ) then 
        local vehicle = getPedOccupiedVehicle ( targetplayer ) 
        if ( vehicle ) then 
            if ( cmd == "blow" ) then 
                blowVehicle ( vehicle ) 
            elseif ( cmd == "fix" ) then 
                fixVehicle ( vehicle ) 
            end 
        end 
    end 
end 
addCommandHandler ( "blow", onPlayerCommands ) 
addCommandHandler ( "fix", onPlayerCommands ) 

Try that, untested.

Ingame nick: Cadu12

Posted
fix works, blow doesn't

This problem from ACL

You will find this in ACL

"command.blow" access="false">

change it to

"command.blow" access="true">

CiTLh.png
Posted
fix works, blow doesn't

This problem from ACL

You will find this in ACL

"command.blow" access="false">

change it to

"command.blow" access="true">

That's for admin panel blow command, it has nothing to do with blow function.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
fix works, blow doesn't

This problem from ACL

You will find this in ACL

"command.blow" access="false">

change it to

"command.blow" access="true">

That's for admin panel blow command, it has nothing to do with blow function.

I haven't say this has anything to do with blow function, it's about the command itself.

if the command was blocked in ACL, you will not be able to use it without right, that is the reason why the script doesn't blow the vehicle.

CiTLh.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...