Jump to content

A way?


manve1

Recommended Posts

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 

Link to comment

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) 

Link to comment

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) 

Link to comment

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) 

Link to comment
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?

Link to comment
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.

Link to comment
  • Other Languages Moderators
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.

Link to comment

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...